Actor is a worker who processes messages asynchronously.
Inheritance: FanObj, Fanx.Util.ThreadPool.Work
Beispiel #1
0
 public ScheduledWork(Actor a, Future f)
 {
     actor = a; future = f;
 }
Beispiel #2
0
 internal void schedule(Actor a, Duration d, Future f)
 {
     m_scheduler.schedule(d.ticks(), new ScheduledWork(a, f));
 }
Beispiel #3
0
 internal void submit(Actor actor)
 {
     m_threadPool.submit(actor);
 }
Beispiel #4
0
        //////////////////////////////////////////////////////////////////////////
        // When Done
        //////////////////////////////////////////////////////////////////////////
        internal void sendWhenDone(Actor a, Future f)
        {
            // if already done, then set immediate flag
              // otherwise add to our when done list
              bool immediate = false;
              lock (this)
              {
            if (isDone()) immediate = true;
            else
            {
              if (whenDone == null) whenDone = new ArrayList();
              whenDone.Add(new WhenDone(a, f));
            }
              }

              // if immediate we are already done so enqueue immediately
              if (immediate)
              {
            try { a._enqueue(f, false); }
            catch (System.Exception e) { Err.dumpStack(e); }
              }
        }
Beispiel #5
0
 public WhenDone(Actor a, Future f)
 {
     actor = a; future = f;
 }
Beispiel #6
0
 public static void makeCoalescing_(Actor self, ActorPool pool, Func k, Func c)
 {
     makeCoalescing_(self, pool, k, c, null);
 }
Beispiel #7
0
        public static void makeCoalescing_(Actor self, ActorPool pool, Func k, Func c, Func r)
        {
            if (k != null && !k.isImmutable())
            throw NotImmutableErr.make("Coalescing toKey func not immutable: " + k).val;

              if (c != null && !c.isImmutable())
            throw NotImmutableErr.make("Coalescing coalesce func not immutable: " + c).val;

              make_(self, pool, r);
              self.m_queue = new CoalescingQueue(k, c);
        }
Beispiel #8
0
 public static Actor makeCoalescing(ActorPool pool, Func k, Func c, Func r)
 {
     Actor self = new Actor();
       makeCoalescing_(self, pool, k, c, r);
       return self;
 }
Beispiel #9
0
 public static Actor make(ActorPool pool, Func receive)
 {
     Actor self = new Actor();
       make_(self, pool, receive);
       return self;
 }
Beispiel #10
0
 internal Context(Actor actor)
 {
     m_actor = actor;
 }
Beispiel #11
0
        public static void make_(Actor self, ActorPool pool, Func receive)
        {
            // check pool
              if (pool == null)
            throw NullErr.make("pool is null").val;

              // check receive method
              if (receive == null && self.@typeof().qname() == "concurrent::Actor")
            throw ArgErr.make("must supply receive func or subclass Actor").val;
              if (receive != null && !receive.isImmutable())
            throw NotImmutableErr.make("Receive func not immutable: " + receive).val;

              // init
              self.m_pool = pool;
              self.m_receive = receive;
              self.m_queue = new Queue();
        }
Beispiel #12
0
 public static void make_(Actor self, ActorPool pool)
 {
     make_(self, pool, null);
 }