Include ConcurrentScheduler separately.
This commit is contained in:
parent
45c3e28ea3
commit
6571a99b45
@ -7,6 +7,7 @@
|
|||||||
#include "td/utils/benchmark.h"
|
#include "td/utils/benchmark.h"
|
||||||
|
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
#include "td/actor/PromiseFuture.h"
|
#include "td/actor/PromiseFuture.h"
|
||||||
|
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
|
|
||||||
#include "td/db/binlog/Binlog.h"
|
#include "td/db/binlog/Binlog.h"
|
||||||
#include "td/db/binlog/ConcurrentBinlog.h"
|
#include "td/db/binlog/ConcurrentBinlog.h"
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
|
|
||||||
#include "td/net/HttpOutboundConnection.h"
|
#include "td/net/HttpOutboundConnection.h"
|
||||||
#include "td/net/HttpQuery.h"
|
#include "td/net/HttpQuery.h"
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
|
|
||||||
#include "td/net/HttpHeaderCreator.h"
|
#include "td/net/HttpHeaderCreator.h"
|
||||||
#include "td/net/HttpInboundConnection.h"
|
#include "td/net/HttpInboundConnection.h"
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
|
|
||||||
#include "td/net/HttpHeaderCreator.h"
|
#include "td/net/HttpHeaderCreator.h"
|
||||||
#include "td/net/HttpInboundConnection.h"
|
#include "td/net/HttpInboundConnection.h"
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
|
|
||||||
#include "td/net/HttpHeaderCreator.h"
|
#include "td/net/HttpHeaderCreator.h"
|
||||||
#include "td/net/HttpQuery.h"
|
#include "td/net/HttpQuery.h"
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include "td/telegram/ServerMessageId.h"
|
#include "td/telegram/ServerMessageId.h"
|
||||||
#include "td/telegram/UserId.h"
|
#include "td/telegram/UserId.h"
|
||||||
|
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
#include "td/actor/PromiseFuture.h"
|
#include "td/actor/PromiseFuture.h"
|
||||||
|
|
||||||
#include "td/db/SqliteConnectionSafe.h"
|
#include "td/db/SqliteConnectionSafe.h"
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
#include "td/actor/PromiseFuture.h"
|
#include "td/actor/PromiseFuture.h"
|
||||||
|
|
||||||
#include "td/net/HttpQuery.h"
|
#include "td/net/HttpQuery.h"
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "td/telegram/TdCallback.h"
|
#include "td/telegram/TdCallback.h"
|
||||||
|
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
|
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
#include "td/utils/crypto.h"
|
#include "td/utils/crypto.h"
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
|
|
||||||
#include "memprof/memprof.h"
|
#include "memprof/memprof.h"
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
|
|
||||||
#include "td/telegram/td_json_client.h"
|
#include "td/telegram/td_json_client.h"
|
||||||
#include "td/telegram/td_log.h"
|
#include "td/telegram/td_log.h"
|
||||||
|
@ -6,11 +6,13 @@ endif()
|
|||||||
|
|
||||||
#SOURCE SETS
|
#SOURCE SETS
|
||||||
set(TDACTOR_SOURCE
|
set(TDACTOR_SOURCE
|
||||||
td/actor/impl/ConcurrentScheduler.cpp
|
td/actor/ConcurrentScheduler.cpp
|
||||||
td/actor/impl/Scheduler.cpp
|
td/actor/impl/Scheduler.cpp
|
||||||
td/actor/MultiPromise.cpp
|
td/actor/MultiPromise.cpp
|
||||||
td/actor/Timeout.cpp
|
td/actor/Timeout.cpp
|
||||||
|
|
||||||
|
td/actor/actor.h
|
||||||
|
td/actor/ConcurrentScheduler.h
|
||||||
td/actor/impl/Actor-decl.h
|
td/actor/impl/Actor-decl.h
|
||||||
td/actor/impl/Actor.h
|
td/actor/impl/Actor.h
|
||||||
td/actor/impl/ActorId-decl.h
|
td/actor/impl/ActorId-decl.h
|
||||||
@ -19,7 +21,6 @@ set(TDACTOR_SOURCE
|
|||||||
td/actor/impl/ActorInfo.h
|
td/actor/impl/ActorInfo.h
|
||||||
td/actor/impl/EventFull-decl.h
|
td/actor/impl/EventFull-decl.h
|
||||||
td/actor/impl/EventFull.h
|
td/actor/impl/EventFull.h
|
||||||
td/actor/impl/ConcurrentScheduler.h
|
|
||||||
td/actor/impl/Event.h
|
td/actor/impl/Event.h
|
||||||
td/actor/impl/Scheduler-decl.h
|
td/actor/impl/Scheduler-decl.h
|
||||||
td/actor/impl/Scheduler.h
|
td/actor/impl/Scheduler.h
|
||||||
@ -29,7 +30,6 @@ set(TDACTOR_SOURCE
|
|||||||
td/actor/SignalSlot.h
|
td/actor/SignalSlot.h
|
||||||
td/actor/SleepActor.h
|
td/actor/SleepActor.h
|
||||||
td/actor/Timeout.h
|
td/actor/Timeout.h
|
||||||
td/actor/actor.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(TDACTOR_TEST_SOURCE
|
set(TDACTOR_TEST_SOURCE
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
|
|
||||||
#include "td/utils/logging.h"
|
#include "td/utils/logging.h"
|
||||||
#include "td/utils/Time.h"
|
#include "td/utils/Time.h"
|
||||||
|
@ -4,12 +4,7 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
#include "td/actor/impl/ConcurrentScheduler.h"
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
|
|
||||||
#include "td/actor/impl/Actor.h"
|
|
||||||
#include "td/actor/impl/ActorId.h"
|
|
||||||
#include "td/actor/impl/ActorInfo.h"
|
|
||||||
#include "td/actor/impl/Scheduler.h"
|
|
||||||
|
|
||||||
#include "td/utils/ExitGuard.h"
|
#include "td/utils/ExitGuard.h"
|
||||||
#include "td/utils/MpscPollableQueue.h"
|
#include "td/utils/MpscPollableQueue.h"
|
||||||
@ -175,4 +170,16 @@ void ConcurrentScheduler::finish() {
|
|||||||
state_ = State::Start;
|
state_ = State::Start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConcurrentScheduler::on_finish() {
|
||||||
|
is_finished_.store(true, std::memory_order_relaxed);
|
||||||
|
for (auto &it : schedulers_) {
|
||||||
|
it->wakeup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConcurrentScheduler::register_at_finish(std::function<void()> f) {
|
||||||
|
std::lock_guard<std::mutex> lock(at_finish_mutex_);
|
||||||
|
at_finish_.push_back(std::move(f));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
@ -6,7 +6,7 @@
|
|||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "td/actor/impl/Scheduler-decl.h"
|
#include "td/actor/actor.h"
|
||||||
|
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
#include "td/utils/port/thread.h"
|
#include "td/utils/port/thread.h"
|
||||||
@ -85,11 +85,11 @@ class ConcurrentScheduler : private Scheduler::Callback {
|
|||||||
enum class State { Start, Run };
|
enum class State { Start, Run };
|
||||||
State state_ = State::Start;
|
State state_ = State::Start;
|
||||||
std::mutex at_finish_mutex_;
|
std::mutex at_finish_mutex_;
|
||||||
std::vector<std::function<void()>> at_finish_; // can be used during destruction by Scheduler destructors
|
vector<std::function<void()>> at_finish_; // can be used during destruction by Scheduler destructors
|
||||||
std::vector<unique_ptr<Scheduler>> schedulers_;
|
vector<unique_ptr<Scheduler>> schedulers_;
|
||||||
std::atomic<bool> is_finished_{false};
|
std::atomic<bool> is_finished_{false};
|
||||||
#if !TD_THREAD_UNSUPPORTED && !TD_EVENTFD_UNSUPPORTED
|
#if !TD_THREAD_UNSUPPORTED && !TD_EVENTFD_UNSUPPORTED
|
||||||
std::vector<thread> threads_;
|
vector<td::thread> threads_;
|
||||||
#endif
|
#endif
|
||||||
#if TD_PORT_WINDOWS
|
#if TD_PORT_WINDOWS
|
||||||
unique_ptr<detail::Iocp> iocp_;
|
unique_ptr<detail::Iocp> iocp_;
|
||||||
@ -97,17 +97,9 @@ class ConcurrentScheduler : private Scheduler::Callback {
|
|||||||
#endif
|
#endif
|
||||||
int32 extra_scheduler_;
|
int32 extra_scheduler_;
|
||||||
|
|
||||||
void on_finish() override {
|
void on_finish() override;
|
||||||
is_finished_.store(true, std::memory_order_relaxed);
|
|
||||||
for (auto &it : schedulers_) {
|
|
||||||
it->wakeup();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void register_at_finish(std::function<void()> f) override {
|
void register_at_finish(std::function<void()> f) override;
|
||||||
std::lock_guard<std::mutex> lock(at_finish_mutex_);
|
|
||||||
at_finish_.push_back(std::move(f));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
@ -9,6 +9,5 @@
|
|||||||
#include "td/actor/impl/Actor.h"
|
#include "td/actor/impl/Actor.h"
|
||||||
#include "td/actor/impl/ActorId.h"
|
#include "td/actor/impl/ActorId.h"
|
||||||
#include "td/actor/impl/ActorInfo.h"
|
#include "td/actor/impl/ActorInfo.h"
|
||||||
#include "td/actor/impl/ConcurrentScheduler.h"
|
|
||||||
#include "td/actor/impl/EventFull.h"
|
#include "td/actor/impl/EventFull.h"
|
||||||
#include "td/actor/impl/Scheduler.h"
|
#include "td/actor/impl/Scheduler.h"
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "td/utils/tests.h"
|
#include "td/utils/tests.h"
|
||||||
|
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
#include "td/actor/Timeout.h"
|
#include "td/actor/Timeout.h"
|
||||||
|
|
||||||
using namespace td;
|
using namespace td;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "td/utils/tests.h"
|
#include "td/utils/tests.h"
|
||||||
|
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
#include "td/actor/PromiseFuture.h"
|
#include "td/actor/PromiseFuture.h"
|
||||||
|
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "td/utils/tests.h"
|
#include "td/utils/tests.h"
|
||||||
|
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
#include "td/actor/MultiPromise.h"
|
#include "td/actor/MultiPromise.h"
|
||||||
#include "td/actor/PromiseFuture.h"
|
#include "td/actor/PromiseFuture.h"
|
||||||
#include "td/actor/SleepActor.h"
|
#include "td/actor/SleepActor.h"
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "td/utils/tests.h"
|
#include "td/utils/tests.h"
|
||||||
|
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
|
|
||||||
#include "td/utils/logging.h"
|
#include "td/utils/logging.h"
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "td/db/TsSeqKeyValue.h"
|
#include "td/db/TsSeqKeyValue.h"
|
||||||
|
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
|
|
||||||
#include "td/utils/base64.h"
|
#include "td/utils/base64.h"
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "td/net/TransparentProxy.h"
|
#include "td/net/TransparentProxy.h"
|
||||||
|
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
#include "td/actor/PromiseFuture.h"
|
#include "td/actor/PromiseFuture.h"
|
||||||
|
|
||||||
#include "td/utils/base64.h"
|
#include "td/utils/base64.h"
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "td/telegram/telegram_api.h"
|
#include "td/telegram/telegram_api.h"
|
||||||
|
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
#include "td/actor/PromiseFuture.h"
|
#include "td/actor/PromiseFuture.h"
|
||||||
|
|
||||||
#include "td/db/binlog/BinlogInterface.h"
|
#include "td/db/binlog/BinlogInterface.h"
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "td/telegram/td_api.h"
|
#include "td/telegram/td_api.h"
|
||||||
|
|
||||||
#include "td/actor/actor.h"
|
#include "td/actor/actor.h"
|
||||||
|
#include "td/actor/ConcurrentScheduler.h"
|
||||||
#include "td/actor/PromiseFuture.h"
|
#include "td/actor/PromiseFuture.h"
|
||||||
|
|
||||||
#include "td/utils/base64.h"
|
#include "td/utils/base64.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user