Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rtfm-core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Per Lindgren
rtfm-core
Commits
f906aa20
Commit
f906aa20
authored
7 years ago
by
Per Lindgren
Browse files
Options
Downloads
Patches
Plain Diff
both claim_mut and claim_mut_new
parent
fe366fea
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib.rs
+18
-10
18 additions, 10 deletions
src/lib.rs
with
18 additions
and
10 deletions
src/lib.rs
+
18
−
10
View file @
f906aa20
...
@@ -32,10 +32,7 @@ pub unsafe trait Resource {
...
@@ -32,10 +32,7 @@ pub unsafe trait Resource {
fn
borrow
<
'cs
>
(
&
'cs
self
,
t
:
&
'cs
Threshold
)
->
&
'cs
Static
<
Self
::
Data
>
;
fn
borrow
<
'cs
>
(
&
'cs
self
,
t
:
&
'cs
Threshold
)
->
&
'cs
Static
<
Self
::
Data
>
;
/// Mutable variant of `borrow`
/// Mutable variant of `borrow`
fn
borrow_mut
<
'cs
>
(
fn
borrow_mut
<
'cs
>
(
&
'cs
mut
self
,
t
:
&
'cs
Threshold
)
->
&
'cs
mut
Static
<
Self
::
Data
>
;
&
'cs
mut
self
,
t
:
&
'cs
Threshold
,
)
->
&
'cs
mut
Static
<
Self
::
Data
>
;
/// Claims the resource data for the span of the closure `f`. For the
/// Claims the resource data for the span of the closure `f`. For the
/// duration of the closure other tasks that may access the resource data
/// duration of the closure other tasks that may access the resource data
...
@@ -48,6 +45,11 @@ pub unsafe trait Resource {
...
@@ -48,6 +45,11 @@ pub unsafe trait Resource {
fn
claim_mut
<
R
,
F
>
(
&
mut
self
,
t
:
&
mut
Threshold
,
f
:
F
)
->
R
fn
claim_mut
<
R
,
F
>
(
&
mut
self
,
t
:
&
mut
Threshold
,
f
:
F
)
->
R
where
where
F
:
FnOnce
(
&
mut
Static
<
Self
::
Data
>
,
&
mut
Threshold
)
->
R
;
F
:
FnOnce
(
&
mut
Static
<
Self
::
Data
>
,
&
mut
Threshold
)
->
R
;
/// New Mutable variant of `claim`
fn
claim_mut_new
<
R
,
F
>
(
&
mut
self
,
b
:
&
mut
bool
,
t
:
&
mut
Threshold
,
f
:
F
)
->
R
where
F
:
FnOnce
(
&
mut
Static
<
Self
::
Data
>
,
&
mut
bool
,
&
mut
Threshold
)
->
R
;
}
}
unsafe
impl
<
T
>
Resource
for
Static
<
T
>
unsafe
impl
<
T
>
Resource
for
Static
<
T
>
...
@@ -60,10 +62,7 @@ where
...
@@ -60,10 +62,7 @@ where
self
self
}
}
fn
borrow_mut
<
'cs
>
(
fn
borrow_mut
<
'cs
>
(
&
'cs
mut
self
,
_cs
:
&
'cs
Threshold
)
->
&
'cs
mut
Static
<
T
>
{
&
'cs
mut
self
,
_cs
:
&
'cs
Threshold
,
)
->
&
'cs
mut
Static
<
T
>
{
self
self
}
}
...
@@ -80,6 +79,13 @@ where
...
@@ -80,6 +79,13 @@ where
{
{
f
(
self
,
t
)
f
(
self
,
t
)
}
}
fn
claim_mut_new
<
R
,
F
>
(
&
mut
self
,
b
:
&
mut
bool
,
t
:
&
mut
Threshold
,
f
:
F
)
->
R
where
F
:
FnOnce
(
&
mut
Static
<
Self
::
Data
>
,
&
mut
bool
,
&
mut
Threshold
)
->
R
,
{
f
(
self
,
b
,
t
)
}
}
}
/// Preemption threshold token
/// Preemption threshold token
...
@@ -99,7 +105,10 @@ impl Threshold {
...
@@ -99,7 +105,10 @@ impl Threshold {
/// This API is meant to be used to create abstractions and not to be
/// This API is meant to be used to create abstractions and not to be
/// directly used by applications.
/// directly used by applications.
pub
unsafe
fn
new
(
value
:
u8
)
->
Self
{
pub
unsafe
fn
new
(
value
:
u8
)
->
Self
{
Threshold
{
value
,
_not_send
:
PhantomData
}
Threshold
{
value
,
_not_send
:
PhantomData
,
}
}
}
/// Creates a `Threshold` token with maximum value
/// Creates a `Threshold` token with maximum value
...
@@ -115,4 +124,3 @@ impl Threshold {
...
@@ -115,4 +124,3 @@ impl Threshold {
self
.value
self
.value
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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