This class wraps the logical ConditionVariable class to make it an easier to work with interface that is similar to Windows' synchronization events.
Initializes a waitable event. The state parameter initializes the default state of the event. If auto_reset is true, any calls to set() will automatically reset the event back to an unset state.
# File lib/rex/sync/event.rb, line 21 def initialize(state = false, auto_reset = true, param = nil) self.state = state self.auto_reset = auto_reset self.param = param self.mutex = Mutex.new self.cond = ConditionVariable.new end
Resets the signaled state to false.
# File lib/rex/sync/event.rb, line 49 def reset self.param = nil self.state = false end
Sets the event and wakes up anyone who was waiting.
# File lib/rex/sync/event.rb, line 32 def set(param = nil) self.param = param self.mutex.synchronize { # If this event does not automatically reset its state, # set the state to true if (auto_reset == false) self.state = true end self.cond.broadcast } end
Generated with the Darkfish Rdoc Generator 2.