Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Unified Diff: mojo/public/utility/lib/thread_local.h

Issue 217443002: Mojo: Move mojo/public/utility to mojo/public/cpp/utility. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/utility/lib/thread.cc ('k') | mojo/public/utility/lib/thread_local_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/utility/lib/thread_local.h
diff --git a/mojo/public/utility/lib/thread_local.h b/mojo/public/utility/lib/thread_local.h
deleted file mode 100644
index 6cb75e1680b1a1422da42ac1494a4e9bb1167908..0000000000000000000000000000000000000000
--- a/mojo/public/utility/lib/thread_local.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// 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.
-
-#ifndef MOJO_PUBLIC_UTILITY_LIB_THREAD_LOCAL_H_
-#define MOJO_PUBLIC_UTILITY_LIB_THREAD_LOCAL_H_
-
-#ifndef _WIN32
-#include <pthread.h>
-#endif
-
-#include "mojo/public/cpp/system/macros.h"
-
-namespace mojo {
-namespace internal {
-
-// Helper functions that abstract the cross-platform APIs.
-struct ThreadLocalPlatform {
-#ifdef _WIN32
- typedef unsigned long SlotType;
-#else
- typedef pthread_key_t SlotType;
-#endif
-
- static void AllocateSlot(SlotType* slot);
- static void FreeSlot(SlotType slot);
- static void* GetValueFromSlot(SlotType slot);
- static void SetValueInSlot(SlotType slot, void* value);
-};
-
-// This class is intended to be statically allocated.
-template <typename P>
-class ThreadLocalPointer {
- public:
- ThreadLocalPointer() : slot_() {
- }
-
- void Allocate() {
- ThreadLocalPlatform::AllocateSlot(&slot_);
- }
-
- void Free() {
- ThreadLocalPlatform::FreeSlot(slot_);
- }
-
- P* Get() {
- return static_cast<P*>(ThreadLocalPlatform::GetValueFromSlot(slot_));
- }
-
- void Set(P* value) {
- ThreadLocalPlatform::SetValueInSlot(slot_, value);
- }
-
- private:
- ThreadLocalPlatform::SlotType slot_;
-};
-
-} // namespace internal
-} // namespace mojo
-
-#endif // MOJO_PUBLIC_UTILITY_LIB_THREAD_LOCAL_H_
« no previous file with comments | « mojo/public/utility/lib/thread.cc ('k') | mojo/public/utility/lib/thread_local_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698