A stream reading entity snapshots from the memory.
More...
#include <RobotAPI/libraries/armem/client/ReadStream.h>
A stream reading entity snapshots from the memory.
After constructing a ReadStream, polling can be started in three ways:
- Run a polling loop in this thread, blocking execution until terminated. See pollBlocking().
- Run a polling loop in a new, separate thread, until it is stopped via stop(). See pollAsync() and stop().
- Perform a single query and process the result, embedded in your own loop or other control flow logic. See pollOnce().
◆ SnapshotCallbackT
Callback called on each entity snapshot in the queried ID.
If it returns false, the stream is stopped.
◆ ReadStream() [1/2]
Inizialize a ReadStream which does not represent a stream.
◆ ReadStream() [2/2]
Initialize a read stream.
- Parameters
-
| reader | The reader to perform the queries. |
| queriedId | The memory ID in which all snapshots should be processed by the stream. |
| maxPollFrequency | The maximum frequency with which queries are performed. The real frequency might be lower. |
◆ pollAsync()
Poll in a new thread as long as callback returns true.
Note that callback will be called in a separate thread, so take care of synchronizing access to variables in the callback appropriately.
Roughly equivalent to:
std::thread thread([]() { stream.pollBlocking(); });
- Parameters
-
| callback | Function to call on each entity snapshot. |
- Exceptions
-
◆ pollBlocking()
Poll in this thread as long as callback returns true.
- Parameters
-
| callback | Function to call on each entity snapshot. |
- Returns
- The snapshot object that returns false.
- Exceptions
-
◆ pollOnce()
Perform one query and call the callbacks on each snapshot.
This allows you to define your own loop, for example:
bool condition = true;
while (condition)
{
auto snapshot = stream.pollOnce(callback);
...
if (...)
{
condition = false;
}
}
- Parameters
-
| callback | Function to call on each entity snapshot. |
- Exceptions
-
◆ stop()
Stop a running polling loop.
If a polling thread has been started by pollAsync() before, joins the thread.
The documentation for this class was generated from the following files: