Skip to content
Browse files

simplification de la generation des actor_id

  • Loading branch information...
1 parent 3e85ba6 commit 8a6b732cd7037526efdc514cd208ff833ed6a603 @SylvainGBR committed Apr 23, 2012
Showing with 9 additions and 2 deletions.
  1. +9 −2 actorssg.ml
View
11 actorssg.ml
@@ -99,10 +99,17 @@ let execute a f =
try f()
with React g -> schedule_receive a g;;
-let create f =
+let new_aid() =
+ Mutex.lock a_mutex;
incr actors_id;
+ let i = !actors_id in
+ begin Mutex.unlock a_mutex;
+ i end;;
+
+let create f =
+ let i = new_aid() in
let l_act = {mailbox = Queue.create() ; mutex = Mutex.create()} in
- let new_actor = {actor_id = !actors_id; actor_location = Local l_act} in
+ let new_actor = {actor_id = i; actor_location = Local l_act} in
let new_act_env = {actor = new_actor; sleeping = Queue.create()} in
Hashtbl.add actors new_actor.actor_id new_act_env;
execute new_actor f;

0 comments on commit 8a6b732

Please sign in to comment.
Something went wrong with that request. Please try again.