- Timestamp:
- 06/09/08 09:01:54 (4 months ago)
- Location:
- trunk
- Files:
-
- 2 modified
-
compiler/logtalk.pl (modified) (12 diffs)
-
RELEASE_NOTES.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/compiler/logtalk.pl
r4305 r4306 13203 13203 13204 13204 13205 '$lgt_mt_threaded_and_exit'(terminate, _, Ids, _) :-13206 '$lgt_mt_threaded_call_cancel'(Ids ),13205 '$lgt_mt_threaded_and_exit'(terminate, _, Ids, Results) :- 13206 '$lgt_mt_threaded_call_cancel'(Ids, Results), 13207 13207 throw('$lgt_terminated'). 13208 13208 13209 % messages can arrive out-of-order; if that's the case we need to keep looking for the 13210 % thread result that lead to the termination of the other threads 13211 13209 13212 '$lgt_mt_threaded_and_exit'(exception(Error), Id, Ids, Results) :- 13213 '$lgt_mt_threaded_record_result'(Results, Id, exception(Error)), 13210 13214 ( Error == '$lgt_terminated' -> 13211 13215 '$lgt_mt_threaded_and_exit'(Ids, Results) 13212 ; '$lgt_mt_threaded_call_cancel'(Ids, Id),13216 ; '$lgt_mt_threaded_call_cancel'(Ids, Results, Id), 13213 13217 throw(Error) 13214 13218 ). … … 13218 13222 '$lgt_mt_threaded_and_add_result'(Results, Id, TGoal, Continue), 13219 13223 ( Continue == false -> 13220 '$lgt_mt_threaded_call_join'(Ids )13224 '$lgt_mt_threaded_call_join'(Ids, Results) 13221 13225 ; '$lgt_mt_threaded_and_exit'(Ids, Results) 13222 13226 ). 13223 13227 13224 '$lgt_mt_threaded_and_exit'(false, Id, Ids, _) :- 13225 '$lgt_mt_threaded_call_cancel'(Ids, Id), 13228 '$lgt_mt_threaded_and_exit'(false, Id, Ids, Results) :- 13229 '$lgt_mt_threaded_record_result'(Results, Id, false), 13230 '$lgt_mt_threaded_call_cancel'(Ids, Results, Id), 13226 13231 fail. 13227 13232 … … 13242 13247 ( var(Done) -> 13243 13248 Continue = true % we found a thread whose result is still pending 13244 ; true % otherwise continue examining the re amaining thread results13249 ; true % otherwise continue examining the remaining thread results 13245 13250 ), 13246 13251 '$lgt_mt_threaded_and_add_result'(Results, Id, TGoal, Continue). … … 13269 13274 13270 13275 13271 '$lgt_mt_threaded_or_exit'(terminate, _, Ids, _) :-13272 '$lgt_mt_threaded_call_cancel'(Ids ),13276 '$lgt_mt_threaded_or_exit'(terminate, _, Ids, Results) :- 13277 '$lgt_mt_threaded_call_cancel'(Ids, Results), 13273 13278 throw('$lgt_terminated'). 13274 13279 13280 % messages can arrive out-of-order; if that's the case we need to keep looking for the 13281 % thread result that lead to the termination of the other threads 13282 13275 13283 '$lgt_mt_threaded_or_exit'(exception(Error), Id, Ids, Results) :- 13284 '$lgt_mt_threaded_record_result'(Results, Id, exception(Error)), 13276 13285 ( Error == '$lgt_terminated' -> 13277 13286 '$lgt_mt_threaded_or_exit'(Ids, Results) 13278 ; '$lgt_mt_threaded_call_cancel'(Ids, Id),13287 ; '$lgt_mt_threaded_call_cancel'(Ids, Results, Id), 13279 13288 throw(Error) 13280 13289 ). … … 13282 13291 '$lgt_mt_threaded_or_exit'(true, Id, Ids, Results) :- 13283 13292 thread_get_message('$lgt_result'(Id, TGoal)), 13284 '$lgt_mt_threaded_call_cancel'(Ids, Id), 13293 '$lgt_mt_threaded_record_result'(Results, Id, true), 13294 '$lgt_mt_threaded_call_cancel'(Ids, Results, Id), 13285 13295 '$lgt_mt_threaded_or_exit_unify'(Results, Id, TGoal). 13286 13296 … … 13290 13300 '$lgt_mt_threaded_or_exit'(Ids, Results) 13291 13301 ; % all goals failed 13292 '$lgt_mt_threaded_call_join'(Ids ),13302 '$lgt_mt_threaded_call_join'(Ids, Results), 13293 13303 fail 13294 13304 ). … … 13298 13308 % unifies the successful thread goal result with the original call 13299 13309 13300 '$lgt_mt_threaded_or_exit_unify'([id(Id, TGoal, _)| _], Id, TGoal) :-13310 '$lgt_mt_threaded_or_exit_unify'([id(Id, TGoal, true)| _], Id, TGoal) :- 13301 13311 !. 13302 13312 … … 13306 13316 13307 13317 13318 % '$lgt_mt_threaded_record_result'(+list, +thread_identifier, +callable) 13319 % 13320 % records a thread goal result: 13321 13322 '$lgt_mt_threaded_record_result'([id(Id, _, Result)| _], Id, Result) :- 13323 !. 13324 13325 '$lgt_mt_threaded_record_result'([_| Results], Id, Result) :- 13326 '$lgt_mt_threaded_record_result'(Results, Id, Result). 13327 13328 13329 13308 13330 % '$lgt_mt_threaded_or_record_failure'(+list, +thread_identifier, -atom) 13309 13331 % 13310 % records a goal failure and checks if all othergoals have failed:13332 % records a thread goal failure and checks if all other thread goals have failed: 13311 13333 13312 13334 '$lgt_mt_threaded_or_record_failure'([id(Id, _, fail)| Results], Id, Continue) :- … … 13320 13342 ( var(Done) -> 13321 13343 Continue = true % we found a thread whose result is still pending 13322 ; true % otherwise continue examining the re amaining thread results13344 ; true % otherwise continue examining the remaining thread results 13323 13345 ), 13324 13346 '$lgt_mt_threaded_or_record_failure'(Results, Id, Continue). … … 13337 13359 13338 13360 13339 % '$lgt_mt_threaded_call_cancel'(+list(thread_identifier), thread_identifier)13361 % '$lgt_mt_threaded_call_cancel'(+list(thread_identifier), +list, +thread_identifier) 13340 13362 % 13341 13363 % aborts a threaded call by aborting and joining all individual threads; 13342 13364 % we must use catch/3 as some threads may already be terminated 13343 13365 13344 '$lgt_mt_threaded_call_cancel'(Ids, ProtectedId) :-13366 '$lgt_mt_threaded_call_cancel'(Ids, Results, ProtectedId) :- 13345 13367 '$lgt_mt_threaded_call_abort'(Ids, ProtectedId), 13346 '$lgt_mt_threaded_call_join'(Ids ).13368 '$lgt_mt_threaded_call_join'(Ids, Results). 13347 13369 13348 13370 … … 13361 13383 13362 13384 13363 '$lgt_mt_threaded_call_cancel'(Ids ) :-13385 '$lgt_mt_threaded_call_cancel'(Ids, Results) :- 13364 13386 '$lgt_mt_threaded_call_abort'(Ids), 13365 '$lgt_mt_threaded_call_join'(Ids ).13387 '$lgt_mt_threaded_call_join'(Ids, Results). 13366 13388 13367 13389 … … 13376 13398 13377 13399 13378 '$lgt_mt_threaded_call_join'([]). 13379 13380 '$lgt_mt_threaded_call_join'([Id| Ids]) :- 13400 '$lgt_mt_threaded_call_join'([], []). 13401 13402 '$lgt_mt_threaded_call_join'([Id| Ids], [id(Id, _, Result)| Results]) :- 13403 ( var(Result) -> 13404 thread_get_message('$lgt_status'(Id, Result)), 13405 ( Result == true -> 13406 thread_get_message('$lgt_result'(Id, _)) 13407 ; true 13408 ) 13409 ; true 13410 ), 13381 13411 catch(thread_join(Id, _), _, true), 13382 '$lgt_mt_threaded_call_join'(Ids ).13412 '$lgt_mt_threaded_call_join'(Ids, Results). 13383 13413 13384 13414 -
trunk/RELEASE_NOTES.txt
r4305 r4306 23 23 exception terms. Thanks to Joerg Schuster for the bug report. 24 24 25 Corrected a bug in the implementation of the built-in meta-predicate 26 threaded/1 when canceling individual threads when one of them terminates 27 with an exception or a failure. 25 Corrected two bugs in the implementation of the built-in meta-predicate 26 threaded/1 when canceling individual threads. The first bug resulted from 27 out-of-order thread status messages. The second bug resultd from a leak 28 of thread results between calls to the threaded/1 predicate. 28 29 29 30 Added a new default compiler option, multifile_directive, to all config
