Mercurial > hg > reactive
changeset 8:71aa901aa435
Fixed potential problem if message queue is saturated - would never
return timeout due to behaviour of thread_get_message/3 with deadline.
author | samer |
---|---|
date | Wed, 15 Feb 2012 15:04:23 +0000 |
parents | 99572a386ccf |
children | 8300e1fb8952 |
files | qutils.pl |
diffstat | 1 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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<Deadline + -> thread_self(Thread), + thread_get_message(Thread,Msg,[deadline(Deadline)]), + debug(qutils,'got message: ~w.',[Msg]) + ; Msg=timeout + ). :- else.