Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
educg-net-17064-1466468
OSKernel2023-umi-3589
Commits
dccc9de1
Commit
dccc9de1
authored
2 years ago
by
PLNTRY
Committed by
Js2xxx
2 years ago
Browse files
Options
Download
Patches
Plain Diff
Fix RCU update function
parent
37ac7737
deployed
comp1
master
poll
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mizu/lib/ksync/src/rcu.rs
+3
-7
mizu/lib/ksync/src/rcu.rs
with
3 additions
and
7 deletions
+3
-7
mizu/lib/ksync/src/rcu.rs
+
3
−
7
View file @
dccc9de1
...
...
@@ -71,19 +71,15 @@ impl<T: Pointable + Send> RcuSlot<T> {
/// new data.
pub
fn
update
<
'a
,
F
>
(
&
self
,
guard
:
&
'a
Guard
,
mut
update
:
F
)
->
Option
<
RcuDropGuard
<
'a
,
T
>>
where
F
:
FnMut
(
&
'a
T
,
Option
<
T
>
)
->
Option
<
T
>
,
F
:
FnMut
(
Option
<&
T
>
,
Option
<
T
>
)
->
Option
<
T
>
,
{
// A temp slot of memory to avoid repeating allocation.
let
mut
temp
:
Option
<
Box
<
MaybeUninit
<
T
>>>
=
None
;
let
mut
current
=
self
.inner
.load_consume
(
guard
);
loop
{
let
cd
=
(
!
current
.is_null
())
.then
(||
unsafe
{
current
.deref
()
});
// Hand out the ownership of the data in `temp` if any.
let
new
=
unsafe
{
update
(
current
.deref
(),
temp
.as_ref
()
.map
(|
ptr
|
ptr
.assume_init_read
()),
)
}
?
;
let
new
=
unsafe
{
update
(
cd
,
temp
.as_ref
()
.map
(|
ptr
|
ptr
.assume_init_read
()))
}
?
;
// After that: `temp <- None | Some(Box::new(MaybeUninit::uninit()))`
// Store the ownership of the new data in `temp`.
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets