plebble
thpool.h
Go to the documentation of this file.
1 /*
2 -------------------------------------------------------------------------------
3  PLEBBLE
4 -------------------------------------------------------------------------------
5  Copyright (C) 2019-2020 KATLAS Technology. (http://katlastechnology.com)
6  Copyright (C) 2017-2020 Marcos Mayorga. (mm@mm-studios.com)
7 
8  This file is part of our Plebble(R) Platform.
9 
10  The code below cannot be copied, used for any purpose other than the one
11  agreed and/or distributed without the express permission of
12  KATLAS Technology.
13 -------------------------------------------------------------------------------
14 
15 
16 */
17 #ifndef USGOV_d0f4984484ed32b47236bc469d4f4ff73f9374b168d6bb224f3e3dd6d255c249
18 #define USGOV_d0f4984484ed32b47236bc469d4f4ff73f9374b168d6bb224f3e3dd6d255c249
19 
20 #include <thread>
21 #include <vector>
22 #include <unordered_set>
23 #include <us/gov/config.h>
24 #include <condition_variable>
25 #include <mutex>
26 #include <atomic>
27 
28 namespace us { namespace gov {
29 namespace socket {
30  using namespace std;
31 
32  struct peer_t;
33  struct daemon;
34 
35  struct thpool final:vector<thread*> {
38  ko start(size_t sz);
39  ko wait_ready(const chrono::system_clock::time_point& deadline) const;
40  void stop();
41  void join();
42  void process(peer_t*p);
43  void run();
44  void watch(ostream&) const;
45 
46  unordered_set<peer_t*> q;
47  condition_variable cv;
48  mutable mutex mx_q;
50  #if CFG_COUNTERS==1
51  struct counters_t {
52  uint32_t jobs_queued{0};
53  atomic<uint32_t> jobs_dispatched{0};
54  void dump(ostream& os) const;
55  };
56  counters_t counters;
57  #endif
58  atomic<short> resume{0};
59  mutex mx;
60  #if CFG_LOGS==1
61  string logdir;
62  #endif
63  };
64 
65 }
66 }}
67 
68 #endif
69 
us::gov::socket::client::prepare_worker_recv
void prepare_worker_recv()
us.ko
Definition: ko.java:20
us::gov::socket::thpool::cv
condition_variable cv
Definition: thpool.h:47
log_start
#define log_start
Definition: gov.h:85
us::gov::socket::thpool::run
void run()
us::gov::dfs::peer_t
relay::peer_t peer_t
Definition: daemon.h:31
us
Definition: daemon.h:22
us::gov::socket::thpool::watch
void watch(ostream &) const
unlikely
#define unlikely(x)
Definition: likely.h:30
us::gov::socket::thpool
Definition: thpool.h:35
c
us::gov::socket::thpool c
Definition: thpool.cpp:26
likely.h
us::gov::socket::thpool::stop
void stop()
us::gov::socket::thpool::join
void join()
daemon.h
thpool.h
us::gov::socket::thpool::start
ko start(size_t sz)
us::gov::socket::thpool::wait_ready
ko wait_ready(const chrono::system_clock::time_point &deadline) const
us::gov::auth::daemon
id::daemon daemon
Definition: daemon.h:25
us::gov::socket
Definition: busyled.h:23
us::gov
Definition: daemon.h:22
peer_t.h
us::gov::socket::client::refdata
string refdata() const
c
Definition: client.cpp:417
us::ok
static constexpr ko ok
Definition: ko.h:28
us::gov::socket::thpool::process
void process(peer_t *p)
us::gov::socket::thpool::thpool
thpool(daemon *d)
us::gov::socket::thpool::mx_q
mutex mx_q
Definition: thpool.h:48
us::gov::socket::peer_t
Definition: peer_t.h:28
std
Definition: app.h:380
us::gov::socket::thpool::~thpool
~thpool()
us::gov::socket::thpool::mx
mutex mx
Definition: thpool.h:59
us::gov::socket::thpool::d
daemon * d
Definition: thpool.h:49
config.h
us::gov::socket::daemon
Definition: daemon.h:32
gov.h
us::gov::socket::thpool::q
unordered_set< peer_t * > q
Definition: thpool.h:46
log
#define log
Definition: gov.h:83
us::gov::socket::client::busyrecv
atomic< int > busyrecv
Definition: client.h:101