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

Public Member Functions

def __init__
 
def acquire
 
def release
 
- Public Member Functions inherited from _Verbose
def __init__
 
def __init__
 

Detailed Description

Definition at line 248 of file threading.py.

Constructor & Destructor Documentation

def __init__ (   self,
  value = 1,
  verbose = None 
)

Definition at line 252 of file threading.py.

References _Semaphore.__cond, _Semaphore.__value, threading.Condition(), and threading.Lock.

253  def __init__(self, value=1, verbose=None):
254  assert value >= 0, "Semaphore initial value must be >= 0"
255  _Verbose.__init__(self, verbose)
256  self.__cond = Condition(Lock())
257  self.__value = value

Member Function Documentation

def acquire (   self,
  blocking = 1 
)

Definition at line 258 of file threading.py.

References _Semaphore.__value, and _Verbose._note().

259  def acquire(self, blocking=1):
260  rc = 0
261  self.__cond.acquire()
262  while self.__value == 0:
263  if not blocking:
264  break
265  if __debug__:
266  self._note("%s.acquire(%s): blocked waiting, value=%s",
267  self, blocking, self.__value)
268  self.__cond.wait()
269  else:
270  self.__value = self.__value - 1
271  if __debug__:
272  self._note("%s.acquire: success, value=%s",
273  self, self.__value)
274  rc = 1
275  self.__cond.release()
276  return rc
def release (   self)

Definition at line 277 of file threading.py.

References _Semaphore.__value, and _Verbose._note().

278  def release(self):
279  self.__cond.acquire()
280  self.__value = self.__value + 1
281  if __debug__:
282  self._note("%s.release: success, value=%s",
283  self, self.__value)
284  self.__cond.notify()
285  self.__cond.release()
286 

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