Lockless cache is a triple-buffered cache.
The indent is to be used between one or more reader threads, and a single writer thread. The reader thread(s) will always call Read(), and the writer thread will always call Write.
#include <thread/YiLocklessCache.h>
Public Member Functions | |
| CYILocklessCache () | |
| bool | HasNextRead () const |
| const YI_CACHE_TYPE & | Read () const |
| void | Write (const YI_CACHE_TYPE &rData) |
|
inline |
Constructs a Lockless cache that can be read by one or more threads, but written by a single thread.
|
inline |
Checks if there the cache has changed.
Convenient function to query wetter we have a cache that is different than what was returned by the previous Read() call. This function is thread-safe and lockless.
|
inline |
Reads the data currently stored and available within the cache. This function is thread-safe and lockless.
|
inline |
Writes the data into the cache.
If a reader thread is already reading the cache, the writer will write data in an unused buffer so the read thread is never affected and everything remains lockless.