2 Copyright (c) 2005-2017 Intel Corporation
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
8 http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include "tbb/tbb_machine.h"
22 #include "tbb/spin_mutex.h"
23 #include "itt_notify.h"
28 void spin_mutex::scoped_lock::internal_acquire( spin_mutex& m ) {
29 __TBB_ASSERT( !my_mutex, "already holding a lock on a spin_mutex" );
30 ITT_NOTIFY(sync_prepare, &m);
31 __TBB_LockByte(m.flag);
33 ITT_NOTIFY(sync_acquired, &m);
36 void spin_mutex::scoped_lock::internal_release() {
37 __TBB_ASSERT( my_mutex, "release on spin_mutex::scoped_lock that is not holding a lock" );
39 ITT_NOTIFY(sync_releasing, my_mutex);
40 __TBB_UnlockByte(my_mutex->flag);
44 bool spin_mutex::scoped_lock::internal_try_acquire( spin_mutex& m ) {
45 __TBB_ASSERT( !my_mutex, "already holding a lock on a spin_mutex" );
46 bool result = bool( __TBB_TryLockByte(m.flag) );
49 ITT_NOTIFY(sync_acquired, &m);
54 void spin_mutex::internal_construct() {
55 ITT_SYNC_CREATE(this, _T("tbb::spin_mutex"), _T(""));