当前位置: 首页>>代码示例>>Python>>正文


Python Message.recipientId方法代码示例

本文整理汇总了Python中message.Message.recipientId方法的典型用法代码示例。如果您正苦于以下问题:Python Message.recipientId方法的具体用法?Python Message.recipientId怎么用?Python Message.recipientId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在message.Message的用法示例。


在下文中一共展示了Message.recipientId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: signal

# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import recipientId [as 别名]
 def signal(self, cv):
     self.log("INFO", "("+str(cv.id)+") signaling")
     cv.conditionVariable.acquire()
     sigmes = Message()
     sigmes.referenceId = cv.id
     sigmes.type = "SIGNAL"
     if len(cv.waitingProcesses) >0:
         sigmes.recipientId = cv.waitingProcesses[0]
         self.communicationManager.send_message(sigmes)
     cv.conditionVariable.release()
开发者ID:chris710,项目名称:distributedmonitor,代码行数:12,代码来源:monitor.py

示例2: signal_all

# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import recipientId [as 别名]
 def signal_all(self, cv):
     self.log("INFO", "("+str(cv.id)+") signaling to all")
     cv.conditionVariable.acquire()
     sigmes = Message()
     sigmes.referenceId = cv.id
     sigmes.type = "SIGNAL"
     for proc in cv.waitingProcesses:
         sigmes.recipientId = proc
         self.communicationManager.send_message(sigmes)
     cv.conditionVariable.release()
开发者ID:chris710,项目名称:distributedmonitor,代码行数:12,代码来源:monitor.py

示例3: finalize

# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import recipientId [as 别名]
 def finalize(self):
     q = Message()
     q.type = "QUIT"
     self.communicationManager.send_broadcast(q)
     q.recipientId = self.communicationManager.processId
     self.communicationManager.send_message(q)
     self.log("TRACE", "Waiting for communication thread to join parent.")
     self.communicationThread.join()
     self.communicationManager.barrier()
     self.log("TRACE", "Communication thread joined")
     self.communicationManager.close()
     self.log("TRACE", "MPI finalized")
     self.log("INFO", "Monitor finalized")
开发者ID:chris710,项目名称:distributedmonitor,代码行数:15,代码来源:monitor.py

示例4: unlock

# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import recipientId [as 别名]
 def unlock(self, mux):
     mux.operationMutex.acquire()
     if not mux.locked:
         mux.operationMutex.release()
         return
     retmes = Message()
     retmes.type = "RETURN"
     retmes.referenceId = mux.id
     if len(mux.heldUpRequests) == 0:
         mux.keepAlive = True    # respond with RETURN instead of AGREE (after CS)
     for proc in mux.heldUpRequests:
         retmes.recipientId = proc
         self.communicationManager.send_message(retmes)
     del mux.heldUpRequests[:]
     mux.requesting = False
     mux.locked = False
     self.communicationManager.get_communication_mutex().acquire()  # create new agreeVector
     mux.agreeVector = dict()
     for i in range(0, self.communicationManager.processCount):
         mux.agreeVector[i] = (i == self.communicationManager.processId)     # set every entry to false except requesting process
     self.communicationManager.get_communication_mutex().release()
     mux.operationMutex.release()
     self.log("INFO", "("+str(mux.id)+") unlocked and leaving CS")
开发者ID:chris710,项目名称:distributedmonitor,代码行数:25,代码来源:monitor.py

示例5: communication_loop

# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import recipientId [as 别名]
 def communication_loop(self):
     while True:
         msg = self.communicationManager.recv_message()      # blocking
         if msg is None:
             break
         if msg.type == "REQUEST":    # requesting CS access
             mux = Mutex.get_mutex(msg.referenceId)
             if mux is not None:
                 mux.operationMutex.acquire()
                 if mux.requesting:        # if REQUEST has earlier time then send AGREE
                     if mux.requestClock < msg.clock:  # add to queue
                         mux.heldUpRequests.append(msg.senderId)
                     else:
                         if mux.requestClock == msg.clock and self.communicationManager.processId < msg.senderId:
                             mux.heldUpRequests.append(msg.senderId)
                         else:
                             agreeReply = Message()
                             agreeReply.referenceId = msg.referenceId
                             agreeReply.recipientId = msg.senderId
                             if mux.keepAlive:
                                 agreeReply.type = "RETURN"
                                 if mux.get_data_size() > 0:
                                     agreeReply.hasData = True
                             else:
                                 agreeReply.type = "AGREE"
                             self.communicationManager.send_message(agreeReply)
                 else:
                     if not mux.locked:
                         agreeReply = Message()
                         agreeReply.referenceId = msg.referenceId
                         agreeReply.recipientId = msg.senderId
                         if mux.keepAlive:
                             agreeReply.type = "RETURN"
                         else:
                             agreeReply.type = "AGREE"
                         self.communicationManager.send_message(agreeReply)
                     else:
                         mux.heldUpRequests.append(msg.senderId)
                 mux.operationMutex.release()
         elif msg.type == "RETURN":  # when leaving CS
             mux = Mutex.get_mutex(msg.referenceId)
             if mux is not None:
                 mux.operationMutex.acquire()
                 mux.agreeVector[msg.senderId] = True
                 mux.keepAlive = False
                 if mux.previousReturn is not None:
                     del mux.previousReturn
                 mux.previousReturn = msg
                 mux.operationMutex.release()
                 self.enter_critical_section(mux)
         elif msg.type == "AGREE":           # process agrees to request for CS
             mux = Mutex.get_mutex(msg.referenceId)
             mux.operationMutex.acquire()
             if mux is not None and mux.requesting:
                 mux.agreeVector[msg.senderId] = True       # sender agreed
                 mux.keepAlive = False                      # sb tries to acquire CS
                 mux.operationMutex.release()
                 self.enter_critical_section(mux)       # try to enter CS
             else:
                 mux.operationMutex.release()
         elif msg.type == "WAIT":        # process is waiting
             cv = ConditionVariable.get_condition_variable(msg.referenceId)
             cv.conditionVariable.acquire()
             cv.waitingProcesses.append(msg.senderId)
             cv.conditionVariable.release()
         elif msg.type == "WAIT_RETURN":     # process is not waiting anymore
             cv = ConditionVariable.get_condition_variable(msg.referenceId)
             cv.conditionVariable.acquire()
             cv.waitingProcesses.remove(msg.senderId)
             cv.conditionVariable.release()
         elif msg.type == "SIGNAL":          # wake up waiting process
             cv = ConditionVariable.get_condition_variable(msg.referenceId)
             cv.conditionVariable.acquire()
             cv.waiting = False
             cv.conditionVariable.notify()
             cv.conditionVariable.release()
         elif msg.type == "QUIT":            # process will no longer communicate
             self.quitMessages += 1
             if self.quitMessages == self.communicationManager.processCount:
                 self.communicationManager.initialized = False
                 return
开发者ID:chris710,项目名称:distributedmonitor,代码行数:83,代码来源:monitor.py


注:本文中的message.Message.recipientId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。