mirror of https://gitee.com/bigwinds/arangodb
port 3.4 change to stopBackgroundThreads. Move ClusterCommThread routines to same place in source file. (#7721)
This commit is contained in:
parent
48d2813789
commit
5153ea0807
|
@ -343,8 +343,14 @@ void ClusterComm::startBackgroundThreads() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClusterComm::stopBackgroundThreads() {
|
void ClusterComm::stopBackgroundThreads() {
|
||||||
|
// pass 1: tell all background threads to stop
|
||||||
for (ClusterCommThread * thread: _backgroundThreads) {
|
for (ClusterCommThread * thread: _backgroundThreads) {
|
||||||
thread->beginShutdown();
|
thread->beginShutdown();
|
||||||
|
} // for
|
||||||
|
|
||||||
|
// pass 2: verify each thread is stopped, wait if necessary
|
||||||
|
// (happens in destructor)
|
||||||
|
for (ClusterCommThread * thread: _backgroundThreads) {
|
||||||
delete thread;
|
delete thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -803,29 +809,6 @@ void ClusterComm::cleanupAllQueues() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ClusterCommThread::ClusterCommThread() : Thread("ClusterComm"), _cc(nullptr) {
|
|
||||||
_cc = ClusterComm::instance().get();
|
|
||||||
_communicator = std::make_shared<communicator::Communicator>();
|
|
||||||
}
|
|
||||||
|
|
||||||
ClusterCommThread::~ClusterCommThread() { shutdown(); }
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief begin shutdown sequence
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void ClusterCommThread::beginShutdown() {
|
|
||||||
// Note that this is called from the destructor of the ClusterComm singleton
|
|
||||||
// object. This means that our pointer _cc is still valid and the condition
|
|
||||||
// variable in it is still OK. However, this method is called from a
|
|
||||||
// different thread than the ClusterCommThread. Therefore we can still
|
|
||||||
// use the condition variable to wake up the ClusterCommThread.
|
|
||||||
Thread::beginShutdown();
|
|
||||||
|
|
||||||
CONDITION_LOCKER(guard, _cc->somethingToSend);
|
|
||||||
guard.signal();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief this method performs the given requests described by the vector
|
/// @brief this method performs the given requests described by the vector
|
||||||
/// of ClusterCommRequest structs in the following way: all requests are
|
/// of ClusterCommRequest structs in the following way: all requests are
|
||||||
|
@ -1333,6 +1316,29 @@ void ClusterComm::scheduleMe(std::function<void()> task) {
|
||||||
arangodb::SchedulerFeature::SCHEDULER->queue(RequestPriority::HIGH, task);
|
arangodb::SchedulerFeature::SCHEDULER->queue(RequestPriority::HIGH, task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClusterCommThread::ClusterCommThread() : Thread("ClusterComm"), _cc(nullptr) {
|
||||||
|
_cc = ClusterComm::instance().get();
|
||||||
|
_communicator = std::make_shared<communicator::Communicator>();
|
||||||
|
}
|
||||||
|
|
||||||
|
ClusterCommThread::~ClusterCommThread() { shutdown(); }
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief begin shutdown sequence
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void ClusterCommThread::beginShutdown() {
|
||||||
|
// Note that this is called from the destructor of the ClusterComm singleton
|
||||||
|
// object. This means that our pointer _cc is still valid and the condition
|
||||||
|
// variable in it is still OK. However, this method is called from a
|
||||||
|
// different thread than the ClusterCommThread. Therefore we can still
|
||||||
|
// use the condition variable to wake up the ClusterCommThread.
|
||||||
|
Thread::beginShutdown();
|
||||||
|
|
||||||
|
CONDITION_LOCKER(guard, _cc->somethingToSend);
|
||||||
|
guard.signal();
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief ClusterComm main loop
|
/// @brief ClusterComm main loop
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in New Issue