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 */
static const bool is_recursive_mutex
Definition: queuing_mutex.h:98
void __TBB_EXPORTED_METHOD release()
Release lock.
queuing_mutex()
Construct unacquired mutex.
Definition: queuing_mutex.h:35
Queuing mutex with local-only spinning.
Definition: queuing_mutex.h:32
atomic< scoped_lock * > q_tail
The last competitor requesting the lock.
~scoped_lock()
Release lock (if lock is held).
Definition: queuing_mutex.h:67
static const bool is_fair_mutex
Definition: queuing_mutex.h:99
static const bool is_rw_mutex
Definition: queuing_mutex.h:97
void initialize()
Initialize fields to mean "no lock held".
Definition: queuing_mutex.h:47
scoped_lock()
Construct lock that has not acquired a mutex.
Definition: queuing_mutex.h:58
queuing_mutex * mutex
The pointer to the mutex owned, or NULL if not holding a mutex.
Definition: queuing_mutex.h:82
void __TBB_EXPORTED_METHOD acquire(queuing_mutex &m)
Acquire lock on given mutex.
#define __TBB_EXPORTED_METHOD
Definition: tbb_stddef.h:102
bool __TBB_EXPORTED_METHOD try_acquire(queuing_mutex &m)
Acquire lock on given mutex if free (i.e. non-blocking)
The graph class.
#define __TBB_DEFINE_PROFILING_SET_NAME(sync_object_type)
void poison_pointer(T *__TBB_atomic &)
Definition: tbb_stddef.h:309
void __TBB_EXPORTED_METHOD internal_construct()
Primary template for atomic.
Definition: atomic.h:407
uintptr_t going
The local spin-wait variable.
Definition: queuing_mutex.h:91
scoped_lock(queuing_mutex &m)
Acquire lock on given mutex.
Definition: queuing_mutex.h:61
Wrapper around the platform's native lock.
Definition: mutex.h:39
The scoped locking pattern.
Definition: queuing_mutex.h:45
scoped_lock * next
The pointer to the next competitor for a mutex.
Definition: queuing_mutex.h:85

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.