Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
queuing_mutex.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2005-2019 Intel Corporation
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 #ifndef __TBB_queuing_mutex_H
18 #define __TBB_queuing_mutex_H
19 
20 #include <cstring>
21 #include "atomic.h"
22 #include "tbb_profiling.h"
23 
24 namespace tbb {
25 
27 
28 class queuing_mutex : internal::mutex_copy_deprecated_and_disabled {
29 public:
32  q_tail = NULL;
33 #if TBB_USE_THREADING_TOOLS
35 #endif
36  }
37 
39 
41  class scoped_lock: internal::no_copy {
43  void initialize() {
44  mutex = NULL;
45  going = 0;
46 #if TBB_USE_ASSERT
48 #endif /* TBB_USE_ASSERT */
49  }
50 
51  public:
53 
55 
58  initialize();
59  acquire(m);
60  }
61 
64  if( mutex ) release();
65  }
66 
69 
72 
75 
76  private:
79 
82 
84 
87  uintptr_t going;
88  };
89 
91 
92  // Mutex traits
93  static const bool is_rw_mutex = false;
94  static const bool is_recursive_mutex = false;
95  static const bool is_fair_mutex = true;
96 
97 private:
100 
101 };
102 
104 
105 } // namespace tbb
106 
107 #endif /* __TBB_queuing_mutex_H */
#define __TBB_DEFINE_PROFILING_SET_NAME(sync_object_type)
queuing_mutex * mutex
The pointer to the mutex owned, or NULL if not holding a mutex.
Definition: queuing_mutex.h:78
void __TBB_EXPORTED_METHOD acquire(queuing_mutex &m)
Acquire lock on given mutex.
uintptr_t going
The local spin-wait variable.
Definition: queuing_mutex.h:87
atomic< scoped_lock * > q_tail
The last competitor requesting the lock.
Definition: queuing_mutex.h:99
static const bool is_recursive_mutex
Definition: queuing_mutex.h:94
scoped_lock(queuing_mutex &m)
Acquire lock on given mutex.
Definition: queuing_mutex.h:57
#define __TBB_EXPORTED_METHOD
Definition: tbb_stddef.h:98
static const bool is_fair_mutex
Definition: queuing_mutex.h:95
queuing_mutex()
Construct unacquired mutex.
Definition: queuing_mutex.h:31
void poison_pointer(T *__TBB_atomic &)
Definition: tbb_stddef.h:305
Primary template for atomic.
Definition: atomic.h:403
The graph class.
Queuing mutex with local-only spinning.
Definition: queuing_mutex.h:28
void __TBB_EXPORTED_METHOD release()
Release lock.
scoped_lock * next
The pointer to the next competitor for a mutex.
Definition: queuing_mutex.h:81
void __TBB_EXPORTED_METHOD internal_construct()
~scoped_lock()
Release lock (if lock is held).
Definition: queuing_mutex.h:63
void initialize()
Initialize fields to mean "no lock held".
Definition: queuing_mutex.h:43
Wrapper around the platform's native lock.
Definition: mutex.h:35
scoped_lock()
Construct lock that has not acquired a mutex.
Definition: queuing_mutex.h:54
The scoped locking pattern.
Definition: queuing_mutex.h:41
static const bool is_rw_mutex
Definition: queuing_mutex.h:93
bool __TBB_EXPORTED_METHOD try_acquire(queuing_mutex &m)
Acquire lock on given mutex if free (i.e. non-blocking)

Copyright © 2005-2019 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.