def run_test(self): Msg.info("HiThread(NoLoop): Start Unit Test ... ") myMutex = HiMutex("wrapper_mutex") myThreadProcs = { # start thread sequence (outside thread space) "on-start": self.thread_start, # thread termination handler (inside thread space) "on-execute": self.thread_execute, # thread before finished handler (inside thread space) "on-finished": self.thread_finished, # thread terminated handler (outside thread space) "on-done": self.thread_done, } Msg.info("UnitTest_NoLoopThread >> Creating NoLoop Thread ... ") myThread = thread_factory("NoLoopThread", True, myThreadProcs) Msg.info("UnitTest_NoLoopThread >> Initializing Thread ... ") myThread.start_thread() # wait for thread to terminate myThread.wait_for() Msg.info("UnitTest_NoLoopThread >> Thread Completed ... ")
def with_test(self): # create a mutex my_mutex = HiMutex("with_mutex") Msg.info("Before With: Mutex[%s]" % (my_mutex.name)) with my_mutex: Msg.info("In With: Mutex[%s]" % (my_mutex.name)) Msg.info("After With: Mutex[%s]" % (my_mutex.name))
def with_test( self ): # create a mutex my_mutex = HiMutex( "with_mutex" ) # Msg.info( "Before With: Mutex[%s] is %s" % ( my_mutex.name, SysUtils.ifthen( my_mutex.locked(), "Locked", "Unlocked" ))) Msg.info( "Before With: Mutex[%s]" % ( my_mutex.name )) with my_mutex : Msg.info( "In With: Mutex[%s]" % ( my_mutex.name )) # Msg.info( "In With: Mutex[%s] is %s" % ( my_mutex.name, SysUtils.ifthen( my_mutex.locked(), "Locked", "Unlocked" ))) Msg.info( "After With: Mutex[%s]" % ( my_mutex.name ))
def __init__(self): self.mutex = HiMutex()
def __init__(self): super().__init__() self.mutex = HiMutex()