本文整理汇总了Python中monitor.Monitor.unlock方法的典型用法代码示例。如果您正苦于以下问题:Python Monitor.unlock方法的具体用法?Python Monitor.unlock怎么用?Python Monitor.unlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类monitor.Monitor
的用法示例。
在下文中一共展示了Monitor.unlock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Mutex
# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import unlock [as 别名]
# hello.py
# from mpi4py import MPI
# comm = MPI.COMM_WORLD
# rank = comm.Get_rank()
# size = comm.Get_size()
# print "hello world from process ", rank+1, " of ", size
from mutex import Mutex
from conditionvariable import ConditionVariable
from monitor import Monitor
import time
m = Mutex(1)
cv = ConditionVariable(1)
monitor = Monitor() # nowe watki tworzone sa w monitorze
if monitor.communicationManager.processId > 0: # te procesy symuluja czekanie
monitor.lock(m)
monitor.wait(cv, m)
monitor.log("INFO", "Stopped waiting, going to sleep")
time.sleep(1)
monitor.signal(cv)
monitor.unlock(m)
else:
time.sleep(2)
monitor.lock(m)
monitor.signal(cv)
monitor.unlock(m)
monitor.finalize()