Added central control of threading.
This commit is contained in:
1 parent
ef3b39361a
commit
2769de6f7e
25 files changed
+259
-110
No files matched your search
@@ -7,6 +7,7 @@
|
||||
#include "defer.h"
|
||||
#include "lib/utils/bts_chrono.h"
|
||||
#include "lib/logging/logging.h"
|
||||
#include "lib/utils/thread_manager.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -83,10 +84,7 @@ void Dispatcher::run(size_t threads)
|
||||
|
||||
void Dispatcher::add_thread() {
|
||||
_me->is_pool = true;
|
||||
boost::thread t([=]() {
|
||||
os::set_thread_name("DispatcherPool");
|
||||
_me->service.run();
|
||||
});
|
||||
auto t = threading::make_thread("DispatcherPool",[=] () {_me->service.run();});
|
||||
t.detach();
|
||||
}
|
||||
|
||||
@@ -113,9 +111,8 @@ bool Dispatcher::check_access()
|
||||
|
||||
|
||||
boost::thread_specific_ptr<Dispatcher> _tl_dispatchers;
|
||||
Dispatcher& Dispatcher::current(bool set_name) {
|
||||
Dispatcher& Dispatcher::current() {
|
||||
if (_tl_dispatchers.get() == nullptr) {
|
||||
if(set_name) os::set_thread_name("Dispatcher");
|
||||
_tl_dispatchers.reset(new Dispatcher());
|
||||
}
|
||||
return *(_tl_dispatchers.get());
|
||||
@@ -153,9 +150,8 @@ Dispatcher& Dispatcher::create_new(const char* name) {
|
||||
condition_variable c;
|
||||
// Take the lock before starting the thread to ensure c.notify_all() cannot happen before we wait on the condition
|
||||
unique_lock<mutex> lock(m);
|
||||
boost::thread t([&]() {
|
||||
Dispatcher& temp = current(false);
|
||||
os::set_thread_name(name);
|
||||
auto t = threading::make_thread(name,[&]() {
|
||||
Dispatcher& temp = current();
|
||||
try {
|
||||
temp.post([&]() {
|
||||
unique_lock<mutex> lock(m);
|
||||
|
||||
Reference in new issue
Block a user