Semaphore

from panda3d.core import Semaphore
class Semaphore

Bases: DTOOL_SUPER_BASE

A classic semaphore synchronization primitive.

A semaphore manages an internal counter which is decremented by each acquire() call and incremented by each release() call. The counter can never go below zero; when acquire() finds that it is zero, it blocks, waiting until some other thread calls release().

Inheritance diagram

Inheritance diagram of Semaphore

__init__(*args, **kwargs)
acquire()

C++ Interface: acquire(const Semaphore self)

/**
  • Decrements the internal count. If the count was already at zero, blocks

  • until the count is nonzero, then decrements it.

*/

getCount()

C++ Interface: get_count(Semaphore self)

/**
  • Returns the current semaphore count. Note that this call is not thread-

  • safe (the count may change at any time).

*/

get_count()

C++ Interface: get_count(Semaphore self)

/**
  • Returns the current semaphore count. Note that this call is not thread-

  • safe (the count may change at any time).

*/

output()

C++ Interface: output(Semaphore self, ostream out)

/**

*/

release()

C++ Interface: release(const Semaphore self)

/**
  • Increments the semaphore’s internal count. This may wake up another thread

  • blocked on acquire().

  • Returns the count of the semaphore upon release.

*/

tryAcquire()

C++ Interface: try_acquire(const Semaphore self)

/**
  • If the semaphore can be acquired without blocking, does so and returns

  • true. Otherwise, returns false.

*/

try_acquire()

C++ Interface: try_acquire(const Semaphore self)

/**
  • If the semaphore can be acquired without blocking, does so and returns

  • true. Otherwise, returns false.

*/