forked from glynos/cpp-netlib
-
Notifications
You must be signed in to change notification settings - Fork 424
Expand file tree
/
Copy pathsimple_sessions.hpp
More file actions
40 lines (32 loc) · 1.24 KB
/
simple_sessions.hpp
File metadata and controls
40 lines (32 loc) · 1.24 KB
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
// Copyright 2013 (c) Google, Inc.
// Copyright 2013 (c) Dean Michael Berris <dberris@google.com>
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef NETWORK_HTTP_SERVER_SIMPLE_SESSIONS_HPP_20130327
#define NETWORK_HTTP_SERVER_SIMPLE_SESSIONS_HPP_20130327
#include <unordered_map>
#include <http/server/session.hpp>
#include <boost/utility/string_ref.hpp>
#include <atomic>
#include <thread>
#include <mutex>
namespace network {
namespace http {
struct simple_sessions {
simple_sessions() = default;
simple_sessions(const simple_sessions&) = delete;
simple_sessions(simple_sessions&&) = delete;
simple_sessions& operator=(const simple_sessions&) = delete;
simple_sessions& operator=(simple_sessions&) = delete;
session lookup(boost::string_ref session_id);
void update(boost::string_ref session_id, session&& session);
private:
typedef std::unordered_map<std::string, session> session_map_type;
std::mutex sessions_mutex_;
session_map_type sessions_;
std::atomic_uint_fast64_t next_session_id_;
};
} // namespace http
} // namespace network
#endif /* end of include guard: NETWORK_HTTP_SERVER_SIMPLE_SESSIONS_HPP_20130327 */