summaryrefslogtreecommitdiffstats
path: root/mojo/public/cpp/environment/lib/buffer_tls.cc
diff options
context:
space:
mode:
Diffstat (limited to 'mojo/public/cpp/environment/lib/buffer_tls.cc')
-rw-r--r--mojo/public/cpp/environment/lib/buffer_tls.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/mojo/public/cpp/environment/lib/buffer_tls.cc b/mojo/public/cpp/environment/lib/buffer_tls.cc
new file mode 100644
index 0000000..d54faba
--- /dev/null
+++ b/mojo/public/cpp/environment/lib/buffer_tls.cc
@@ -0,0 +1,37 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/public/cpp/environment/buffer_tls.h"
+
+#include <assert.h>
+
+#include "mojo/public/cpp/environment/lib/buffer_tls_setup.h"
+#include "mojo/public/cpp/utility/lib/thread_local.h"
+
+namespace mojo {
+namespace internal {
+
+static ThreadLocalPointer<Buffer> current_buffer;
+
+void SetUpCurrentBuffer() {
+ current_buffer.Allocate();
+}
+
+void TearDownCurrentBuffer() {
+ assert(!current_buffer.Get());
+ current_buffer.Free();
+}
+
+Buffer* GetCurrentBuffer() {
+ return current_buffer.Get();
+}
+
+Buffer* SetCurrentBuffer(Buffer* buf) {
+ Buffer* old_buf = current_buffer.Get();
+ current_buffer.Set(buf);
+ return old_buf;
+}
+
+} // namespace internal
+} // namespace mojo