LeechCraft
0.6.70-18808-g3467692359
Modular cross-platform feature rich live environment.
Toggle main menu visibility
Loading...
Searching...
No Matches
threadsafety.h
Go to the documentation of this file.
1
/**********************************************************************
2
* LeechCraft - modular cross-platform feature rich internet client.
3
* Copyright (C) 2006-2014 Georg Rudoy
4
*
5
* Distributed under the Boost Software License, Version 1.0.
6
* (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7
**********************************************************************/
8
9
#pragma once
10
11
#include <mutex>
12
#include "
task.h
"
13
#include "
context.h
"
14
15
namespace
LC::Util
16
{
17
template
<
typename
>
18
struct
ThreadSafetyExtension
19
{
20
static
constexpr
bool
IsLockingHandler
=
true
;
21
static
constexpr
bool
IsThreadSafe
=
true
;
22
23
mutable
std::mutex
Mutex_
;
24
25
void
lock
()
const
26
{
27
Mutex_
.lock ();
28
}
29
30
void
unlock
()
const
31
{
32
Mutex_
.unlock ();
33
}
34
};
35
36
template
<
typename
T =
void
>
37
using
ThreadSafeTask
=
Task<T, ThreadSafetyExtension>
;
38
39
template
<
typename
T =
void
>
40
using
ThreadSafeContextTask
=
Task<T, ThreadSafetyExtension, ContextExtension>
;
41
42
template
<
typename
T>
43
concept
IsThreadSafe
=
requires
{ T::IsThreadSafe; };
44
}
LC::Util::Task
Definition
task.h:151
LC::Util::IsThreadSafe
Definition
threadsafety.h:43
context.h
LC::Util
Definition
icoreproxy.h:34
LC::Util::ThreadSafeTask
Task< T, ThreadSafetyExtension > ThreadSafeTask
Definition
threadsafety.h:37
LC::Util::ThreadSafeContextTask
Task< T, ThreadSafetyExtension, ContextExtension > ThreadSafeContextTask
Definition
threadsafety.h:40
LC::Util::ThreadSafetyExtension
Definition
threadsafety.h:19
LC::Util::ThreadSafetyExtension::unlock
void unlock() const
Definition
threadsafety.h:30
LC::Util::ThreadSafetyExtension::Mutex_
std::mutex Mutex_
Definition
threadsafety.h:23
LC::Util::ThreadSafetyExtension::lock
void lock() const
Definition
threadsafety.h:25
LC::Util::ThreadSafetyExtension::IsLockingHandler
static constexpr bool IsLockingHandler
Definition
threadsafety.h:20
task.h
src
util
threads
coro
threadsafety.h
Generated by
1.17.0