Fix ConcurrentScheduler destructor.
This commit is contained in:
parent
172c08a991
commit
39f30f42be
@ -44,7 +44,7 @@ class ConcurrentScheduler : private Scheduler::Callback {
|
||||
|
||||
void test_one_thread_run();
|
||||
|
||||
bool is_finished() {
|
||||
bool is_finished() const {
|
||||
return is_finished_.load(std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
@ -84,10 +84,10 @@ class ConcurrentScheduler : private Scheduler::Callback {
|
||||
private:
|
||||
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_;
|
||||
std::atomic<bool> is_finished_{false};
|
||||
std::mutex at_finish_mutex_;
|
||||
std::vector<std::function<void()>> at_finish_;
|
||||
#if !TD_THREAD_UNSUPPORTED && !TD_EVENTFD_UNSUPPORTED
|
||||
std::vector<thread> threads_;
|
||||
#endif
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "td/actor/impl/EventFull.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/ExitGuard.h"
|
||||
#include "td/utils/format.h"
|
||||
#include "td/utils/List.h"
|
||||
#include "td/utils/logging.h"
|
||||
@ -245,7 +246,7 @@ void Scheduler::clear() {
|
||||
CHECK(ready_actors_list_.empty());
|
||||
poll_.clear();
|
||||
|
||||
if (callback_) {
|
||||
if (callback_ && !ExitGuard::is_exited()) {
|
||||
// can't move lambda with unique_ptr inside into std::function
|
||||
auto ptr = actor_info_pool_.release();
|
||||
callback_->register_at_finish([ptr] { delete ptr; });
|
||||
|
Loading…
Reference in New Issue
Block a user