예제 #1
0
    def __init__(self, name, min_task_id, max_task_id):
        """
        Method:    __init__
        Description: 构造函数
        Parameter: 
            name: worker的名称
            min_task_id: 
            max_task_id: 
        Return: 
        Others: 
             一个app中的worker名称不能冲突
             每个app中的所有worker,都需要有自己的taskid的区段,且不能互相重合
             min_task_id不能小于 1
             max_task_id不能大于0xFFFFFFFE
             taskid是 unsigned int类型

             注: RpcWorker已经固定使用0xFFFF0000~0xFFFFFFFE
                所以其他worker只能使用1~0xFFFEFFFF
                
        """
        
        Worker.__init__(self, name)

        self.__min_task_id = min(min(0xFFFFFFFF, max(1, min_task_id)), min(0xFFFFFFFF, max(1, max_task_id)))
        self.__max_task_id = max(min(0xFFFFFFFF, max(1, min_task_id)), min(0xFFFFFFFF, max(1, max_task_id)))
        self.__current_task_id = self.__min_task_id

        self.__ack_handlers = {}

        self.set_dispatch_handler_strategy(CmdCodeDispatchHandlerStrategy())
        self.set_busy_strategy(NoBusyStrategy())
예제 #2
0
    def __init__(self):
        """
        Method:    __init__
        Description: 构造函数
        Parameter: 无
        Return: 
        Others: 
            __mutex: 锁
            __peer_sockets:所有与其他app发送消息的socket
        """

        Worker.__init__(self, IpcSendWorker.worker_name)

        self.__mutex = threading.RLock()
        
        self.__peer_sockets = {}  # pid: (endpoint, socket)
        self.__context    = eipc.Context.instance()
예제 #3
0
    def __init__(self):
        """
        Method:    __init__
        Description: 构造函数
        Parameter: 
            endpoint: 本app绑定的endpoint,其他app通过连接到该endpoint后方可发送消息过来
        Return: 
            __endpoint: 本app绑定的endpoint
            __socket: 处于监听状态的socket
            __context:eipc的Context对象
            __poll: eipc的Poller对象
        Others: 
        """

        Worker.__init__(self, IpcRecvWorker.worker_name)
        self.__endpoint = ""
        self.__socket     = None
        self.__context    = eipc.Context.instance()
        self.__poll = eipc.Poller()