|
lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
|
Client of the shared-memory monitor server: connect() finds the server for a tag, maps its shared memory read-only and opens the transition socket and event queues; get() returns the next datagram and free() hands its buffer back. More...
#include <ShmemClient.hh>
Public Member Functions | |
| ShmemClient () | |
| Construct unconnected: no socket, queues or handler. | |
| virtual | ~ShmemClient () |
| Close the message queues and the transition socket and delete the handler. | |
| int | connect (const char *tag, int tr_index=0) |
| Drop any previous connection, read the server port from the discovery queue for tag (retrying), connect a TCP socket to 127.0.0.1 on that port (retrying), read the first XtcMonitorMsg, map the shared memory read-only, and open this client's event input and output queues. | |
| void * | get (int &index, size_t &size) |
| Block in poll() until the transition socket or the event queue is readable, serving transitions first, and return a pointer to the datagram in shared memory with index and size set to its buffer index and buffer size. | |
| void * | get (int &index, size_t &size, bool &eventSkipped, bool transitionsOnly=false) |
| Same as get(int&, size_t&), but if transitionsOnly is true and poll() returns with no transition pending, set eventSkipped to true and return NULL without reading the event. | |
| void | free (int index, size_t size) |
| Return buffer index (located with size) to the server: for an L1Accept datagram send the message on this client's output event queue, otherwise send it on the transition socket (perror() on failure). | |
Client of the shared-memory monitor server: connect() finds the server for a tag, maps its shared memory read-only and opens the transition socket and event queues; get() returns the next datagram and free() hands its buffer back.
| psalg::shmem::ShmemClient::ShmemClient | ( | ) |
Construct unconnected: no socket, queues or handler.
|
virtual |
Close the message queues and the transition socket and delete the handler.
| int psalg::shmem::ShmemClient::connect | ( | const char * | tag, |
| int | tr_index = 0 |
||
| ) |
Drop any previous connection, read the server port from the discovery queue for tag (retrying), connect a TCP socket to 127.0.0.1 on that port (retrying), read the first XtcMonitorMsg, map the shared memory read-only, and open this client's event input and output queues.
tr_index is used only in an error message.
| void psalg::shmem::ShmemClient::free | ( | int | index, |
| size_t | size | ||
| ) |
Return buffer index (located with size) to the server: for an L1Accept datagram send the message on this client's output event queue, otherwise send it on the transition socket (perror() on failure).
| void * psalg::shmem::ShmemClient::get | ( | int & | index, |
| size_t & | size | ||
| ) |
Block in poll() until the transition socket or the event queue is readable, serving transitions first, and return a pointer to the datagram in shared memory with index and size set to its buffer index and buffer size.
Returns NULL, with index -1 and size 0, on a receive error, a closed socket or an invalid buffer index.
| void * psalg::shmem::ShmemClient::get | ( | int & | index, |
| size_t & | size, | ||
| bool & | eventSkipped, | ||
| bool | transitionsOnly = false |
||
| ) |
Same as get(int&, size_t&), but if transitionsOnly is true and poll() returns with no transition pending, set eventSkipped to true and return NULL without reading the event.
eventSkipped is never set to false here.