TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
Public Types | Public Member Functions | List of all members
cpid::BlobSubscriber Class Referencefinal

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)
 

Detailed Description

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.

Member Typedef Documentation

using cpid::BlobSubscriber::CallbackFn = std::function<void(void const* data, size_t len, int64_t tag)>

Constructor & Destructor Documentation

cpid::BlobSubscriber::BlobSubscriber ( CallbackFn  callback,
std::vector< std::string >  endpoints,
std::shared_ptr< zmq::context_t >  context = nullptr 
)
cpid::BlobSubscriber::~BlobSubscriber ( )

Member Function Documentation

void cpid::BlobSubscriber::updateEndpoints ( std::vector< std::string >  endpoints)

The documentation for this class was generated from the following files: