changeset 6:ef5802225f99

get_message_or_timeout now uses deadline/1 option of thread_get_message if available.
author samer
date Mon, 13 Feb 2012 13:04:26 +0000
parents af1ebea468b5
children 99572a386ccf
files qutils.pl
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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