-- Allow ThreadPoolManager tp return immediately from addTask

Summary:
- it should be possible to specify a zero timeout if the pendingTaskQueue
  is already full

Reviewed By: marc

Test Plan:
- Tested in search


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665406 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/concurrency/ThreadManager.cpp b/lib/cpp/src/concurrency/ThreadManager.cpp
index eec94be..604602e 100644
--- a/lib/cpp/src/concurrency/ThreadManager.cpp
+++ b/lib/cpp/src/concurrency/ThreadManager.cpp
@@ -421,9 +421,7 @@
     }
 
     if (pendingTaskCountMax_ > 0 && (tasks_.size() >= pendingTaskCountMax_)) {
-
-      if (canSleep()) {
-
+      if (canSleep() && timeout >= 0) {
         while (pendingTaskCountMax_ > 0 && tasks_.size() >= pendingTaskCountMax_) {
           monitor_.wait(timeout);
         }
diff --git a/lib/cpp/src/concurrency/ThreadManager.h b/lib/cpp/src/concurrency/ThreadManager.h
index 4c56461..7bca5d0 100644
--- a/lib/cpp/src/concurrency/ThreadManager.h
+++ b/lib/cpp/src/concurrency/ThreadManager.h
@@ -123,7 +123,9 @@
    * @param task  The task to queue for execution
    *
    * @param timeout Time to wait in milliseconds to add a task when a pending-task-count
-   * is specified
+   * is specified. Specific cases:
+   * timeout = 0  : Wait forever to queue task.
+   * timeout = -1 : Return immediately if pending task count exceeds specified max
    *
    * @throws TooManyPendingTasksException Pending task count exceeds max pending task count
    */