acme
Foundational cross-platform layer of the ca2 framework
Toggle main menu visibility
Loading...
Searching...
No Matches
synchronously_keep_bit.h
1
// Created by camilo on 2021-09-06 14:37 BRT <3ThomasBS_!!
2
#pragma once
3
4
5
#include "acme/parallelization/synchronous_lock.h"
6
7
8
template
<
typename
TYPE >
9
class
___synchronously_keep_bit :
10
public
set_bit < TYPE >
11
{
12
public
:
13
14
15
::matter
* m_pmatterLock;
16
bool
m_bKeepValue;
17
bool
m_bKeepAwayValue;
18
bool
m_bKept;
19
20
21
___synchronously_keep_bit(
::matter
* pmatterLock, TYPE & field, ::u64 mask,
bool
bKeepValue) :
22
___synchronously_keep_bit(pmatterLock, field, mask, bKeepValue, (field & mask) == mask) {}
23
24
___synchronously_keep_bit(
::matter
* pmatterLock, TYPE & field, ::u64 mask,
bool
bKeepValue,
bool
bKeepAwayValue) :
25
set_bit < TYPE > (field.eflag(), mask), m_pmatterLock(pmatterLock), m_bKeepValue(bKeepValue), m_bKeepAwayValue(bKeepAwayValue), m_bKept(
false
)
26
{
27
28
keep();
29
30
}
31
32
~___synchronously_keep_bit()
33
{
34
35
keep_away();
36
37
}
38
39
40
void
keep()
41
{
42
43
if
(m_bKept)
44
{
45
46
return
;
47
48
}
49
50
m_bKept =
true
;
51
52
_synchronous_lock
synchronouslock(m_pmatterLock->synchronization(), m_pmatterLock, SYNCHRONOUS_LOCK_SUFFIX);
53
54
this->set(m_bKeepValue);
55
56
}
57
58
59
void
keep_away()
60
{
61
62
if
(!m_bKept)
63
{
64
65
return
;
66
67
}
68
69
m_bKept =
false
;
70
71
_synchronous_lock
synchronouslock(m_pmatterLock->synchronization(), m_pmatterLock, SYNCHRONOUS_LOCK_SUFFIX);
72
73
this->set(m_bKeepAwayValue);
74
75
}
76
77
78
};
79
80
81
template
<
typename
TYPE >
82
auto
synchronously_keep_bit(
::matter
* pmatterLock, TYPE & field, ::u64 mask,
bool
bKeepValue)
83
{
84
85
return
___synchronously_keep_bit < TYPE >(pmatterLock, field, mask, bKeepValue);
86
87
}
88
89
90
template
<
typename
TYPE >
91
auto
synchronously_keep_bit(
::matter
* pmatterLock, TYPE & field, ::u64 mask,
bool
bKeepValue,
bool
bKeepAwayValue)
92
{
93
94
return
___synchronously_keep_bit < TYPE >(pmatterLock, field, mask, bKeepValue, bKeepAwayValue);
95
96
}
97
98
99
_synchronous_lock
Definition
synchronous_lock.h:31
matter
Definition
matter.h:17
parallelization
synchronously_keep_bit.h
Generated by
1.17.0