Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
1e7df0e5
Commit
1e7df0e5
authored
Dec 29, 2018
by
Sergey Vojtovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
XID_cache_element::m_state transition to std::atomic
parent
9e37537c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
+15
-15
sql/sql_class.cc
sql/sql_class.cc
+15
-15
No files found.
sql/sql_class.cc
View file @
1e7df0e5
...
...
@@ -5599,34 +5599,34 @@ class XID_cache_element
ACQUIRED and RECOVERED flags are cleared before element is deleted from
hash in a spin loop, after last reference is released.
*/
int32
m_state
;
std
::
atomic
<
int32_t
>
m_state
;
public:
static
const
int32
ACQUIRED
=
1
<<
30
;
static
const
int32
RECOVERED
=
1
<<
29
;
XID_STATE
*
m_xid_state
;
bool
is_set
(
int32
flag
)
{
return
m
y_atomic_load32_explicit
(
&
m_state
,
MY_MEMORY_ORDER_RELAXED
)
&
flag
;
}
void
set
(
int32
flag
)
bool
is_set
(
int32
_t
flag
)
{
return
m
_state
.
load
(
std
::
memory_order_relaxed
)
&
flag
;
}
void
set
(
int32
_t
flag
)
{
DBUG_ASSERT
(
!
is_set
(
ACQUIRED
|
RECOVERED
));
m
y_atomic_add32_explicit
(
&
m_state
,
flag
,
MY_MEMORY_ORDER_RELAXED
);
m
_state
.
fetch_add
(
flag
,
std
::
memory_order_relaxed
);
}
bool
lock
()
{
int32
old
=
my_atomic_add32_explicit
(
&
m_state
,
1
,
MY_MEMORY_ORDER_ACQUIRE
);
int32
_t
old
=
m_state
.
fetch_add
(
1
,
std
::
memory_order_acquire
);
if
(
old
&
(
ACQUIRED
|
RECOVERED
))
return
true
;
unlock
();
return
false
;
}
void
unlock
()
{
m
y_atomic_add32_explicit
(
&
m_state
,
-
1
,
MY_MEMORY_ORDER_RELEASE
);
}
{
m
_state
.
fetch_sub
(
1
,
std
::
memory_order_release
);
}
void
mark_uninitialized
()
{
int32
old
=
ACQUIRED
;
while
(
!
m
y_atomic_cas32_weak_explicit
(
&
m_state
,
&
old
,
0
,
MY_MEMORY_ORDER_RELAXED
,
MY_MEMORY_ORDER_RELAXED
))
int32
_t
old
=
ACQUIRED
;
while
(
!
m
_state
.
compare_exchange_weak
(
old
,
0
,
std
::
memory_order_relaxed
,
std
::
memory_order_relaxed
))
{
old
&=
ACQUIRED
|
RECOVERED
;
(
void
)
LF_BACKOFF
();
...
...
@@ -5634,10 +5634,10 @@ class XID_cache_element
}
bool
acquire_recovered
()
{
int32
old
=
RECOVERED
;
while
(
!
m
y_atomic_cas32_weak_explicit
(
&
m_state
,
&
old
,
ACQUIRED
|
RECOVERED
,
MY_MEMORY_ORDER_RELAXED
,
MY_MEMORY_ORDER_RELAXED
))
int32
_t
old
=
RECOVERED
;
while
(
!
m
_state
.
compare_exchange_weak
(
old
,
ACQUIRED
|
RECOVERED
,
std
::
memory_order_relaxed
,
std
::
memory_order_relaxed
))
{
if
(
!
(
old
&
RECOVERED
)
||
(
old
&
ACQUIRED
))
return
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment