trikRuntime
|
Helper template for syncing reader and writer. More...
#include <synchronizedVar.h>
Public Member Functions | |
SynchronizedVar () | |
Constructor. Creates var with default buffer and value. More... | |
T | get () |
Returns synced value. May be called from reader thread. More... | |
T * | operator-> () |
Returns pointer to unsynced buffer. More... | |
const T & | operator* () const |
Returns contents of unsynced buffer. More... | |
void | sync () |
Copies value from buffer to synced value, invalidates buffer. More... | |
void | reset () |
Resets buffer to initial state. More... | |
Helper template for syncing reader and writer.
Compound value can be written to buffer using "->" operator, then, when "sync" is called, it is swapped with current value, which can be accessed using "get". For example, SynchronizedVar<Point> var; var->x = 10; var.sync(); var->x = 20; EXPECT_EQ(10, var.get().x); var.sync(); EXPECT_EQ(20, var.get().x);
|
inline |
Constructor. Creates var with default buffer and value.
|
inline |
Returns synced value. May be called from reader thread.
|
inline |
Returns contents of unsynced buffer.
Shall be called only from writer thread.
|
inline |
Returns pointer to unsynced buffer.
Shall be called only from writer thread.
|
inline |
Resets buffer to initial state.
Shall be called from writer thread.
|
inline |
Copies value from buffer to synced value, invalidates buffer.
Shall be called from writer thread.