Midas C++ API - rb_xxx functions
This page contains the full API reference for the rb_xxx ring buffer functions. Ring buffers pass events between threads within a single program, for example from a readout thread to the thread that sends them on; the mfe frontend framework uses them for multi-threaded readout.
Ring Buffer Functions (rb_xxx)
Functions
rb_create
int rb_create(int size, int max_event_size, int *ring_buffer_handle)
Create a ring buffer with a given size
Provide an inter-thread buffer scheme for handling front-end events. This code allows concurrent data acquisition, calibration and network transfer on a multi-CPU machine. One thread reads out the data, passes it via the ring buffer functions to another thread running on the other CPU, which can then calibrate and/or send the data over the network.
Parameters:
-
size(int) –Size of ring buffer, must be larger than 2*max_event_size -
max_event_size(int) –Maximum event size to be placed into -
ring_buffer_handle(int *)
Returns:
-
int–
Declared in include/msystem.h:690, defined in src/midas.cxx:18869
rb_delete
int rb_delete(int ring_buffer_handle)
Delete a ring buffer
Parameters:
-
ring_buffer_handle(int) –Handle of the ring buffer
Returns:
-
int–
Declared in include/msystem.h:691, defined in src/midas.cxx:18924
rb_get_buffer_level
int rb_get_buffer_level(int handle, int * n_bytes)
Return number of bytes in a ring buffer
Parameters:
-
handle(int) –Handle of the buffer to get the info -
n_bytes(int *)
Returns:
-
int–
Declared in include/msystem.h:696, defined in src/midas.cxx:19219
rb_get_rp
int rb_get_rp(int handle, void **p, int millisec)
Obtain the current read pointer at which new data is available with optional timeout
available data. If p == NULL, only
return status.
Parameters:
-
handle(int) –Ring buffer handle -
p(void **) -
millisec(int) –Optional timeout in milliseconds if buffer is full. Zero to not wait at all (non-blocking)
Returns:
-
int–DB_SUCCESS, DB_TIEMOUT, DB_INVALID_HANDLE
Declared in include/msystem.h:694, defined in src/midas.cxx:19102
rb_get_wp
int rb_get_wp(int handle, void **p, int millisec)
Retrieve write pointer where new data can be written
Parameters:
-
handle(int) –Ring buffer handle -
p(void **) -
millisec(int) –Optional timeout in milliseconds if buffer is full. Zero to not wait at all (non-blocking)
Returns:
-
int–
Declared in include/msystem.h:692, defined in src/midas.cxx:18961
rb_increment_rp
int rb_increment_rp(int handle, int size)
Increment current read pointer, freeing up space for the writing thread.
Parameters:
-
handle(int) –Ring buffer handle -
size(int) –Number of bytes to free up at current read pointer
Returns:
-
int–
Declared in include/msystem.h:695, defined in src/midas.cxx:19164
rb_increment_wp
int rb_increment_wp(int handle, int size)
rb_increment_wp
Increment current write pointer, making the data at the write pointer available to the receiving thread
Parameters:
-
handle(int) –Ring buffer handle -
size(int) –Number of bytes placed at the WP
Returns:
-
int–
Declared in include/msystem.h:693, defined in src/midas.cxx:19036
rb_set_nonblocking
int rb_set_nonblocking()
Set all rb_get_xx to nonblocking. Needed in multi-thread environments for stopping all theads without deadlock
Returns:
-
int–
Declared in include/msystem.h:689, defined in src/midas.cxx:18828