| 7338 | | MTCalls = (message_queue_create(Queue), MTGoals, '$lgt_mt_check_threads'(Ids, Queue)), |
| 7339 | | MTExits = ('$lgt_mt_threaded_and_exit'(TGoals, Queue, Results), message_queue_destroy(Queue)). |
| | 7338 | MTCalls = (thread_self(Queue), MTGoals, thread_send_message(Queue, '$lgt_workers'(Ids))), |
| | 7339 | MTExits = ('$lgt_mt_check_threads'(Ids, Queue), '$lgt_mt_threaded_and_exit'(TGoals, Ids, Results)). |
| 7353 | | MTCalls = (message_queue_create(Queue), MTGoals, '$lgt_mt_check_threads'(Ids, Queue)), |
| 7354 | | MTExits = ('$lgt_mt_threaded_or_exit'(TGoals, Queue, Results), message_queue_destroy(Queue)). |
| | 7353 | MTCalls = (thread_self(Queue), MTGoals, thread_send_message(Queue, '$lgt_workers'(Ids))), |
| | 7354 | MTExits = ('$lgt_mt_check_threads'(Ids, Queue), '$lgt_mt_threaded_or_exit'(TGoals, Ids, Results)). |
| 12940 | | ( catch(TGoal, Error, (thread_send_message(Queue, Id::exception(Error)), throw(Error))) -> |
| 12941 | | thread_send_message(Queue, Id::true(TGoal)) |
| 12942 | | ; thread_send_message(Queue, Id::fail) |
| | 12940 | ( catch(TGoal, Error, (thread_send_message(Queue, '$lgt_result'(Id, exception(Error))), throw(Error))) -> |
| | 12941 | thread_send_message(Queue, '$lgt_result'(Id, true(TGoal))) |
| | 12942 | ; thread_send_message(Queue, '$lgt_result'(Id, fail)) |
| 12969 | | '$lgt_mt_threaded_and_exit'(TGoals, Queue, Results) :- |
| 12970 | | thread_get_message(Queue, Id::Result), |
| 12971 | | '$lgt_mt_threaded_and_exit'(Result, Id, TGoals, Queue, Results). |
| 12972 | | |
| 12973 | | |
| 12974 | | '$lgt_mt_threaded_and_exit'(exception(Error), _, _, Queue, Results) :- |
| 12975 | | '$lgt_mt_threaded_call_abort'(Results), |
| 12976 | | message_queue_destroy(Queue), |
| | 12978 | '$lgt_mt_threaded_and_exit'(TGoals, Ids, Results) :- |
| | 12979 | thread_get_message('$lgt_result'(Id, Result)), |
| | 12980 | thread_join(Id, _), |
| | 12981 | '$lgt_mt_threaded_and_exit'(Result, Id, TGoals, Ids, Results). |
| | 12982 | |
| | 12983 | |
| | 12984 | '$lgt_mt_threaded_and_exit'(exception(Error), Id, _, Ids, _) :- |
| | 12985 | '$lgt_mt_threaded_call_abort'(Ids, Id), |
| 12984 | | ; '$lgt_mt_threaded_and_exit'(TGoals, Queue, Results) |
| 12985 | | ). |
| 12986 | | |
| 12987 | | '$lgt_mt_threaded_and_exit'(fail, _, _, Queue, Results) :- |
| 12988 | | '$lgt_mt_threaded_call_abort'(Results), |
| 12989 | | message_queue_destroy(Queue), |
| | 12992 | ; '$lgt_mt_threaded_and_exit'(TGoals, Ids, Results) |
| | 12993 | ). |
| | 12994 | |
| | 12995 | '$lgt_mt_threaded_and_exit'(fail, Id, _, Ids, _) :- |
| | 12996 | '$lgt_mt_threaded_call_abort'(Ids, Id), |
| 13053 | | ( catch(TGoal, Error, (thread_send_message(Queue, Id::exception(Error)), throw(Error))) -> |
| 13054 | | thread_send_message(Queue, Id::true(TGoal)) |
| 13055 | | ; thread_send_message(Queue, Id::fail) |
| 13056 | | ). |
| 13057 | | |
| 13058 | | |
| 13059 | | |
| 13060 | | % '$lgt_mt_threaded_or_exit'(+callable, +message_queue_identifier, +list) |
| | 13050 | ( catch(TGoal, Error, (thread_send_message(Queue, '$lgt_result'(Id, exception(Error))), throw(Error))) -> |
| | 13051 | thread_send_message(Queue, '$lgt_result'(Id, true(TGoal))) |
| | 13052 | ; thread_send_message(Queue, '$lgt_result'(Id, fail)) |
| | 13053 | ). |
| | 13054 | |
| | 13055 | |
| | 13056 | |
| | 13057 | % '$lgt_mt_threaded_or_exit'(+callable, +list(thread_identifier), +list) |
| 13065 | | '$lgt_mt_threaded_or_exit'(TGoals, Queue, Results) :- |
| 13066 | | thread_get_message(Queue, Id::Result), |
| 13067 | | '$lgt_mt_threaded_or_exit'(Result, Id, TGoals, Queue, Results). |
| 13068 | | |
| 13069 | | |
| 13070 | | '$lgt_mt_threaded_or_exit'(exception(Error), _, _, Queue, Results) :- |
| 13071 | | '$lgt_mt_threaded_call_abort'(Results), |
| 13072 | | message_queue_destroy(Queue), |
| | 13062 | '$lgt_mt_threaded_or_exit'(TGoals, Ids, Results) :- |
| | 13063 | thread_get_message('$lgt_result'(Id, Result)), |
| | 13064 | thread_join(Id, _), |
| | 13065 | '$lgt_mt_threaded_or_exit'(Result, Id, TGoals, Ids, Results). |
| | 13066 | |
| | 13067 | |
| | 13068 | '$lgt_mt_threaded_or_exit'(exception(Error), Id, _, Ids, _) :- |
| | 13069 | '$lgt_mt_threaded_call_abort'(Ids, Id), |
| 13075 | | '$lgt_mt_threaded_or_exit'(true(TGoal), Id, TGoals, _, Results) :- |
| 13076 | | '$lgt_mt_threaded_call_abort'(Results), |
| | 13072 | '$lgt_mt_threaded_or_exit'(true(TGoal), Id, TGoals, Ids, Results) :- |
| | 13073 | '$lgt_mt_threaded_call_abort'(Ids, Id), |
| | 13134 | '$lgt_mt_threaded_call_abort'(Ids, Id) :- |
| | 13135 | '$lgt_mt_threaded_call_abort_filter'(Ids, Id, RIds), |
| | 13136 | '$lgt_mt_threaded_call_abort'(RIds). |
| | 13137 | |
| | 13138 | |
| | 13139 | '$lgt_mt_threaded_call_abort_filter'([], _, []). |
| | 13140 | |
| | 13141 | '$lgt_mt_threaded_call_abort_filter'([Id| Ids], Id, Ids) :- |
| | 13142 | !. |
| | 13143 | |
| | 13144 | '$lgt_mt_threaded_call_abort_filter'([RId| Ids], Id, [RId| RIds]) :- |
| | 13145 | '$lgt_mt_threaded_call_abort_filter'(Ids, Id, RIds). |
| | 13146 | |
| | 13147 | |
| 13140 | | '$lgt_mt_threaded_call_abort'([id(Id, _)| Results]) :- |
| 13141 | | catch(thread_signal(Id, (mutex_unlock_all, thread_exit(aborted))), _, true), |
| 13142 | | thread_join(Id, _), |
| 13143 | | '$lgt_mt_threaded_call_abort'(Results). |
| 13144 | | |
| | 13150 | '$lgt_mt_threaded_call_abort'([Id| Ids]) :- |
| | 13151 | ( catch(thread_peek_message(Id, '$lgt_workers'(DIds)), _, fail) -> |
| | 13152 | '$lgt_mt_threaded_call_abort'(DIds) |
| | 13153 | ; true |
| | 13154 | ), |
| | 13155 | catch(thread_signal(Id, thread_exit(aborted)), _, true), |
| | 13156 | catch(thread_join(Id, _), _, true), |
| | 13157 | '$lgt_mt_threaded_call_abort'(Ids). |
| | 13158 | |