File: this_session.h

package info (click to toggle)
uhd 3.13.1.0-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 207,120 kB
  • sloc: cpp: 167,245; ansic: 86,841; vhdl: 53,420; python: 40,839; xml: 13,167; tcl: 5,688; makefile: 2,167; sh: 1,719; pascal: 230; csh: 94; asm: 20; perl: 11
file content (44 lines) | stat: -rw-r--r-- 1,234 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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 */