MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / socket_t

Class socket_t

3rdparty/cppzmq/zmq.hpp:2189–2267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2187namespace zmq
2188{
2189class socket_t : public detail::socket_base
2190{
2191 friend class monitor_t;
2192
2193 public:
2194 socket_t() ZMQ_NOTHROW : detail::socket_base(ZMQ_NULLPTR), ctxptr(ZMQ_NULLPTR) {}
2195
2196 socket_t(context_t &context_, int type_) :
2197 detail::socket_base(zmq_socket(context_.handle(), type_)),
2198 ctxptr(context_.handle())
2199 {
2200 if (_handle == ZMQ_NULLPTR)
2201 throw error_t();
2202 }
2203
2204#ifdef ZMQ_CPP11
2205 socket_t(context_t &context_, socket_type type_) :
2206 socket_t(context_, static_cast<int>(type_))
2207 {
2208 }
2209#endif
2210
2211#ifdef ZMQ_HAS_RVALUE_REFS
2212 socket_t(socket_t &&rhs) ZMQ_NOTHROW : detail::socket_base(rhs._handle),
2213 ctxptr(rhs.ctxptr)
2214 {
2215 rhs._handle = ZMQ_NULLPTR;
2216 rhs.ctxptr = ZMQ_NULLPTR;
2217 }
2218 socket_t &operator=(socket_t &&rhs) ZMQ_NOTHROW
2219 {
2220 close();
2221 std::swap(_handle, rhs._handle);
2222 std::swap(ctxptr, rhs.ctxptr);
2223 return *this;
2224 }
2225#endif
2226
2227 ~socket_t() ZMQ_NOTHROW { close(); }
2228
2229 operator void *() ZMQ_NOTHROW { return _handle; }
2230
2231 operator void const *() const ZMQ_NOTHROW { return _handle; }
2232
2233 void close() ZMQ_NOTHROW
2234 {
2235 if (_handle == ZMQ_NULLPTR)
2236 // already closed
2237 return;
2238 int rc = zmq_close(_handle);
2239 ZMQ_ASSERT(rc == 0);
2240 _handle = ZMQ_NULLPTR;
2241 ctxptr = ZMQ_NULLPTR;
2242 }
2243
2244 void swap(socket_t &other) ZMQ_NOTHROW
2245 {
2246 std::swap(_handle, other._handle);

Callers 1

initMethod · 0.85

Calls 2

socket_refClass · 0.85
swapFunction · 0.70

Tested by

no test coverage detected