Package coro :: Module _coro :: Class semaphore
[hide private]
[frames] | no frames]

Class semaphore

object --+
         |
        semaphore

Semaphore lock object.

The constructor takes one parameter, the value to start the semaphore with.

Instance Methods [hide private]
 
__init__(...)
x.__init__(...) initializes x; see help(type(x)) for signature
 
__int__(x)
int(x)
 
__long__(x)
long(x)
a new object with type S, a subtype of T
__new__(T, S, ...)
 
acquire(...)
Acquire a number of resource elements from the semaphore.
 
release(...)
Release a number of resource elements.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables [hide private]
  _waiting
: A fifo of (value, co) tuples of coroutines waiting for the semaphore.
  avail
: The current value of the semaphore.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(...)
(Constructor)

 
x.__init__(...) initializes x; see help(type(x)) for signature
Overrides: object.__init__

__new__(T, S, ...)

 
Returns: a new object with type S, a subtype of T
Overrides: object.__new__

acquire(...)

 

Acquire a number of resource elements from the semaphore.

This will subtract the given value from the semaphore. This will block if the requested number of resource elements are not available (if the value would go negative).

Parameters:
  • value - : The number of resource elements.

release(...)

 
Release a number of resource elements.
Parameters:
  • value - : The number of resource elements to release (add to the sempahore).

Instance Variable Details [hide private]

avail

: The current value of the semaphore. Also available via __int__.