Ejemplo n.º 1
0
            internal static void Dispatch(NonBlockingConnection conn, ActionBean bean, Protocol protocol)
            {
                int  priority = 1;
                Task task     = new Task(priority, bean, conn, protocol);

                ThreadPool.AddTask(task);
            }
Ejemplo n.º 2
0
            private Task(int priority, ActionBean bean, NonBlockingConnection conn, Protocol protocol) : base(priority)
            {
                this.bean     = bean;
                this.conn     = conn;
                this.protocol = protocol;

                time_start = WatchDog.GetTime();
            }
Ejemplo n.º 3
0
        public void DispatchAct(Protocol protocol, NonBlockingConnection conn)
        {
            ActionBean bean = null;

            if (actions.TryGetValue(protocol.act, out bean))
            {
                // 分配一个线程执行
                Task.Dispatch(conn, bean, protocol);
            }
        }
Ejemplo n.º 4
0
        private Dispatch()
        {
            // 加载所有的Action
            try{
                AllActClass aac = new AllActClass();
                foreach (IAction act in aac.dic.Values)
                {
                    MethodInfo[] ms = act.GetType().GetMethods();
                    foreach (MethodInfo m in ms)
                    {
                        ActionBean bean = ActionBean.newInstance(act, m);
                        if ((bean != null) && (!actions.ContainsKey(bean.actId)))
                        {
                            actions.Add(bean.actId, bean);
                        }
                    }
                }
            } catch (Exception e) {
                ConsoleEx.DebugLog(e.ToString());
            }

            // 初始化线程池
            ThreadPool.LoadConfig();
        }
Ejemplo n.º 5
0
 private Task(int priority, ActionBean bean, NonBlockingConnection conn, Protocol protocol) : base(priority)
 {
     this.bean     = bean;
     this.conn     = conn;
     this.protocol = protocol;
 }