# HG changeset patch # User samer # Date 1329138266 0 # Node ID ef5802225f9912d14989dcc4677ce95d894cc9e3 # Parent af1ebea468b5ac6c0b32e6429ce16892075a8c00 get_message_or_timeout now uses deadline/1 option of thread_get_message if available. diff -r af1ebea468b5 -r ef5802225f99 qutils.pl --- a/qutils.pl Thu Feb 09 11:13:32 2012 +0000 +++ b/qutils.pl Mon Feb 13 13:04:26 2012 +0000 @@ -22,6 +22,17 @@ :- if(current_predicate(thread_get_message/3)). +:- 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]). + +:- else. + +:- writeln('% compiling get_message_or_timeout/2 using timeout/1 option.'). get_message_or_timeout(Deadline,Msg) :- get_time(Now), ( Now>=Deadline @@ -32,9 +43,11 @@ thread_get_message(Thread,Msg,[timeout(Timeout)]), debug(qutils,'got message: ~w.',[Msg]) ). +:- endif. :- else. +:- writeln('% compiling get_message_or_timeout/2 using alarm and message send.'). get_message_or_timeout(Deadline,Msg) :- get_time(Now), ( Now>=Deadline