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

A request-reply server backed by ZeroMQ. More...

#include <reqrepserver.h>

Public Types

using ReplyFn = std::function< void(void const *buf, size_t len)>
 
using CallbackFn = std::function< void(void const *buf, size_t len, ReplyFn reply)>
 

Public Member Functions

 ReqRepServer (CallbackFn callback, size_t numThreads=1, std::string endpoint=std::string())
 Constructor. More...
 
 ~ReqRepServer ()
 
std::string endpoint () const
 

Detailed Description

A request-reply server backed by ZeroMQ.

This server will listen for messages in a dedicated thread and call the supplied callback function for every incoming request. Note that if numThreads is greater than one, the callback function maybe be called concurrently from multiple threads. The callback function will be supplied with a reply function; this function must be called before returning. Failure to do so will return in a fatal error (i.e. program abort).

Member Typedef Documentation

using cpid::ReqRepServer::CallbackFn = std::function<void(void const* buf, size_t len, ReplyFn reply)>
using cpid::ReqRepServer::ReplyFn = std::function<void(void const* buf, size_t len)>

Constructor & Destructor Documentation

cpid::ReqRepServer::ReqRepServer ( CallbackFn  callback,
size_t  numThreads = 1,
std::string  endpoint = std::string() 
)

Constructor.

This instance will handle up to numThreads replies concurrently. If endpoint is an empty string, bind to local IP with automatic port selection. The callback will be called from dedicated threads.

cpid::ReqRepServer::~ReqRepServer ( )

Member Function Documentation

std::string cpid::ReqRepServer::endpoint ( ) const

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