Avoid the ShutDown explicit acknowledgement due to jthread already blocking on this
This commit is contained in:
parent
6239f4fc3e
commit
78528bd609
@ -84,8 +84,6 @@ class ShardManager {
|
||||
: io_(io), coordinator_leader_(coordinator_leader) {
|
||||
MG_ASSERT(shard_worker_threads >= 1);
|
||||
|
||||
shard_worker::Queue queue;
|
||||
|
||||
for (int i = 0; i < shard_worker_threads; i++) {
|
||||
shard_worker::Queue queue;
|
||||
shard_worker::ShardWorker worker{io, queue};
|
||||
@ -103,16 +101,8 @@ class ShardManager {
|
||||
ShardManager &operator=(const ShardManager &) = delete;
|
||||
|
||||
~ShardManager() {
|
||||
auto shutdown_acks = std::vector<io::Future<bool>>{};
|
||||
for (auto worker : workers_) {
|
||||
auto [future, promise] = io::FuturePromisePair<bool>();
|
||||
worker.Push(shard_worker::ShutDown{.acknowledge_shutdown = std::move(promise)});
|
||||
shutdown_acks.emplace_back(std::move(future));
|
||||
}
|
||||
|
||||
for (auto &&ack : shutdown_acks) {
|
||||
bool acked = std::move(ack).Wait();
|
||||
MG_ASSERT(acked);
|
||||
worker.Push(shard_worker::ShutDown{});
|
||||
}
|
||||
|
||||
// The jthread handes for our shard worker threads will be
|
||||
|
@ -55,9 +55,7 @@ using storage::v3::ShardRsm;
|
||||
template <typename IoImpl>
|
||||
using ShardRaft = Raft<IoImpl, ShardRsm, WriteRequests, WriteResponses, ReadRequests, ReadResponses>;
|
||||
|
||||
struct ShutDown {
|
||||
io::Promise<bool> acknowledge_shutdown;
|
||||
};
|
||||
struct ShutDown {};
|
||||
|
||||
struct Cron {};
|
||||
|
||||
@ -96,7 +94,7 @@ class Queue {
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(inner_->mu);
|
||||
|
||||
inner_->queue.push_back(std::forward<Message>(message));
|
||||
inner_->queue.emplace_back(std::forward<Message>(message));
|
||||
} // lock dropped before notifying condition variable
|
||||
|
||||
inner_->cv.notify_all();
|
||||
@ -125,10 +123,7 @@ class ShardWorker {
|
||||
Time next_cron_ = Time::min();
|
||||
std::map<uuid, ShardRaft<IoImpl>> rsm_map_;
|
||||
|
||||
bool Process(ShutDown &&shut_down) {
|
||||
shut_down.acknowledge_shutdown.Fill(true);
|
||||
return false;
|
||||
}
|
||||
bool Process(ShutDown && /* shut_down */) { return false; }
|
||||
|
||||
bool Process(Cron &&cron) {
|
||||
Cron();
|
||||
|
Loading…
Reference in New Issue
Block a user