| 7627 | | '$lgt_tr_threaded_individual_goal'(TGoal, Queue, thread_create('$lgt_mt_threaded_call'(TGoal, Queue), Id, [at_exit('$lgt_mt_threaded_exit_handler'(Id, Queue))]), Id, id(Id, TGoal, _)). |
| | 7627 | '$lgt_tr_threaded_individual_goal'(TGoal, Queue, thread_create('$lgt_mt_threaded_call'(TGoal, Queue), Id, [at_exit('$lgt_mt_exit_handler'(Id, Queue))]), Id, id(Id, TGoal, _)). |
| | 13154 | % '$lgt_mt_dispatch_goal'(+atom, +object_identifier, +object_identifier, @callable, @nonvar) |
| | 13155 | % |
| | 13156 | % creates a thread for proving a goal (this predicate is called from within categories) |
| | 13157 | |
| | 13158 | '$lgt_mt_dispatch_goal'(Option, Goal, This, Self, Tag) :- |
| | 13159 | '$lgt_current_object_'(This, Queue, _, _, _, _, _, _, _, _, _, _, _) -> |
| | 13160 | '$lgt_mt_dispatch_goal'(Option, Queue, Goal, This, Self, Tag). |
| | 13161 | |
| | 13162 | |
| | 13163 | |
| | 13164 | % '$lgt_mt_dispatch_goal'(+atom, +message_queue, @callable, +object_identifier, +object_identifier, @nonvar) |
| | 13165 | % |
| | 13166 | % creates a thread for proving a goal |
| | 13167 | |
| | 13168 | '$lgt_mt_dispatch_goal'(ignore, _, Goal, _, _, _) :- |
| | 13169 | thread_create(catch(Goal, _, true), _, [detached(true)]). |
| | 13170 | |
| | 13171 | '$lgt_mt_dispatch_goal'(call, Queue, Goal, This, Self, Tag) :- |
| | 13172 | thread_create('$lgt_mt_non_det_goal'(Queue, Goal, This, Self, Tag), Id, []), |
| | 13173 | % wait until the thread created for proving the goal is ready before proceeding: |
| | 13174 | thread_get_message(Queue, '$lgt_non_det_ready'(Id)). |
| | 13175 | |
| | 13176 | '$lgt_mt_dispatch_goal'(once, Queue, Goal, This, Self, Tag) :- |
| | 13177 | thread_create('$lgt_mt_det_goal'(Queue, Goal, This, Self, Tag), Id, []), |
| | 13178 | % wait until the thread created for proving the goal is ready before proceeding: |
| | 13179 | thread_get_message(Queue, '$lgt_det_ready'(Id)). |
| | 13180 | |
| | 13181 | |
| | 13182 | |
| 13158 | | '$lgt_mt_det_goal'(Return, Goal, This, Self, Tag) :- |
| 13159 | | thread_self(DetId), |
| 13160 | | thread_send_message(Return, '$lgt_thread_id'(once, Goal, This, Self, Tag, DetId)), |
| | 13187 | '$lgt_mt_det_goal'(Queue, Goal, This, Self, Tag) :- |
| | 13188 | thread_self(Id), |
| | 13189 | thread_send_message(Queue, '$lgt_thread_id'(once, Goal, This, Self, Tag, Id)), |
| 13162 | | thread_send_message(Return, '$lgt_det_ready'(Goal, This, Self, Tag)), |
| 13163 | | ( catch(Goal, Error, (thread_send_message(Return, '$lgt_reply'(Goal, This, Self, Tag, Error, DetId)), Flag = error)) -> |
| 13164 | | ( var(Flag) -> |
| 13165 | | thread_send_message(Return, '$lgt_reply'(Goal, This, Self, Tag, success, DetId)) |
| | 13191 | thread_send_message(Queue, '$lgt_det_ready'(Id)), |
| | 13192 | ( catch(Goal, Error, thread_send_message(Queue, '$lgt_reply'(Goal, This, Self, Tag, Error, Id))) -> |
| | 13193 | ( var(Error) -> |
| | 13194 | thread_send_message(Queue, '$lgt_reply'(Goal, This, Self, Tag, success, Id)) |
| 13178 | | '$lgt_mt_non_det_goal'(Return, Goal, This, Self, Tag) :- |
| 13179 | | thread_self(NonDetId), |
| 13180 | | thread_send_message(Return, '$lgt_thread_id'(call, Goal, This, Self, Tag, NonDetId)), |
| | 13207 | '$lgt_mt_non_det_goal'(Queue, Goal, This, Self, Tag) :- |
| | 13208 | thread_self(Id), |
| | 13209 | thread_send_message(Queue, '$lgt_thread_id'(call, Goal, This, Self, Tag, Id)), |
| 13182 | | thread_send_message(Return, '$lgt_non_det_ready'(Goal, This, Self, Tag)), |
| 13183 | | ( catch(Goal, Error, (thread_send_message(Return, '$lgt_reply'(Goal, This, Self, Tag, Error, NonDetId)), Flag = error)), |
| 13184 | | ( var(Flag) -> |
| 13185 | | thread_send_message(Return, '$lgt_reply'(Goal, This, Self, Tag, success, NonDetId)), |
| | 13211 | thread_send_message(Queue, '$lgt_non_det_ready'(Id)), |
| | 13212 | ( catch(Goal, Error, thread_send_message(Queue, '$lgt_reply'(Goal, This, Self, Tag, Error, Id))), |
| | 13213 | ( var(Error) -> |
| | 13214 | thread_send_message(Queue, '$lgt_reply'(Goal, This, Self, Tag, success, Id)), |
| 13194 | | ; thread_send_message(Return, '$lgt_reply'(Goal, This, Self, Tag, failure, NonDetId)) |
| 13195 | | ). |
| 13196 | | |
| 13197 | | |
| 13198 | | |
| 13199 | | % '$lgt_mt_dispatch_goal'(+atom, +object_identifier, +object_identifier, @callable, @tag) |
| 13200 | | % |
| 13201 | | % creates a thread for proving a goal (this predicate is called from within categories) |
| 13202 | | |
| 13203 | | '$lgt_mt_dispatch_goal'(Option, Goal, This, Self, Tag) :- |
| 13204 | | '$lgt_current_object_'(This, Queue, _, _, _, _, _, _, _, _, _, _, _) -> |
| 13205 | | '$lgt_mt_dispatch_goal'(Option, Queue, Goal, This, Self, Tag). |
| 13206 | | |
| 13207 | | |
| 13208 | | |
| 13209 | | % '$lgt_mt_dispatch_goal'(+atom, +message_queue, @callable, +object_identifier, +object_identifier, @tag) |
| 13210 | | % |
| 13211 | | % creates a thread for proving a goal |
| 13212 | | |
| 13213 | | '$lgt_mt_dispatch_goal'(ignore, _, Goal, _, _, _) :- |
| 13214 | | thread_create(catch(Goal, _, true), _, [detached(true)]). |
| 13215 | | |
| 13216 | | '$lgt_mt_dispatch_goal'(call, Queue, Goal, This, Self, Tag) :- |
| 13217 | | thread_create('$lgt_mt_non_det_goal'(Queue, Goal, This, Self, Tag), _, [detached(false)]), |
| 13218 | | % wait until the thread created for proving the goal is ready before proceeding: |
| 13219 | | thread_get_message(Queue, '$lgt_non_det_ready'(Goal, This, Self, Tag)). |
| 13220 | | |
| 13221 | | '$lgt_mt_dispatch_goal'(once, Queue, Goal, This, Self, Tag) :- |
| 13222 | | thread_create('$lgt_mt_det_goal'(Queue, Goal, This, Self, Tag), _, [detached(false)]), |
| 13223 | | % wait until the thread created for proving the goal is ready before proceeding: |
| 13224 | | thread_get_message(Queue, '$lgt_det_ready'(Goal, This, Self, Tag)). |
| | 13223 | ; % no (more) solutions |
| | 13224 | thread_send_message(Queue, '$lgt_reply'(Goal, This, Self, Tag, failure, Id)) |
| | 13225 | ). |