# HG changeset patch # User samer # Date 1329318263 0 # Node ID 71aa901aa435e5aab384c0132a71810a9421eaa7 # Parent 99572a386ccf4ca7b42b290ed403864617702f99 Fixed potential problem if message queue is saturated - would never return timeout due to behaviour of thread_get_message/3 with deadline. diff -r 99572a386ccf -r 71aa901aa435 qutils.pl --- a/qutils.pl Mon Feb 13 16:40:36 2012 +0000 +++ b/qutils.pl Wed Feb 15 15:04:23 2012 +0000 @@ -23,10 +23,14 @@ :- if(current_predicate_option(thread_get_message/3,3,deadline(_))). :- writeln('% compiling get_message_or_timeout/2 using deadline/1 option.'). + get_message_or_timeout(Deadline,Msg) :- - thread_self(Thread), - thread_get_message(Thread,Msg,[deadline(Deadline)]), - debug(qutils,'got message: ~w.',[Msg]). + ( get_time(Now), Now thread_self(Thread), + thread_get_message(Thread,Msg,[deadline(Deadline)]), + debug(qutils,'got message: ~w.',[Msg]) + ; Msg=timeout + ). :- else.