blob: 652bc3722eeceeee3d3e013f92f63e306d3c312a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
/*
* Copyright (C) 2005-2022 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "RecursiveMutex.h"
namespace XbmcThreads
{
static pthread_mutexattr_t recursiveAttr;
static bool SetRecursiveAttr()
{
static bool alreadyCalled = false;
if (!alreadyCalled)
{
pthread_mutexattr_init(&recursiveAttr);
pthread_mutexattr_settype(&recursiveAttr, PTHREAD_MUTEX_RECURSIVE);
#if !defined(TARGET_ANDROID)
pthread_mutexattr_setprotocol(&recursiveAttr, PTHREAD_PRIO_INHERIT);
#endif
alreadyCalled = true;
}
return true; // note, we never call destroy.
}
static bool recursiveAttrSet = SetRecursiveAttr();
pthread_mutexattr_t& CRecursiveMutex::getRecursiveAttr()
{
if (!recursiveAttrSet) // this is only possible in the single threaded startup code
recursiveAttrSet = SetRecursiveAttr();
return recursiveAttr;
}
} // namespace XbmcThreads
|