From: James Sedgwick Date: Fri, 19 Sep 2014 10:19:17 +0000 (-0700) Subject: fix occasional crash in cpu pool X-Git-Tag: v0.22.0~349 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e3e4ab20f6b07ac2c4b73d56228a0e8abeca5023;p=folly.git fix occasional crash in cpu pool Summary: need to initialize threadsToStop_ and make it signed so it doesn't underflow in rare races Test Plan: cpu pool unit tests no longer crash if run a ton of times Reviewed By: davejwatson@fb.com Subscribers: fugalh, njormrod FB internal diff: D1563524 --- diff --git a/folly/experimental/wangle/concurrent/CPUThreadPoolExecutor.h b/folly/experimental/wangle/concurrent/CPUThreadPoolExecutor.h index 210fd673..575e23c6 100644 --- a/folly/experimental/wangle/concurrent/CPUThreadPoolExecutor.h +++ b/folly/experimental/wangle/concurrent/CPUThreadPoolExecutor.h @@ -53,8 +53,8 @@ class CPUThreadPoolExecutor : public ThreadPoolExecutor { void threadRun(ThreadPtr thread) override; void stopThreads(size_t n) override; - std::atomic threadsToStop_; std::unique_ptr> taskQueue_; + std::atomic threadsToStop_{0}; }; }} // folly::wangle