refactor to more idiomatic RAII

* FairMQTransportFactoryZMQ: move the config invariant
    initialization to ctor
  * FairMQChannel: add new ctor that creates usable channel
  * FairMQSocket*: close sockets in dtor
  * FairMQTransportFactory*: terminate context in dtor
  * FairMQChannel: add Bind/Connect facades (for explicit control, e.g. timing)
This commit is contained in:
Dennis Klein
2017-05-14 17:10:57 +02:00
committed by Mohammad Al-Turany
parent 87252edbe0
commit 3205e0c378
12 changed files with 78 additions and 55 deletions

View File

@@ -42,6 +42,12 @@ class FairMQChannel
/// @param address Network address to bind/connect to (e.g. "tcp://127.0.0.1:5555" or "ipc://abc")
FairMQChannel(const std::string& type, const std::string& method, const std::string& address);
/// Constructor
/// @param name Channel name
/// @param type Socket type (push/pull/pub/sub/spub/xsub/pair/req/rep/dealer/router/)
/// @param factory TransportFactory
FairMQChannel(const std::string& name, const std::string& type, std::shared_ptr<FairMQTransportFactory> factory);
/// Copy Constructor
FairMQChannel(const FairMQChannel&);
@@ -53,6 +59,20 @@ class FairMQChannel
FairMQSocket const & GetSocket() const;
auto Bind(const std::string& address) -> bool
{
fMethod = "bind";
fAddress = address;
return fSocket->Bind(address);
}
auto Connect(const std::string& address) -> void
{
fMethod = "connect";
fAddress = address;
return fSocket->Connect(address);
}
/// Get channel name
/// @return Returns full channel name (e.g. "data[0]")
std::string GetChannelName() const;