fix cancelAllFunctions
authorTaiyuan Zhang <taiyuanz@fb.com>
Thu, 21 Apr 2016 22:42:26 +0000 (15:42 -0700)
committerFacebook Github Bot 2 <facebook-github-bot-2-bot@fb.com>
Thu, 21 Apr 2016 22:50:24 +0000 (15:50 -0700)
Summary: as titled. When I tried re-adding all functions after cancelAllFunctions, it throws error. This is because it doesn't reset currentFunction to null.

Reviewed By: jjs0

Differential Revision: D3209237

fb-gh-sync-id: 5b6e2d967fc3c0986320d23b8d61eb1bfbff8940
fbshipit-source-id: 5b6e2d967fc3c0986320d23b8d61eb1bfbff8940

folly/experimental/FunctionScheduler.cpp

index de90c4821516567f2bf3ea19d1470770262ee47b..6727ca35f8ab8e6ee0ad378a10e0f3dd8aeece0d 100644 (file)
@@ -223,6 +223,7 @@ void FunctionScheduler::cancelFunction(const std::unique_lock<std::mutex>& l,
 void FunctionScheduler::cancelAllFunctions() {
   std::unique_lock<std::mutex> l(mutex_);
   functions_.clear();
+  currentFunction_ = nullptr;
 }
 
 bool FunctionScheduler::resetFunctionTimer(StringPiece nameID) {