Show
Ignore:
Timestamp:
08/26/08 12:51:33 (5 months ago)
Author:
pmoura
Message:

Small performance improvement to the threaded/1 built-in multi-threading predicate.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/compiler/logtalk.pl

    r4447 r4450  
    1335113351'$lgt_mt_threaded_call'(Goal, Queue) :- 
    1335213352    thread_self(Id), 
    13353     call(Goal), 
    13354     thread_send_message(Queue, '$lgt_result'(Id, true(Goal))). 
     13353    (   Goal -> 
     13354        thread_send_message(Queue, '$lgt_result'(Id, true(Goal))) 
     13355    ;   thread_send_message(Queue, '$lgt_result'(Id, false)) 
     13356    ). 
    1335513357 
    1335613358 
     
    1336413366 
    1336513367'$lgt_mt_threaded_exit_handler'(Id, Queue) :- 
    13366     thread_property(Id, status(Status)), 
    13367     (   Status == true -> 
    13368         true 
    13369     ;   catch(thread_send_message(Queue, '$lgt_result'(Id, Status)), _, thread_detach(Id)) 
    13370     ). 
    13371  
    13372  
    13373  
    13374 % '$lgt_mt_threaded_and_exit'(+callable, +list(thread_identifier), +list) 
     13368    thread_property(Id, status(exception(Error))), 
     13369    catch(thread_send_message(Queue, '$lgt_result'(Id, exception(Error))), _, thread_detach(Id)). 
     13370 
     13371 
     13372 
     13373% '$lgt_mt_threaded_and_exit'(+list(thread_identifier), +list) 
    1337513374% 
    1337613375% retrieves the result of proving a conjunction of goals using a threaded/1 predicate call 
     
    1344213441 
    1344313442 
    13444 % '$lgt_mt_threaded_or_exit'(+callable, +list(thread_identifier), +list) 
     13443% '$lgt_mt_threaded_or_exit'(+list(thread_identifier), +list) 
    1344513444% 
    1344613445% retrieves the result of proving a disjunction of goals using a threaded/1 predicate 
     
    1354813547 
    1354913548'$lgt_mt_threaded_call_abort'([Id| Ids]) :- 
    13550     catch('$lgt_mt_abort_thread'(Id), _, true), 
     13549    catch(thread_signal(Id, '$lgt_mt_abort_thread'(Id)), _, true), 
    1355113550    '$lgt_mt_threaded_call_abort'(Ids). 
    1355213551 
    1355313552 
    1355413553'$lgt_mt_abort_thread'(Id) :- 
    13555     (   thread_peek_message(Id, '$lgt_master') -> 
     13554    (   thread_peek_message('$lgt_master') -> 
    1355613555        thread_send_message(Id, '$lgt_result'(_, terminate)) 
    13557     ;   thread_signal(Id, throw('$lgt_terminated')) 
     13556    ;   throw('$lgt_terminated') 
    1355813557    ). 
    1355913558