Bug fix: pidControlLoop may loop infinitely.

boost::basic_waitable_timer::cancel is a non-blocking function and only
sends cancellation to the pending operations. For other operations:
```
If the timer has already expired when cancel() is called, then the
handlers for asynchronous wait operations will:
* have already been invoked; or
* have been queued for invocation in the near future.
These handlers can no longer be cancelled, and therefore are passed an
error code that indicates the successful completion of the wait
operation.
```

In our case, if pidControlLoop() has been invoked or in the invoke
queue while the timer cancellation, it will ignore the cancal ec and
infinitely call the pidControlLoop() chain.

Thus an extra cancel variable is introduced to break the chain.

Signed-off-by: Hao Jiang <jianghao@google.com>
Change-Id: Ie4e53454ee326bdf612abb511990610a6b528300
diff --git a/pid/pidloop.hpp b/pid/pidloop.hpp
index b7d1b34..f9b78b3 100644
--- a/pid/pidloop.hpp
+++ b/pid/pidloop.hpp
@@ -14,11 +14,14 @@
  *
  * @param[in] zone - ptr to the ZoneInterface implementation for this loop.
  * @param[in] timer - boost timer used for async callback.
+ * @param[in] isCanceling - bool ptr to indicate whether pidControlLoop is being
+ * canceled.
  * @param[in] first - boolean to denote if initialization needs to be run.
  * @param[in] ms100cnt - loop timer counter.
  */
 void pidControlLoop(std::shared_ptr<ZoneInterface> zone,
                     std::shared_ptr<boost::asio::steady_timer> timer,
-                    bool first = true, int ms100cnt = 0);
+                    const bool* isCanceling, bool first = true,
+                    int ms100cnt = 0);
 
 } // namespace pid_control