|
lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
|
Tracks the transition buffers in shared memory: a stack of buffers holding the cached transitions of the current state, a list of free buffers, and a per-buffer bitmask of clients still using each buffer. More...
#include <TransitionCache.hh>
Public Member Functions | |
| TransitionCache (char *p, size_t sz, unsigned) | |
| Use the third argument as the number of buffers, each sz bytes, starting at p; write a Reset transition Dgram into each and mark all of them free with no clients. | |
| ~TransitionCache () | |
| Destroy the semaphore and free the per-buffer client masks. | |
| void | dump () const |
| Print each buffer's transition name, time and client mask, then the cached and free buffer indexes, to stdout. | |
| std::stack< int > | current () |
| Return the cached buffer indexes as a stack whose top is the oldest cached transition (the reverse of the internal order). | |
| int | allocate (XtcData::TransitionId::Value) |
| Choose the first free buffer that no client holds for transition id and update the cache: Configure starts it, the next begin transition (top id + 2) is pushed, the matching end (top id + 1) pops the top, Disable pops entries above BeginStep, and up to three SlowUpdates are counted. | |
| bool | allocate (int ibuffer, unsigned client) |
| Add client to the client mask of buffer ibuffer and return true. | |
| bool | deallocate (int ibuffer, unsigned client) |
| Remove client from the mask of buffer ibuffer (printing a message if it was not set); when a SlowUpdate buffer becomes unused the SlowUpdate count is decremented. | |
| void | deallocate (unsigned client) |
| Retire client: clear its bit in the not-ready mask and in every buffer's client mask. | |
| unsigned | not_ready () const |
| Return the bitmask of clients marked not ready (per the member comment, clients that are behind in processing). | |
Tracks the transition buffers in shared memory: a stack of buffers holding the cached transitions of the current state, a list of free buffers, and a per-buffer bitmask of clients still using each buffer.
Per the header comment, it caches transitions for clients and tracks those still to be served to late clients. A process-local semaphore guards the state.
| psalg::shmem::TransitionCache::TransitionCache | ( | char * | p, |
| size_t | sz, | ||
| unsigned | |||
| ) |
Use the third argument as the number of buffers, each sz bytes, starting at p; write a Reset transition Dgram into each and mark all of them free with no clients.
| psalg::shmem::TransitionCache::~TransitionCache | ( | ) |
Destroy the semaphore and free the per-buffer client masks.
| bool psalg::shmem::TransitionCache::allocate | ( | int | ibuffer, |
| unsigned | client | ||
| ) |
Add client to the client mask of buffer ibuffer and return true.
If client is marked not ready, this is refused (returns false) unless the buffer holds a SlowUpdate or an end transition (odd id) lower than every end transition the client already holds.
| int psalg::shmem::TransitionCache::allocate | ( | XtcData::TransitionId::Value | ) |
Choose the first free buffer that no client holds for transition id and update the cache: Configure starts it, the next begin transition (top id + 2) is pushed, the matching end (top id + 1) pops the top, Disable pops entries above BeginStep, and up to three SlowUpdates are counted.
Other transitions are reported on stderr and rolled back, or abort() is called if a begin transition was skipped. For begin (even) ids, clients still holding an Enable buffer are added to the not-ready mask.
| std::stack< int > psalg::shmem::TransitionCache::current | ( | ) |
Return the cached buffer indexes as a stack whose top is the oldest cached transition (the reverse of the internal order).
| bool psalg::shmem::TransitionCache::deallocate | ( | int | ibuffer, |
| unsigned | client | ||
| ) |
Remove client from the mask of buffer ibuffer (printing a message if it was not set); when a SlowUpdate buffer becomes unused the SlowUpdate count is decremented.
| void psalg::shmem::TransitionCache::deallocate | ( | unsigned | client | ) |
Retire client: clear its bit in the not-ready mask and in every buffer's client mask.
| void psalg::shmem::TransitionCache::dump | ( | ) | const |
Print each buffer's transition name, time and client mask, then the cached and free buffer indexes, to stdout.
|
inline |
Return the bitmask of clients marked not ready (per the member comment, clients that are behind in processing).