diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-02-17 17:33:35 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-02-17 17:33:35 +0100 |
| commit | 33e13c4053138930f4b2f59349e441c76111059d (patch) | |
| tree | 4a4da8c31d0a78bc11539ae89a5d67602cdcb913 /src/lib/nanomsg.cc | |
| parent | e573f4fa173608dcb7ca23f543b49d5be26a8226 (diff) | |
Assorted C++11 tidying.
Diffstat (limited to 'src/lib/nanomsg.cc')
| -rw-r--r-- | src/lib/nanomsg.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/lib/nanomsg.cc b/src/lib/nanomsg.cc index 4cc071370..b66d966af 100644 --- a/src/lib/nanomsg.cc +++ b/src/lib/nanomsg.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "nanomsg.h" #include "dcpomatic_log.h" #include "exceptions.h" @@ -26,12 +27,15 @@ #include <stdexcept> #include <cerrno> + using std::string; using std::runtime_error; using boost::optional; + #define NANOMSG_URL "ipc:///tmp/dcpomatic.ipc" + Nanomsg::Nanomsg (bool server) { _socket = nn_socket (AF_SP, NN_PAIR); @@ -49,6 +53,7 @@ Nanomsg::Nanomsg (bool server) } } + bool Nanomsg::send (string s, int timeout) { @@ -69,18 +74,20 @@ Nanomsg::send (string s, int timeout) return true; } + optional<string> Nanomsg::get_from_pending () { if (_pending.empty()) { - return optional<string>(); + return {}; } - string const l = _pending.back(); + auto const l = _pending.back(); _pending.pop_back(); return l; } + void Nanomsg::recv_and_parse (int flags) { @@ -108,6 +115,7 @@ Nanomsg::recv_and_parse (int flags) nn_freemsg (buf); } + optional<string> Nanomsg::receive (int timeout) { @@ -115,7 +123,7 @@ Nanomsg::receive (int timeout) nn_setsockopt (_socket, NN_SOL_SOCKET, NN_RCVTIMEO, &timeout, sizeof(int)); } - optional<string> l = get_from_pending (); + auto l = get_from_pending (); if (l) { return *l; } |
