aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/deps/rpclib/include/rpc/this_session.h
diff options
context:
space:
mode:
authorAndrej Rode <andrej.rode@ettus.com>2017-04-03 18:49:58 -0700
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:03:45 -0800
commit53795c74aead4e6021bc788b788f8ed5b4a0166d (patch)
tree45e4075f3d8ffdee7dff7c72dd665f5c5b0c746c /host/lib/deps/rpclib/include/rpc/this_session.h
parent6a12add1560545438e1bebc05efbafd05aace4f9 (diff)
downloaduhd-53795c74aead4e6021bc788b788f8ed5b4a0166d.tar.gz
uhd-53795c74aead4e6021bc788b788f8ed5b4a0166d.tar.bz2
uhd-53795c74aead4e6021bc788b788f8ed5b4a0166d.zip
uhd: add cut-down rpclib source tree and import tool
Diffstat (limited to 'host/lib/deps/rpclib/include/rpc/this_session.h')
-rw-r--r--host/lib/deps/rpclib/include/rpc/this_session.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/host/lib/deps/rpclib/include/rpc/this_session.h b/host/lib/deps/rpclib/include/rpc/this_session.h
new file mode 100644
index 000000000..d391c1838
--- /dev/null
+++ b/host/lib/deps/rpclib/include/rpc/this_session.h
@@ -0,0 +1,44 @@
+#pragma once
+
+#ifndef THIS_SESSION_H_HTS95N7G
+#define THIS_SESSION_H_HTS95N7G
+
+#include <atomic>
+#include "rpc/config.h"
+
+namespace rpc {
+
+namespace detail {
+class server_session;
+}
+
+//! \brief Encapsulates information about the server session/connection
+//! this handler is running in. This is the interface through which bound
+//! functions may interact with the session.
+//! \note Accessing the this_session() object is thread safe, but incurs some
+//! syncrhonization cost in the form of atomic flags. (usually not a concern)
+class this_session_t {
+public:
+ //! \brief Gracefully exits the session (i.e. ongoing writes and reads are
+ //! completed; queued writes and reads are not).
+ //! \note Use this function if you need to close the connection from a
+ //! handler.
+ void post_exit();
+
+ friend class rpc::detail::server_session;
+
+private:
+ void clear();
+
+ std::atomic_bool exit_{false};
+};
+
+//! \brief A thread-local object that can be used to control the currently
+//! active server session.
+//! \note Accessing this object outside of handlers while a server is
+//! running is potentially unsafe.
+this_session_t &this_session();
+
+} /* rpc */
+
+#endif /* end of include guard: THIS_SESSION_H_HTS95N7G */