TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
|
Subscriber for ZeroMQ PUB-SUB pattern. More...
#include <blobpubsub.h>
Public Types | |
using | CallbackFn = std::function< void(void const *data, size_t len, int64_t tag)> |
Public Member Functions | |
BlobSubscriber (CallbackFn callback, std::vector< std::string > endpoints, std::shared_ptr< zmq::context_t > context=nullptr) | |
~BlobSubscriber () | |
void | updateEndpoints (std::vector< std::string > endpoints) |
Subscriber for ZeroMQ PUB-SUB pattern.
This client will subscribe to one of the BlobPublisher endpoints specified and listen for incoming mesages. For each received blob, a user-defined callback will be called (in the context of the dedicated listening thread).
Note that due to last-value-caching, the callback might be called multiple times for the same data and tag as they might be broadcasted multiple times.
Changing the endpoints via updateEndpoints()
will trigger endpoint re-selection, which in turn might trigger re-subscription to a new publisher endpoint and which in turn will trigger re-broadcasts.
using cpid::BlobSubscriber::CallbackFn = std::function<void(void const* data, size_t len, int64_t tag)> |
cpid::BlobSubscriber::BlobSubscriber | ( | CallbackFn | callback, |
std::vector< std::string > | endpoints, | ||
std::shared_ptr< zmq::context_t > | context = nullptr |
||
) |
cpid::BlobSubscriber::~BlobSubscriber | ( | ) |
void cpid::BlobSubscriber::updateEndpoints | ( | std::vector< std::string > | endpoints | ) |