Include ConcurrentScheduler separately.

This commit is contained in:
levlam 2020-11-23 03:24:36 +03:00
parent 45c3e28ea3
commit 6571a99b45
24 changed files with 42 additions and 26 deletions

View File

@ -7,6 +7,7 @@
#include "td/utils/benchmark.h"
#include "td/actor/actor.h"
#include "td/actor/ConcurrentScheduler.h"
#include "td/actor/PromiseFuture.h"
#include "td/utils/common.h"

View File

@ -5,6 +5,7 @@
// 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/db/binlog/Binlog.h"
#include "td/db/binlog/ConcurrentBinlog.h"

View File

@ -5,6 +5,7 @@
// 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/net/HttpOutboundConnection.h"
#include "td/net/HttpQuery.h"

View File

@ -5,6 +5,7 @@
// 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/net/HttpHeaderCreator.h"
#include "td/net/HttpInboundConnection.h"

View File

@ -5,6 +5,7 @@
// 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/net/HttpHeaderCreator.h"
#include "td/net/HttpInboundConnection.h"

View File

@ -5,6 +5,7 @@
// 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/net/HttpHeaderCreator.h"
#include "td/net/HttpQuery.h"

View File

@ -11,7 +11,7 @@
#include "td/telegram/ServerMessageId.h"
#include "td/telegram/UserId.h"
#include "td/actor/actor.h"
#include "td/actor/ConcurrentScheduler.h"
#include "td/actor/PromiseFuture.h"
#include "td/db/SqliteConnectionSafe.h"

View File

@ -5,6 +5,7 @@
// 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/actor/PromiseFuture.h"
#include "td/net/HttpQuery.h"

View File

@ -10,6 +10,7 @@
#include "td/telegram/TdCallback.h"
#include "td/actor/actor.h"
#include "td/actor/ConcurrentScheduler.h"
#include "td/utils/common.h"
#include "td/utils/crypto.h"

View File

@ -5,6 +5,7 @@
// 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 "memprof/memprof.h"

View File

@ -4,7 +4,7 @@
// 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)
//
#include "td/actor/actor.h"
#include "td/actor/ConcurrentScheduler.h"
#include "td/telegram/td_json_client.h"
#include "td/telegram/td_log.h"

View File

@ -6,11 +6,13 @@ endif()
#SOURCE SETS
set(TDACTOR_SOURCE
td/actor/impl/ConcurrentScheduler.cpp
td/actor/ConcurrentScheduler.cpp
td/actor/impl/Scheduler.cpp
td/actor/MultiPromise.cpp
td/actor/Timeout.cpp
td/actor/actor.h
td/actor/ConcurrentScheduler.h
td/actor/impl/Actor-decl.h
td/actor/impl/Actor.h
td/actor/impl/ActorId-decl.h
@ -19,7 +21,6 @@ set(TDACTOR_SOURCE
td/actor/impl/ActorInfo.h
td/actor/impl/EventFull-decl.h
td/actor/impl/EventFull.h
td/actor/impl/ConcurrentScheduler.h
td/actor/impl/Event.h
td/actor/impl/Scheduler-decl.h
td/actor/impl/Scheduler.h
@ -29,7 +30,6 @@ set(TDACTOR_SOURCE
td/actor/SignalSlot.h
td/actor/SleepActor.h
td/actor/Timeout.h
td/actor/actor.h
)
set(TDACTOR_TEST_SOURCE

View File

@ -5,6 +5,7 @@
// 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/utils/logging.h"
#include "td/utils/Time.h"

View File

@ -4,12 +4,7 @@
// 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)
//
#include "td/actor/impl/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/actor/ConcurrentScheduler.h"
#include "td/utils/ExitGuard.h"
#include "td/utils/MpscPollableQueue.h"
@ -175,4 +170,16 @@ void ConcurrentScheduler::finish() {
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

View File

@ -6,7 +6,7 @@
//
#pragma once
#include "td/actor/impl/Scheduler-decl.h"
#include "td/actor/actor.h"
#include "td/utils/common.h"
#include "td/utils/port/thread.h"
@ -85,11 +85,11 @@ class ConcurrentScheduler : private Scheduler::Callback {
enum class State { Start, Run };
State state_ = State::Start;
std::mutex at_finish_mutex_;
std::vector<std::function<void()>> at_finish_; // can be used during destruction by Scheduler destructors
std::vector<unique_ptr<Scheduler>> schedulers_;
vector<std::function<void()>> at_finish_; // can be used during destruction by Scheduler destructors
vector<unique_ptr<Scheduler>> schedulers_;
std::atomic<bool> is_finished_{false};
#if !TD_THREAD_UNSUPPORTED && !TD_EVENTFD_UNSUPPORTED
std::vector<thread> threads_;
vector<td::thread> threads_;
#endif
#if TD_PORT_WINDOWS
unique_ptr<detail::Iocp> iocp_;
@ -97,17 +97,9 @@ class ConcurrentScheduler : private Scheduler::Callback {
#endif
int32 extra_scheduler_;
void on_finish() override {
is_finished_.store(true, std::memory_order_relaxed);
for (auto &it : schedulers_) {
it->wakeup();
}
}
void on_finish() 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));
}
void register_at_finish(std::function<void()> f) override;
};
} // namespace td

View File

@ -9,6 +9,5 @@
#include "td/actor/impl/Actor.h"
#include "td/actor/impl/ActorId.h"
#include "td/actor/impl/ActorInfo.h"
#include "td/actor/impl/ConcurrentScheduler.h"
#include "td/actor/impl/EventFull.h"
#include "td/actor/impl/Scheduler.h"

View File

@ -10,6 +10,7 @@
#include "td/utils/tests.h"
#include "td/actor/actor.h"
#include "td/actor/ConcurrentScheduler.h"
#include "td/actor/Timeout.h"
using namespace td;

View File

@ -7,6 +7,7 @@
#include "td/utils/tests.h"
#include "td/actor/actor.h"
#include "td/actor/ConcurrentScheduler.h"
#include "td/actor/PromiseFuture.h"
#include "td/utils/common.h"

View File

@ -7,6 +7,7 @@
#include "td/utils/tests.h"
#include "td/actor/actor.h"
#include "td/actor/ConcurrentScheduler.h"
#include "td/actor/MultiPromise.h"
#include "td/actor/PromiseFuture.h"
#include "td/actor/SleepActor.h"

View File

@ -7,6 +7,7 @@
#include "td/utils/tests.h"
#include "td/actor/actor.h"
#include "td/actor/ConcurrentScheduler.h"
#include "td/utils/logging.h"

View File

@ -18,6 +18,7 @@
#include "td/db/TsSeqKeyValue.h"
#include "td/actor/actor.h"
#include "td/actor/ConcurrentScheduler.h"
#include "td/utils/base64.h"
#include "td/utils/common.h"

View File

@ -27,6 +27,7 @@
#include "td/net/TransparentProxy.h"
#include "td/actor/actor.h"
#include "td/actor/ConcurrentScheduler.h"
#include "td/actor/PromiseFuture.h"
#include "td/utils/base64.h"

View File

@ -14,6 +14,7 @@
#include "td/telegram/telegram_api.h"
#include "td/actor/actor.h"
#include "td/actor/ConcurrentScheduler.h"
#include "td/actor/PromiseFuture.h"
#include "td/db/binlog/BinlogInterface.h"

View File

@ -12,6 +12,7 @@
#include "td/telegram/td_api.h"
#include "td/actor/actor.h"
#include "td/actor/ConcurrentScheduler.h"
#include "td/actor/PromiseFuture.h"
#include "td/utils/base64.h"