Changeset 4184

Show
Ignore:
Timestamp:
04/01/08 12:55:34 (9 months ago)
Author:
pmoura
Message:

Renamed some multi-threading auxiliary predicates for clarity.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/compiler/logtalk.pl

    r4183 r4184  
    1295912959 
    1296012960'$lgt_mt_threaded_and_exit'(terminate, _, Ids, _) :- 
    12961     '$lgt_mt_threaded_call_abort'(Ids). 
     12961    '$lgt_mt_threaded_call_cancel'(Ids). 
    1296212962 
    1296312963'$lgt_mt_threaded_and_exit'(exception(Error), _, Ids, _) :- 
    12964     '$lgt_mt_threaded_call_abort'(Ids, Error), 
     12964    '$lgt_mt_threaded_call_cancel'(Ids, Error), 
    1296512965    throw(Error). 
    1296612966 
     
    1296912969    '$lgt_mt_threaded_and_add_result'(Results, Id, TGoal, Continue), 
    1297012970    (   Continue == false -> 
    12971         '$lgt_mt_threaded_call_clean'(Ids) 
     12971        '$lgt_mt_threaded_call_join'(Ids) 
    1297212972    ;   '$lgt_mt_threaded_and_exit'(Ids, Results) 
    1297312973    ). 
    1297412974 
    1297512975'$lgt_mt_threaded_and_exit'(false, _, Ids, _) :- 
    12976     '$lgt_mt_threaded_call_abort'(Ids), 
     12976    '$lgt_mt_threaded_call_cancel'(Ids), 
    1297712977    fail. 
    1297812978 
     
    1302113021 
    1302213022'$lgt_mt_threaded_or_exit'(terminate, _, Ids, _) :- 
    13023     '$lgt_mt_threaded_call_abort'(Ids). 
     13023    '$lgt_mt_threaded_call_cancel'(Ids). 
    1302413024 
    1302513025'$lgt_mt_threaded_or_exit'(exception(Error), _, Ids, _) :- 
    13026     '$lgt_mt_threaded_call_abort'(Ids, Error), 
     13026    '$lgt_mt_threaded_call_cancel'(Ids, Error), 
    1302713027    throw(Error). 
    1302813028 
    1302913029'$lgt_mt_threaded_or_exit'(true, Id, Ids, Results) :- 
    1303013030    thread_get_message('$lgt_result'(Id, TGoal)), 
    13031     '$lgt_mt_threaded_call_abort'(Ids), 
     13031    '$lgt_mt_threaded_call_cancel'(Ids), 
    1303213032    '$lgt_mt_threaded_or_exit_unify'(Results, Id, TGoal). 
    1303313033 
     
    1303713037        '$lgt_mt_threaded_or_exit'(Ids, Results) 
    1303813038    ;   % all goals failed 
    13039         '$lgt_mt_threaded_call_clean'(Ids), 
     13039        '$lgt_mt_threaded_call_join'(Ids), 
    1304013040        fail 
    1304113041    ). 
     
    1308913089% we must use catch/3 as some threads may already be terminated 
    1309013090 
    13091 '$lgt_mt_threaded_call_abort'(Ids) :- 
    13092     '$lgt_mt_threaded_call_cancel'(Ids), 
    13093     '$lgt_mt_threaded_call_clean'(Ids). 
    13094  
    13095  
    13096 '$lgt_mt_threaded_call_cancel'([]). 
    13097  
    13098 '$lgt_mt_threaded_call_cancel'([Id| Ids]) :- 
     13091'$lgt_mt_threaded_call_cancel'(Ids) :- 
     13092    '$lgt_mt_threaded_call_abort'(Ids), 
     13093    '$lgt_mt_threaded_call_join'(Ids). 
     13094 
     13095 
     13096'$lgt_mt_threaded_call_abort'([]). 
     13097 
     13098'$lgt_mt_threaded_call_abort'([Id| Ids]) :- 
     13099    catch(thread_send_message(Id, '$lgt_status'(_, terminate)), _, true), 
    1309913100    (   catch(thread_peek_message(Id, '$lgt_master'), _, fail) -> 
    13100         catch(thread_send_message(Id, '$lgt_status'(_, terminate)), _, true) 
     13101        true 
    1310113102    ;   catch(thread_signal(Id, '$lgt_mt_thread_abort'(abort)), _, true) 
    1310213103    ), 
    13103     '$lgt_mt_threaded_call_cancel'(Ids). 
    13104  
    13105  
    13106 '$lgt_mt_threaded_call_abort'(Ids, Error) :- 
    13107     '$lgt_mt_threaded_call_cancel'(Ids, Error), 
    13108     '$lgt_mt_threaded_call_clean'(Ids). 
    13109  
    13110  
    13111 '$lgt_mt_threaded_call_cancel'([], _). 
    13112  
    13113 '$lgt_mt_threaded_call_cancel'([Id| Ids], Error) :- 
     13104    '$lgt_mt_threaded_call_abort'(Ids). 
     13105 
     13106 
     13107'$lgt_mt_threaded_call_cancel'(Ids, Error) :- 
     13108    '$lgt_mt_threaded_call_abort'(Ids, Error), 
     13109    '$lgt_mt_threaded_call_join'(Ids). 
     13110 
     13111 
     13112'$lgt_mt_threaded_call_abort'([], _). 
     13113 
     13114'$lgt_mt_threaded_call_abort'([Id| Ids], Error) :- 
     13115    catch(thread_send_message(Id, '$lgt_status'(_, terminate)), _, true), 
    1311413116    (   catch(thread_peek_message(Id, '$lgt_master'), _, fail) -> 
    13115         catch(thread_send_message(Id, '$lgt_status'(_, terminate)), _, true) 
     13117        true 
    1311613118    ;   catch(thread_signal(Id, '$lgt_mt_thread_abort'(Error)), _, true) 
    1311713119    ), 
    13118     '$lgt_mt_threaded_call_cancel'(Ids, Error). 
    13119  
    13120  
    13121 '$lgt_mt_threaded_call_clean'([]). 
    13122  
    13123 '$lgt_mt_threaded_call_clean'([Id| Ids]) :- 
     13120    '$lgt_mt_threaded_call_abort'(Ids, Error). 
     13121 
     13122 
     13123'$lgt_mt_threaded_call_join'([]). 
     13124 
     13125'$lgt_mt_threaded_call_join'([Id| Ids]) :- 
    1312413126    catch(thread_join(Id, _), _, true), 
    13125     '$lgt_mt_threaded_call_clean'(Ids). 
     13127    '$lgt_mt_threaded_call_join'(Ids). 
    1312613128 
    1312713129 
    1312813130'$lgt_mt_thread_abort'(Error) :- 
    13129     findall(Id, (thread_peek_message('$lgt_status'(Id, _)), thread_get_message('$lgt_status'(Id, _))), Ids), 
     13131    findall(Id, (thread_peek_message('$lgt_status'(Id, _)), thread_get_message('$lgt_status'(Id, _)), nonvar(Id)), Ids), 
    1313013132    '$lgt_mt_threaded_call_abort'(Ids, Error), 
    1313113133    mutex_unlock_all,