Reland of New task queueing primitive for async tasks: TaskQueue.

New task queueing primitive for async tasks: TaskQueue.
TaskQueue is a new way to asynchronously execute tasks sequentially
in a thread safe manner with minimal locking.  The implementation
uses OS supported APIs to do this that are compatible with async IO
notifications from things like sockets and files.
This class is a part of rtc_base_approved, so can be used by both
the webrtc and libjingle parts of the WebRTC library.  Moving forward,
we can replace rtc::Thread and webrtc::ProcessThread with this implementation.
NOTE: It should not be assumed that all tasks that execute on a TaskQueue,
run on the same thread.  E.g. on Mac and iOS, we use GCD dispatch queues
which means that tasks might execute on different threads depending on
what's the most efficient thing to do.

TBR=perkj@webrtc.org,phoglund@webrtc.org

Review-Url: https://codereview.webrtc.org/1984503002
Cr-Commit-Position: refs/heads/master@{#12749}
diff --git a/webrtc/base/task_queue_posix.h b/webrtc/base/task_queue_posix.h
new file mode 100644
index 0000000..b677b78
--- /dev/null
+++ b/webrtc/base/task_queue_posix.h
@@ -0,0 +1,36 @@
+/*
+ *  Copyright 2016 The WebRTC Project Authors. All rights reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_BASE_TASK_QUEUE_POSIX_H_
+#define WEBRTC_BASE_TASK_QUEUE_POSIX_H_
+
+#include <pthread.h>
+
+namespace rtc {
+
+class TaskQueue;
+
+namespace internal {
+
+class AutoSetCurrentQueuePtr {
+ public:
+  explicit AutoSetCurrentQueuePtr(TaskQueue* q);
+  ~AutoSetCurrentQueuePtr();
+
+ private:
+  TaskQueue* const prev_;
+};
+
+pthread_key_t GetQueuePtrTls();
+
+}  // namespace internal
+}  // namespace rtc
+
+#endif  // WEBRTC_BASE_TASK_QUEUE_POSIX_H_