rippled
Loading...
Searching...
No Matches
BasicApp.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_APP_BASICAPP_H_INCLUDED
21#define RIPPLE_APP_BASICAPP_H_INCLUDED
22
23#include <boost/asio/io_context.hpp>
24
25#include <optional>
26#include <thread>
27#include <vector>
28
29// This is so that the io_context can outlive all the children
31{
32private:
33 std::optional<boost::asio::executor_work_guard<
34 boost::asio::io_context::executor_type>>
37 boost::asio::io_context io_context_;
38
39public:
40 BasicApp(std::size_t numberOfThreads);
41 ~BasicApp();
42
43 boost::asio::io_context&
45 {
46 return io_context_;
47 }
48};
49
50#endif
boost::asio::io_context io_context_
Definition BasicApp.h:37
std::vector< std::thread > threads_
Definition BasicApp.h:36
boost::asio::io_context & get_io_context()
Definition BasicApp.h:44
std::optional< boost::asio::executor_work_guard< boost::asio::io_context::executor_type > > work_
Definition BasicApp.h:35