Permalink
Browse files

gestion des fonctions appelees par receive

  • Loading branch information...
SylvainGBR committed Apr 23, 2012
1 parent feca2a5 commit 6f801379e8cdaf056ccd0f8786e7c2130b140cf4
Showing with 9 additions and 1 deletion.
  1. +9 −1 actorssg.ml
View
@@ -68,14 +68,17 @@ let actors_id = ref 0
let a_mutex = Mutex.create()
let receive_scheduler = Queue.create()
+let rs_mutex = Mutex.create()
let send a m =
match a.actor_location with
| Local lac -> begin Mutex.lock lac.mutex; Queue.add (mutables_copy m) lac.mailbox; Mutex.unlock lac.mutex end
| Remote o -> ();;
let schedule_receive a f =
-Queue.add (a, f) receive_scheduler;;
+ Mutex.lock rs_mutex;
+ Queue.add (a, f) receive_scheduler;
+ Mutex.unlock rs_mutex;;
exception React of (message -> unit);;
@@ -110,6 +113,11 @@ let rec reacting a g =
reacting_aux(); end
| Remote rac -> failwith "You cannot run a remote actor";;
+let recieve_handler =
+ try
+ let (a, f) = Queue.pop receive_scheduler in reacting a f;
+ with Queue.Empty -> ();;
+
(*val create : (actor -> unit) -> actor
val receive : actor -> (message -> unit) -> unit

0 comments on commit 6f80137

Please sign in to comment.