|
||||
File indexing completed on 2025-01-30 09:31:55
0001 /* 0002 * Copyright 2017 The Abseil Authors. 0003 * 0004 * Licensed under the Apache License, Version 2.0 (the "License"); 0005 * you may not use this file except in compliance with the License. 0006 * You may obtain a copy of the License at 0007 * 0008 * https://www.apache.org/licenses/LICENSE-2.0 0009 * 0010 * Unless required by applicable law or agreed to in writing, software 0011 * distributed under the License is distributed on an "AS IS" BASIS, 0012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0013 * See the License for the specific language governing permissions and 0014 * limitations under the License. 0015 */ 0016 0017 // Interface for getting the current ThreadIdentity, creating one if necessary. 0018 // See thread_identity.h. 0019 // 0020 // This file is separate from thread_identity.h because creating a new 0021 // ThreadIdentity requires slightly higher level libraries (per_thread_sem 0022 // and low_level_alloc) than accessing an existing one. This separation allows 0023 // us to have a smaller //absl/base:base. 0024 0025 #ifndef ABSL_SYNCHRONIZATION_INTERNAL_CREATE_THREAD_IDENTITY_H_ 0026 #define ABSL_SYNCHRONIZATION_INTERNAL_CREATE_THREAD_IDENTITY_H_ 0027 0028 #include "absl/base/internal/thread_identity.h" 0029 #include "absl/base/port.h" 0030 0031 namespace absl { 0032 ABSL_NAMESPACE_BEGIN 0033 namespace synchronization_internal { 0034 0035 // Allocates and attaches a ThreadIdentity object for the calling thread. 0036 // For private use only. 0037 base_internal::ThreadIdentity* CreateThreadIdentity(); 0038 0039 // Returns the ThreadIdentity object representing the calling thread; guaranteed 0040 // to be unique for its lifetime. The returned object will remain valid for the 0041 // program's lifetime; although it may be re-assigned to a subsequent thread. 0042 // If one does not exist for the calling thread, allocate it now. 0043 inline base_internal::ThreadIdentity* GetOrCreateCurrentThreadIdentity() { 0044 base_internal::ThreadIdentity* identity = 0045 base_internal::CurrentThreadIdentityIfPresent(); 0046 if (ABSL_PREDICT_FALSE(identity == nullptr)) { 0047 return CreateThreadIdentity(); 0048 } 0049 return identity; 0050 } 0051 0052 } // namespace synchronization_internal 0053 ABSL_NAMESPACE_END 0054 } // namespace absl 0055 0056 #endif // ABSL_SYNCHRONIZATION_INTERNAL_CREATE_THREAD_IDENTITY_H_
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |