Actor is a worker who processes messages asynchronously.
Наследование: FanObj, Fanx.Util.ThreadPool.Work
Пример #1
0
 public ScheduledWork(Actor a, Future f)
 {
     actor = a; future = f;
 }
Пример #2
0
 internal void schedule(Actor a, Duration d, Future f)
 {
     m_scheduler.schedule(d.ticks(), new ScheduledWork(a, f));
 }
Пример #3
0
 internal void submit(Actor actor)
 {
     m_threadPool.submit(actor);
 }
Пример #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); }
              }
        }
Пример #5
0
 public WhenDone(Actor a, Future f)
 {
     actor = a; future = f;
 }
Пример #6
0
 public static void makeCoalescing_(Actor self, ActorPool pool, Func k, Func c)
 {
     makeCoalescing_(self, pool, k, c, null);
 }
Пример #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);
        }
Пример #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;
 }
Пример #9
0
 public static Actor make(ActorPool pool, Func receive)
 {
     Actor self = new Actor();
       make_(self, pool, receive);
       return self;
 }
Пример #10
0
 internal Context(Actor actor)
 {
     m_actor = actor;
 }
Пример #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();
        }
Пример #12
0
 public static void make_(Actor self, ActorPool pool)
 {
     make_(self, pool, null);
 }