Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
_Condition Class Reference
Inheritance diagram for _Condition:
_Verbose

Public Member Functions

def __init__
 
def __repr__
 
def wait
 
def notify
 
def notifyAll
 
- Public Member Functions inherited from _Verbose
def __init__
 
def __init__
 

Data Fields

 acquire
 
 release
 

Detailed Description

Definition at line 138 of file threading.py.

Constructor & Destructor Documentation

def __init__ (   self,
  lock = None,
  verbose = None 
)

Definition at line 140 of file threading.py.

References _Condition.__lock, and threading.RLock().

141  def __init__(self, lock=None, verbose=None):
142  _Verbose.__init__(self, verbose)
143  if lock is None:
144  lock = RLock()
145  self.__lock = lock
146  # Export the lock's acquire() and release() methods
147  self.acquire = lock.acquire
148  self.release = lock.release
149  # If the lock defines _release_save() and/or _acquire_restore(),
150  # these override the default implementations (which just call
151  # release() and acquire() on the lock). Ditto for _is_owned().
152  try:
153  self._release_save = lock._release_save
154  except AttributeError:
155  pass
156  try:
157  self._acquire_restore = lock._acquire_restore
158  except AttributeError:
159  pass
160  try:
161  self._is_owned = lock._is_owned
162  except AttributeError:
163  pass
164  self.__waiters = []

Member Function Documentation

def __repr__ (   self)

Definition at line 165 of file threading.py.

References _Condition.__lock, and _Condition.__waiters.

166  def __repr__(self):
167  return "<Condition(%s, %d)>" % (self.__lock, len(self.__waiters))
def notify (   self,
  n = 1 
)

Definition at line 223 of file threading.py.

References _Condition.__waiters, _Condition._is_owned, _Verbose._note(), and threading.currentThread().

224  def notify(self, n=1):
225  me = currentThread()
226  assert self._is_owned(), "notify() of un-acquire()d lock"
227  __waiters = self.__waiters
228  waiters = __waiters[:n]
229  if not waiters:
230  if __debug__:
231  self._note("%s.notify(): no waiters", self)
232  return
233  self._note("%s.notify(): notifying %d waiter%s", self, n,
234  n!=1 and "s" or "")
235  for waiter in waiters:
236  waiter.release()
237  try:
238  __waiters.remove(waiter)
239  except ValueError:
240  pass
def notifyAll (   self)

Definition at line 241 of file threading.py.

References _Condition.__waiters, and _Condition.notify().

242  def notifyAll(self):
243  self.notify(len(self.__waiters))
244 
def wait (   self,
  timeout = None 
)

Definition at line 181 of file threading.py.

References _Condition._acquire_restore, threading._allocate_lock, _Condition._is_owned, _Verbose._note(), _Condition._release_save, threading._sleep, threading._time, threading.currentThread(), and sre_parse.min.

182  def wait(self, timeout=None):
183  me = currentThread()
184  assert self._is_owned(), "wait() of un-acquire()d lock"
185  waiter = _allocate_lock()
186  waiter.acquire()
187  self.__waiters.append(waiter)
188  saved_state = self._release_save()
189  try: # restore state no matter what (e.g., KeyboardInterrupt)
190  if timeout is None:
191  waiter.acquire()
192  if __debug__:
193  self._note("%s.wait(): got it", self)
194  else:
195  # Balancing act: We can't afford a pure busy loop, so we
196  # have to sleep; but if we sleep the whole timeout time,
197  # we'll be unresponsive. The scheme here sleeps very
198  # little at first, longer as time goes on, but never longer
199  # than 20 times per second (or the timeout time remaining).
200  endtime = _time() + timeout
201  delay = 0.0005 # 500 us -> initial delay of 1 ms
202  while 1:
203  gotit = waiter.acquire(0)
204  if gotit:
205  break
206  remaining = endtime - _time()
207  if remaining <= 0:
208  break
209  delay = min(delay * 2, remaining, .05)
210  _sleep(delay)
211  if not gotit:
212  if __debug__:
213  self._note("%s.wait(%s): timed out", self, timeout)
214  try:
215  self.__waiters.remove(waiter)
216  except ValueError:
217  pass
218  else:
219  if __debug__:
220  self._note("%s.wait(%s): got it", self, timeout)
221  finally:
222  self._acquire_restore(saved_state)

Field Documentation

acquire

Definition at line 146 of file threading.py.

release

Definition at line 147 of file threading.py.


The documentation for this class was generated from the following file: