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 
18 
19 */
20 
21 #ifndef __TBB_queuing_mutex_H
22 #define __TBB_queuing_mutex_H
23 
24 #include <cstring>
25 #include "atomic.h"
26 #include "tbb_profiling.h"
27 
28 namespace tbb {
29 
31 
32 class queuing_mutex : internal::mutex_copy_deprecated_and_disabled {
33 public:
36  q_tail = NULL;
37 #if TBB_USE_THREADING_TOOLS
39 #endif
40  }
41 
43 
45  class scoped_lock: internal::no_copy {
47  void initialize() {
48  mutex = NULL;
49  going = 0;
50 #if TBB_USE_ASSERT
52 #endif /* TBB_USE_ASSERT */
53  }
54 
55  public:
57 
59 
62  initialize();
63  acquire(m);
64  }
65 
68  if( mutex ) release();
69  }
70 
73 
76 
79 
80  private:
83 
86 
88 
91  uintptr_t going;
92  };
93 
95 
96  // Mutex traits
97  static const bool is_rw_mutex = false;
98  static const bool is_recursive_mutex = false;
99  static const bool is_fair_mutex = true;
100 
101 private:
104 
105 };
106 
108 
109 } // namespace tbb
110 
111 #endif /* __TBB_queuing_mutex_H */
Primary template for atomic.
Definition: atomic.h:407
queuing_mutex * mutex
The pointer to the mutex owned, or NULL if not holding a mutex.
Definition: queuing_mutex.h:82
The scoped locking pattern.
Definition: queuing_mutex.h:45
queuing_mutex()
Construct unacquired mutex.
Definition: queuing_mutex.h:35
static const bool is_rw_mutex
Definition: queuing_mutex.h:97
void __TBB_EXPORTED_METHOD internal_construct()
static const bool is_fair_mutex
Definition: queuing_mutex.h:99
bool __TBB_EXPORTED_METHOD try_acquire(queuing_mutex &m)
Acquire lock on given mutex if free (i.e. non-blocking)
void __TBB_EXPORTED_METHOD acquire(queuing_mutex &m)
Acquire lock on given mutex.
scoped_lock()
Construct lock that has not acquired a mutex.
Definition: queuing_mutex.h:58
atomic< scoped_lock * > q_tail
The last competitor requesting the lock.
#define __TBB_EXPORTED_METHOD
Definition: tbb_stddef.h:102
The graph class.
#define __TBB_DEFINE_PROFILING_SET_NAME(sync_object_type)
void poison_pointer(T *__TBB_atomic &)
Definition: tbb_stddef.h:309
Queuing mutex with local-only spinning.
Definition: queuing_mutex.h:32
uintptr_t going
The local spin-wait variable.
Definition: queuing_mutex.h:91
Wrapper around the platform&#39;s native lock.
Definition: mutex.h:39
static const bool is_recursive_mutex
Definition: queuing_mutex.h:98
void initialize()
Initialize fields to mean "no lock held".
Definition: queuing_mutex.h:47
scoped_lock(queuing_mutex &m)
Acquire lock on given mutex.
Definition: queuing_mutex.h:61
scoped_lock * next
The pointer to the next competitor for a mutex.
Definition: queuing_mutex.h:85
~scoped_lock()
Release lock (if lock is held).
Definition: queuing_mutex.h:67
void __TBB_EXPORTED_METHOD release()
Release lock.

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.