Inheritance diagram for smtk::shared_memory:

Public Member Functions | |
| int | blocking_q_read (void *buf, size_t bytes=0, size_t offset=0) |
| block until there is data to read in the queue | |
| int | blocking_read (void *buf, size_t bytes=0, size_t offset=0) |
| read blocking until new data comes | |
| void * | blocking_rlock_pointer (bool from_queue=false, int *num_in_q=0) |
| block until new data is ready, get a read-lock and a read pointer | |
| int | blocking_wlock (void) |
| wait for the signal from the reader and get the write-lock | |
| void * | blocking_wlock_pointer (void) |
| wait for the signal from the reader, get the write-lock and return a pointer to shared memory | |
| int | blocking_write (const void *buf, size_t bytes=0, size_t offset=0, const struct timeval *time_stamp=0, int byte_order=__BYTE_ORDER) |
| blocking write | |
| int | blocking_write (const void *buf, const struct timeval *time_stamp, int byte_order=__BYTE_ORDER) |
| blocking write | |
| arena * | get_arena (void) |
| get the arena object associated with this object | |
| char * | get_name (void) const |
| get the segment name | |
| size_t | get_size (void) const |
| get the segment memory size | |
| shared_memory & | get_time_stamp (struct timeval &tv) |
| get time stamp | |
| long double | get_time_stamp (void) const |
| get time stamp | |
| unsigned long long | get_write_count (void) const |
| get the write count | |
| bool | is_counted (void) |
| is the segment write counted | |
| bool | is_invalid (void) const |
| see if the object is invalid | |
| bool | is_local_byte_order () const |
| Check the byte order of the data that was last read. | |
| bool | is_queued (void) |
| is the segment queued | |
| bool | is_time_stamped (void) |
| is the segment write time stamped | |
| bool | is_valid (void) const |
| see if the object is valid | |
| template<class X> | |
| shared_memory & | operator= (X x) |
| write to the current refered array element | |
| shared_memory & | operator[] (int index) |
| refer to one array element | |
| int | q_read (void *buf, size_t bytes=0, size_t offset=0) |
| read from the queue | |
| int | read (void *buf, size_t bytes=0, size_t offset=0) |
| read current values | |
| void * | rlock_pointer (bool from_queue=false, int *num_in_q=0) |
| get a read-lock and a read pointer | |
| int | runlock (void) |
| release the read lock | |
| int | set_byte_swapping (int element_size) |
| make the segment byte swap when needed and sets array element size | |
| int | set_element_size (int element_size) |
| make the segment byte swap when needed and sets array element size | |
| int | set_queuing (int length=0) |
| make the segment be queued | |
| int | set_signal_writer (void) |
| set up to signal blocking writers | |
| int | set_time_stamping (void) |
| make the segment be time stamped when it is written | |
| int | set_write_counting (void) |
| make the segment be counted when it is written | |
| shared_memory (const char *segment_name, const char *arena_file=0) | |
| shared_memory (size_t size, const char *segment_name, const char *arena_file, MODE arena_file_flag) | |
| shared_memory (size_t size, const char *segment_name, const char *arena_file, mode_t arena_file_mode=0, MODE arena_file_flag=GET) | |
| shared_memory (size_t size, const char *segment_name, MODE mflag, const char *arena_file=0, mode_t arena_file_mode=0, MODE arena_file_flag=GET) | |
| shared_memory (size_t size, const char *segment_name, void *init_buff, const char *arena_file, mode_t arena_file_mode=0, MODE arena_file_flag=GET) | |
| shared_memory (size_t size, const char *segment_name, void *init_buff, MODE mflag=GET, const char *arena_file=0, mode_t arena_file_mode=0, MODE arena_file_flag=GET) | |
| shared_memory (size_t size, const char *segment_name=0, size_t element_size=0, void *init_buff=0, u_int16_t flags=0, u_int16_t queue_length=0, MODE mflag=GET, const char *arena_file=0, mode_t arena_file_mode=0, MODE arena_file_flag=GET) | |
| int | signal_writer (bool set_counter=true) |
| signal blocking writers | |
| int | unblock_read (void) |
| unblock a blocking read | |
| int | unset_signal_writer (void) |
| remove this object from signaling blocking writers | |
| int | wait_for_write (void) |
| wait for data to read | |
| int | wlock (void) |
| get the write lock | |
| void * | wlock_pointer (void) |
| get the write-lock and return a pointer to shared memory | |
| int | write (const void *buf, const struct timeval *time_stamp, int byte_order=__BYTE_ORDER) |
| write | |
| int | write (const void *buf, size_t bytes=0, size_t offset=0, const struct timeval *time_stamp=0, int byte_order=__BYTE_ORDER) |
| write | |
| int | wunlock (const struct timeval *time_stamp=0, bool did_write=true) |
| finish off the writing and release the write-lock | |
| virtual | ~shared_memory (void) |
Static Public Attributes | |
| static const u_int16_t | DEFAULT_QUEUE_LENGTH = 10 |
| static const u_int16_t | IS_COUNTED = 004 |
| static const u_int16_t | IS_TIME_STAMPED = 002 |
Protected Member Functions | |
| template<class T> | |
| T | invalidate (T t) |
| invalidate the object | |
| void | invalidate (void) |
| invalidate the object | |
| template<class T> | |
| T | validate (T t) |
| validate the object | |
| void | validate (void) |
| validate the object | |
This provides an interface to SmTk shared memory. This shared memory is shared between processes on a computer and may shared between IP networked computers in a manner that is seamless to the SmTk API (application programming interface) user. So programs that use SmTk shared memory become networked programs in a seamless way that is simular to how X windows programs are networked programs without any effort from the program writer.
There are 28 constructor argument possibilities, with the 7 different constructors. It's likely one will suit you.
| shared_memory::shared_memory | ( | size_t | size, | |
| const char * | segment_name = 0, |
|||
| size_t | element_size = 0, |
|||
| void * | init_buff = 0, |
|||
| u_int16_t | flags = 0, |
|||
| u_int16_t | queue_length = 0, |
|||
| MODE | mflag = GET, |
|||
| const char * | arena_file = 0, |
|||
| mode_t | arena_file_mode = 0, |
|||
| MODE | arena_file_flag = GET | |||
| ) |
This constructor has the most optional arguments. It is a super-set of all other smtk::shared_memory constructors.
You create and/or connect to a SmTk shared memory segment with the constructor of a smtk::shared_memory object. If the arena file for the shared memory segment does not exist yet it will be created for the (mflag=) GET and CREATE versions of this. If this is successful the inherited method is_valid() will return true.
| size | size of the shared memory segment that the user will use. This is just the size of that the user reads the writes to. | |
| segment_name | is the name used to refer to the shared memory segment with, so that other programs may refer to it with this name too. There may not be two shared memory segments with the same name in the same shared memory arena file. If segment_name=0 and this shared memory segment is being created, than a name will be assigned and it will begin with "~". There will be other shared memory segments created with a name that begins with "~" as part of the internal structure of the shared memory arena, so it would be good to avoid having names that begin with ~. | |
| element_size | is the size of an element in an array, if the data in shared memory is an array of elements. For example if the data in shared memory is an array of single precision floats then element_size should be equal to sizeof(float). When element_size is greater than one then any data read that came from the network will be automatically set so that the byte order is the same as the local computer's byte order. Byte order is only a problem if you are sharing memory between computers with different byte orders like between a SGI IRIX computer and an AMD or Intel PC. If your shared memory data is not an array that's fine, but you may have to do your own byte swapping if your sharing memory between computers with different byte orders. See is_local_byte_order(). | |
| init_buff | is a user provided buffer. init_buff will be used to initialize the shared memory segment if it is created. init_buff will be set to the values of the data in the shared memory segment if it exists before the object is created. If init_buff=0 it will be ignored. | |
| flags | is a bit mask of flags that may be any bit-wise or'd combination of the masks IS_QUEUED, IS_TIME_STAMPED, and IS_COUNTED:
| |
| queue_length | may be set to the desired queue length if the shared memory is to be queued. If queue_length=0, and the shared memory queuing is not set yet, the value of DEFAULT_QUEUE_LENGTH will be used for the queue length. | |
| mflag | If mflag (creation mode flag) is GET then the shared memory segment will be created if they do not exist, else if mflag is CONNECT than the shared memory segment must exist before this call, or else if mflag is CREATE the shared memory segment must not exist before this call and it will be created. | |
| arena_file | is the arena file that is used to map the shared memory. Using a network mounted file may not work, but that may be an easy way to get reliable networked shared memory. If it works, it may be a little slow. If arena_file=0 the default arena file SMTK_DEFAULT_ARENA_FILE will be used. SMTK_DEFAULT_ARENA_FILE is defined in smtk/config.h. If arena_file!=0 and it is not a full file path the SMTK_DEFAULT_ARENA_DIR will be the directory used. SMTK_DEFAULT_ARENA_DIR and SMTK_DEFAULT_ARENA_FILE are macros defined in smtk/shared_memory_config.h which is included in smtk.h. | |
| arena_file_mode | specifies the permissions to use in case a new arena file is created. It is modified by the process's umask in the usual way: the permissions of the created arena file are (mode & ~umask). If arena_file_mode=0 the the arena file permissions will be set to SMTK_DEFAULT_ARENA_FILE_MODE being modified by the process's umask in the usual way: the permissions of the created file are (mode & ~umask). SMTK_DEFAULT_ARENA_FILE_MODE is defined in smtk/config.h. arena_file_mode will not have any effect unless you are creating the arena file. (On UNIXes) You can use chmod(1) or chmod(2) to modify the arena file permissions after the file is created. | |
| arena_file_flag | If arena_file_flag=GET then the shared memory arena file will be created if it does not exist, else if arena_file_flag is CONNECT than the shared memory arena file must exist before this call, or else if arena_file_flag is CREATE the shared memory arena file must not exist before this call and it will be created. |
| shared_memory::shared_memory | ( | size_t | size, | |
| const char * | segment_name, | |||
| void * | init_buff, | |||
| MODE | mflag = GET, |
|||
| const char * | arena_file = 0, |
|||
| mode_t | arena_file_mode = 0, |
|||
| MODE | arena_file_flag = GET | |||
| ) |
Alternate constructor. Uses the default element_size=0.
| shared_memory::shared_memory | ( | size_t | size, | |
| const char * | segment_name, | |||
| void * | init_buff, | |||
| const char * | arena_file, | |||
| mode_t | arena_file_mode = 0, |
|||
| MODE | arena_file_flag = GET | |||
| ) |
Alternate constructor. Uses the defaults element_size=0 and MODE flag=GET.
| shared_memory::shared_memory | ( | size_t | size, | |
| const char * | segment_name, | |||
| MODE | mflag, | |||
| const char * | arena_file = 0, |
|||
| mode_t | arena_file_mode = 0, |
|||
| MODE | arena_file_flag = GET | |||
| ) |
Alternate constructor. Uses the defaults element_size=0 and MODE init_buff=0.
| shared_memory::shared_memory | ( | size_t | size, | |
| const char * | segment_name, | |||
| const char * | arena_file, | |||
| mode_t | arena_file_mode = 0, |
|||
| MODE | arena_file_flag = GET | |||
| ) |
Alternate constructor. Uses the defaults element_size=0, MODE init_buff=0 and MODE flag=GET.
| shared_memory::shared_memory | ( | size_t | size, | |
| const char * | segment_name, | |||
| const char * | arena_file, | |||
| MODE | arena_file_flag | |||
| ) |
Alternate constructor. Uses the defaults element_size=0, MODE init_buff=0, MODE flag=GET and arena_file_mode=0.
| shared_memory::shared_memory | ( | const char * | segment_name, | |
| const char * | arena_file = 0 | |||
| ) |
Connect to a SmTk shared memory segment with this constructor of a smtk::shared_memory object. If the shared memory segment does not exist this object will not be validated.
| segment_name | is the name used to refer to the shared memory segment with, so that other programs may refer to it with this name too. | |
| arena_file | is the arena file that is used to map the shared memory. |
| shared_memory::~shared_memory | ( | void | ) | [virtual] |
This destructor does not remove the shared memory segment from the arena file. The shared memory segment is a resource that is shared between processes. See smtk::shared_memory_remove().
| int shared_memory::blocking_q_read | ( | void * | buf, | |
| size_t | bytes = 0, |
|||
| size_t | offset = 0 | |||
| ) |
block until there is data to read in the queue
This call will block wait for a signal from a write or a call to unblock_read(). Do not call rlock() before this.
If the user held a read-lock (rlock()) before calling this the read-lock will be released before this blocks, if it blocks, but the read-lock will be re-acquired before this returns.
| buf | is a user supplied buffer that the data will be read to. This buffer must be as large or larger then the size of the shared memory, as may have been set in the constructor or is returned from get_size(). | |
| bytes | if set is the number of bytes to write to buf. If bytes is set and you need to do many partial reads you want to call rlock() and do the many q_read() calls and than call advance_q() and maybe more q_read() calls and after you get enough or the queue is empty call runlock(). You don't want to use lots of time while holding the read lock between the rlock() call and the runlock() call. | |
| offset | is the number of bytes from the start of the shared memory data to start reading from. |
| int shared_memory::blocking_read | ( | void * | buf, | |
| size_t | bytes = 0, |
|||
| size_t | offset = 0 | |||
| ) |
read blocking until new data comes
This will add write counting to the shared memory segment. If you wish to make certain you read all that is written in an asynchronous manner try shared_memory::read_q() or shared_memory::blocking_q_read().
This call will block wait for a signal from a write or a call to unblock_read(). Do not call rlock() before this.
| buf | is a user supplied buffer that the data will be read to. This buffer must be as large or larger then the size of the shared memory, as may have been set in the constructor or is returned from get_size(). | |
| bytes | if set is the number of bytes to write to buf. If bytes is set and you need to do many partial reads you want to call rlock() and do the many q_read() calls and than call advance_q() and maybe more q_read() calls and after you get enough or the queue is empty call runlock(). You don't want to use lots of time while holding the read lock between the rlock() call and the runlock() call. | |
| offset | is the number of bytes from the start of the shared memory data to start reading from. |
| void * shared_memory::blocking_rlock_pointer | ( | bool | from_queue = false, |
|
| int * | num_in_q = 0 | |||
| ) |
block until new data is ready, get a read-lock and a read pointer
This will make the shared_memory be queued.
| from_queue | If from_queue is true this will return a pointer to the queued data entry. | |
| num_in_q | If num_in_q is set and from_queue is true the value that num_in_q points to will be written with the number of entries in the queue before this call. If from_queue is false num_in_q will be ignored. |
| int shared_memory::blocking_wlock | ( | void | ) |
wait for the signal from the reader and get the write-lock
This can be used, in place of wlock(), for doing a synchronous writing with shared_memory::operator= and time_stamp will be ignored. See shared_memory::set_time_stamping() and shared_memory::get_time_stamp().
| void* smtk::shared_memory::blocking_wlock_pointer | ( | void | ) | [inline] |
wait for the signal from the reader, get the write-lock and return a pointer to shared memory
This can be used, in place of wlock(), for doing a synchronous writing with shared_memory::operator= and time_stamp will be ignored. See shared_memory::set_time_stamping() and shared_memory::get_time_stamp().
| int shared_memory::blocking_write | ( | const void * | buf, | |
| size_t | bytes = 0, |
|||
| size_t | offset = 0, |
|||
| const struct timeval * | time_stamp = 0, |
|||
| int | byte_order = __BYTE_ORDER | |||
| ) |
blocking write
| buf | is a pointer to the data to copy to shared memory. | |
| bytes | if set, is the number of bytes to write. | |
| offset | is the position in bytes in shared memory where to start writing. | |
| time_stamp | If time_stamp is set this time stamp will be used to time stamp the shared memory entry. If time_stamp is not set and the segment is time stamped then a time stamp will be generated (using gettimeofday(2)) at the time of this call. The default time_stamp=0 is recommended in most local cases. If time stamping is not set the argument time_stamp will be ignored. See shared_memory::set_time_stamping() and shared_memory::get_time_stamp(). | |
| byte_order | is the order of the data you are writing. This is not for local users. Setting byte_order is necessary if you are writing to shared memory from a server that gets data from the network from computers that may have different byte orders. byte_order may be set to __LITTLE_ENDIAN or __BIG_ENDIAN which are defined in the system header file endian.h. |
| int smtk::shared_memory::blocking_write | ( | const void * | buf, | |
| const struct timeval * | time_stamp, | |||
| int | byte_order = __BYTE_ORDER | |||
| ) | [inline] |
blocking write
| buf | is a pointer to the data to copy to shared memory. | |
| time_stamp | If time_stamp is set this time stamp will be used to time stamp the shared memory entry. If time_stamp is not set and the segment is time stamped then a time stamp will be generated (using gettimeofday(2)) at the time of this call. The default time_stamp=0 is recommended in most local cases. If time stamping is not set the argument time_stamp will be ignored. See shared_memory::set_time_stamping() and shared_memory::get_time_stamp(). | |
| byte_order | is the order of the data you are writing. This is not for local users. Setting byte_order is necessary if you are writing to shared memory from a server that gets data from the network from computers that may have different byte orders. byte_order may be set to __LITTLE_ENDIAN or __BIG_ENDIAN which are defined in the system header file endian.h. |
| arena* smtk::shared_memory::get_arena | ( | void | ) | [inline] |
get the arena object associated with this object
You should not need this unless you are debugging SmTk code.
| char* smtk::shared_memory::get_name | ( | void | ) | const [inline] |
get the segment name
| size_t smtk::shared_memory::get_size | ( | void | ) | const [inline] |
get the segment memory size
| shared_memory& smtk::shared_memory::get_time_stamp | ( | struct timeval & | tv | ) | [inline] |
get time stamp
Get the time stamp from the last entry read or written. The shared memory segment must be time stamped by using shared_memory::set_time_stamping().
| tv | a reference to a struct timeval which will be set to the time stamp from the last call to read() or q_read(). |
| long double smtk::shared_memory::get_time_stamp | ( | void | ) | const [inline] |
| unsigned long long smtk::shared_memory::get_write_count | ( | void | ) | const [inline] |
get the write count
The shared memory segment must have write counting set using shared_memory::set_write_counting(). Get the write_count from the last entry read or written.
| T smtk::validation::invalidate | ( | T | t | ) | [inline, protected, inherited] |
invalidate the object
Make the object invalid.
| void smtk::validation::invalidate | ( | void | ) | [inline, protected, inherited] |
invalidate the object
Make the object invalid.
| bool smtk::shared_memory::is_counted | ( | void | ) | [inline] |
is the segment write counted
returns true if the segment is write counted, else returns false.
| bool smtk::validation::is_invalid | ( | void | ) | const [inline, inherited] |
see if the object is invalid
| bool smtk::shared_memory::is_local_byte_order | ( | ) | const [inline] |
Check the byte order of the data that was last read.
If your not using arrays in the shared memory, when you'll have to byte swap the data that you read yourself. Calling is_local_byte_order() after one of the read methods will tell you if you need to byte swap the data.
return true if the data last read was is the local computers byte order, and returns false if it is not in the local computers byte order.
| bool smtk::shared_memory::is_queued | ( | void | ) | [inline] |
is the segment queued
returns true if the segment is queued, else returns false.
| bool smtk::shared_memory::is_time_stamped | ( | void | ) | [inline] |
| bool smtk::validation::is_valid | ( | void | ) | const [inline, inherited] |
see if the object is valid
| shared_memory& smtk::shared_memory::operator= | ( | X | x | ) | [inline] |
write to the current refered array element
This can be more efficient because you do not need to transfer your calculated values to an array, like when you use shared_memory::write(). You just write the array element value by passing a refenence to the type (like float).
You must call wlock() at some point before this and wunlock() at some point after. This presents a more traditional looking interface to distributed shared memory.
| x | Sets the value of the array element in the shared memory to /e x. |
| shared_memory& smtk::shared_memory::operator[] | ( | int | index | ) | [inline] |
refer to one array element
Sets the internal pointer to shared memory to array index index. The element size must be set to use this. The element size may be set in the shared_memory() constructor, set_byte_swapping(), or set_element_size(). You must have a write-lock or a read-lock when calling this.
| index | is the array index of the array element you will get. If index is too large (index * element_size >= memory_size) you will over-ride the buffer and get undefined results. |
| int shared_memory::q_read | ( | void * | buf, | |
| size_t | bytes = 0, |
|||
| size_t | offset = 0 | |||
| ) |
read from the queue
Read the values from the shared memory queue.
| buf | is a user supplied buffer that the data will be read to. | |
| bytes | if set is the number of bytes to write to buf. If bytes is set and you need to do many partial reads you want to call rlock() and do the many q_read() calls and than call advance_q() and maybe more q_read() calls and after you get enough or the queue is empty call runlock(). You don't want to use lots of time while holding the read lock between the rlock() call and the runlock() call. | |
| offset | is the number of bytes from the start of the shared memory data to start reading from. |
| int shared_memory::read | ( | void * | buf, | |
| size_t | bytes = 0, |
|||
| size_t | offset = 0 | |||
| ) |
read current values
Read the current values from shared memory. If you wish to make certain you read all that is written in an asynchronous manner try shared_memory::read_q() or shared_memory::blocking_q_read().
| buf | is a user supplied buffer that the data will be read to. If bytes is set and you need to do many partial reads you way want to call rlock() and do the many read() calls and after you get enough call runlock(). You don't want to use lots of time while holding the read lock between the rlock() call and the runlock() call. | |
| bytes | if set is the number of bytes to write to buf. | |
| offset | is the number of bytes from the start of the shared memory data to start reading from. |
| void * shared_memory::rlock_pointer | ( | bool | from_queue = false, |
|
| int * | num_in_q = 0 | |||
| ) |
get a read-lock and a read pointer
| from_queue | If from_queue is true this will return a pointer to the queued data entry, but if there is no queue entry to read the read-lock will not be aquired. | |
| num_in_q | If num_in_q is set and from_queue is true the value that num_in_q points to will be written with the number of entries in the queue before this call. If from_queue is false num_in_q will be ignored. |
| int smtk::shared_memory::runlock | ( | void | ) | [inline] |
| int shared_memory::set_byte_swapping | ( | int | element_size | ) |
make the segment byte swap when needed and sets array element size
This will fail if the shared memory segment size is not a multiple of element_size. When the shared memory is written to from a networked server, this will cause the shared memory data to be byte swapped automatically. Since the user may make SmTk shared memory any size with array with elements of any size byte swapping can't be done without knowing the array element size. For example to get an array of floats to be automatically byte swapped, when needed, use: shm_object.set_byte_swapping(sizeof(float)). The element size may also be set in smtk::shared_memory constructors, which sets up automatic byte swapping.
| element_size | is the size of the element in bytes. The element size may only be set once, but calling this with the same value as the shared memory segment has set already will not return an error. |
| int smtk::shared_memory::set_element_size | ( | int | element_size | ) | [inline] |
make the segment byte swap when needed and sets array element size
This does the same thing that set_byte_swapping() does, but may be easier to remember function name for people setting the element size so that they may use the array writing funtions operator[] and operator=.
| element_size | is the size of the element in bytes. The element size may only be set once, but calling this with the same value as the shared memory segment has set already will not return an error. |
| int shared_memory::set_queuing | ( | int | length = 0 |
) |
make the segment be queued
Make the shared memory segment be queued.
| length | is the requested queue length. If length is smaller than the current queue length it will not be changed. |
| int shared_memory::set_signal_writer | ( | void | ) |
set up to signal blocking writers
| int shared_memory::set_time_stamping | ( | void | ) |
| int shared_memory::set_write_counting | ( | void | ) |
make the segment be counted when it is written
This sets the shared memory segment up so that each time the shared memory is written to the data written is marked with a count. See shared_memory::get_write_count().
| int shared_memory::signal_writer | ( | bool | set_counter = true |
) |
signal blocking writers
| set_counter | If set_counter is true the write_count from the last reading call will be written to the segment header so that a blocking_write() in some process can see if it's time to write now or not. A writing process may unblock itself by calling this in a signal handler with set_counter set to false. |
| int shared_memory::unblock_read | ( | void | ) |
unblock a blocking read
For use in the signal handler, so that your program may exit when nothing is writing to the shared memory segment and you in a call to one of the blocking read methods blocking_read() or blocking_q_read().
| int shared_memory::unset_signal_writer | ( | void | ) |
remove this object from signaling blocking writers
| T smtk::validation::validate | ( | T | t | ) | [inline, protected, inherited] |
validate the object
Make the object valid.
| void smtk::validation::validate | ( | void | ) | [inline, protected, inherited] |
validate the object
Make the object valid.
| int shared_memory::wait_for_write | ( | void | ) |
wait for data to read
Blocks until there is new data to read in shared memory. The segment will be write counted if it's not already. See set_write_counting(). If the caller has a read-lock or write-lock before this call it will have it after, though it will be released when and if blocking occurs.
| int shared_memory::wlock | ( | void | ) |
get the write lock
Getting a write lock is not required before each write(), but may be useful if your doing a set of more than one partial writes. When wlock() is not called, by the user, before write() it is automatically called in write(). wlock() should be followed by a corresponding call to wunlock(). Unless you're doing partial writes it's not recommended to use wlock() and wunlock().
If a user uses wlock() and wulock() before and after a sequence of calls to write() the time_stamp pasted to write will be ignored, and the user should set time_stamp in the call to wunlock().
| void* smtk::shared_memory::wlock_pointer | ( | void | ) | [inline] |
get the write-lock and return a pointer to shared memory
Getting a write lock is not required before each write(), but may be useful if your doing a set of more than one partial writes. When wlock() is not called, by the user, before write() it is automatically called in write(). wlock() should be followed by a corresponding call to wunlock(). Unless you're doing partial writes it's not recommended to use wlock() and wunlock().
If a user uses wlock() and wulock() before and after a sequence of calls to write() the time_stamp pasted to write will be ignored, and the user should set time_stamp in the call to wunlock().
| int smtk::shared_memory::write | ( | const void * | buf, | |
| const struct timeval * | time_stamp, | |||
| int | byte_order = __BYTE_ORDER | |||
| ) | [inline] |
write
Write to the shared memory segment.
| buf | is a pointer to the data to copy to shared memory. | |
| time_stamp | If time_stamp is set this time stamp will be used to time stamp the shared memory entry. If time_stamp is not set and the segment is time stamped then a time stamp will be generated (using gettimeofday(2)) at the time of this call. The default time_stamp=0 is recommended in most local cases. If time stamping is not set the argument time_stamp will be ignored. See shared_memory::set_time_stamping() and shared_memory::get_time_stamp(). | |
| byte_order | is the order of the data you are writing. This is not for local users. Setting byte_order is necessary if you are writing to shared memory from a server that gets data from the network from computers that may have different byte orders. byte_order may be set to __LITTLE_ENDIAN or __BIG_ENDIAN which are defined in the system header file endian.h. |
| int shared_memory::write | ( | const void * | buf, | |
| size_t | bytes = 0, |
|||
| size_t | offset = 0, |
|||
| const struct timeval * | time_stamp = 0, |
|||
| int | byte_order = __BYTE_ORDER | |||
| ) |
write
Write to the shared memory segment.
| buf | is a pointer to the data to copy to shared memory. | |
| bytes | if set, is the number of bytes to write. | |
| offset | is the position in bytes in shared memory where to start writing. | |
| time_stamp | If time_stamp is set this time stamp will be used to time stamp the shared memory entry. If time_stamp is not set and the segment is time stamped then a time stamp will be generated (using gettimeofday(2)) at the time of this call. The default time_stamp=0 is recommended in most local cases. If time stamping is not set the argument time_stamp will be ignored. See shared_memory::set_time_stamping() and shared_memory::get_time_stamp(). | |
| byte_order | is the order of the data you are writing. This is not for local users. Setting byte_order is necessary if you are writing to shared memory from a server that gets data from the network from computers that may have different byte orders. byte_order may be set to __LITTLE_ENDIAN or __BIG_ENDIAN which are defined in the system header file endian.h. |
| int shared_memory::wunlock | ( | const struct timeval * | time_stamp = 0, |
|
| bool | did_write = true | |||
| ) |
finish off the writing and release the write-lock
If a user uses wlock() and wulock() before and after a sequence of calls to write() the time_stamp pasted to write will be ignored, and the user should set time_stamp in the call to wunlock().
| time_stamp | is a time stamp to write. | |
| did_write | If did_write=true than the appropate actions will be taken, like advancing the queue. If did_write is false then it is assumed that you did not write and the queue will not be advanced, the write count will not be incremented, and so on. |
const u_int16_t smtk::shared_memory::DEFAULT_QUEUE_LENGTH = 10 [static] |
constructor bit-mask flag
const u_int16_t smtk::shared_memory::IS_COUNTED = 004 [static] |
constructor bit-mask flag
const u_int16_t smtk::shared_memory::IS_TIME_STAMPED = 002 [static] |
constructor bit-mask flag
1.5.2