Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lambda-rust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Iris
lambda-rust
Commits
f3ac56ab
There was a problem fetching the pipeline summary.
Commit
f3ac56ab
authored
8 years ago
by
Ralf Jung
Browse files
Options
Downloads
Patches
Plain Diff
Arc comments
parent
fededf8a
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
theories/lang/lib/arc.v
+10
-1
10 additions, 1 deletion
theories/lang/lib/arc.v
theories/lang/lib/lock.v
+5
-0
5 additions, 0 deletions
theories/lang/lib/lock.v
with
15 additions
and
1 deletion
theories/lang/lib/arc.v
+
10
−
1
View file @
f3ac56ab
...
...
@@ -27,6 +27,7 @@ Definition downgrade : val :=
rec
:
"downgrade"
[
"l"
]
:=
let
:
"weak"
:=
!
ˢᶜ
(
"l"
+
ₗ
#
1
)
in
if
:
"weak"
=
#
(
-1
)
then
(* -1 in weak indicates that somebody locked the counts; let's spin. *)
"downgrade"
[
"l"
]
else
if
:
CAS
(
"l"
+
ₗ
#
1
)
"weak"
(
"weak"
+
#
1
)
then
#
()
...
...
@@ -42,6 +43,9 @@ Definition upgrade : val :=
Definition
drop_weak
:
val
:=
rec
:
"drop"
[
"l"
]
:=
(* This can ignore the lock because the lock is only held when there
are no other weak refs in existence, so this code will never be called
with the lock held. *)
let
:
"weak"
:=
!
ˢᶜ
(
"l"
+
ₗ
#
1
)
in
if
:
CAS
(
"l"
+
ₗ
#
1
)
"weak"
(
"weak"
-
#
1
)
then
"weak"
=
#
1
else
"drop"
[
"l"
]
.
...
...
@@ -57,6 +61,7 @@ Definition try_unwrap : val :=
Definition
is_unique
:
val
:=
λ
:
[
"l"
],
(* Try to acquire the lock for the last ref by CASing weak count from 1 to -1. *)
if
:
CAS
(
"l"
+
ₗ
#
1
)
#
1
#
(
-1
)
then
let
:
"strong"
:=
!
ˢᶜ
"l"
in
let
:
"unique"
:=
"strong"
=
#
1
in
...
...
@@ -128,6 +133,10 @@ Section def.
End
def
.
Section
arc
.
(* P1 is the thing that is shared by strong reference owners (in practice,
this is the lifetime token), and P2 is the thing that is owned by the
protocol when only weak references are left (in practice, P2 is the
ownership of the underlying memory incl. deallocation). *)
Context
`{
!
lrustG
Σ
,
!
arcG
Σ
}
(
P1
:
Qp
→
iProp
Σ
)
{
HP1
:
Fractional
P1
}
(
P2
:
iProp
Σ
)
(
N
:
namespace
)
.
...
...
@@ -598,7 +607,7 @@ Section arc.
(* No other reference : we get everything. *)
|
0
%
nat
=>
l
↦
#
1
∗
shift_loc
l
1
↦
#
1
∗
P1
1
(* No other strong, but there are weaks : we get P1,
plus the option to get a weak if we pay P
1
. *)
plus the option to get a weak if we pay P
2
. *)
|
1
%
nat
=>
P1
1
∗
(
P2
=
{
⊤
}
=∗
weak_tok
γ
)
(* There are other strong : we get back what we gave at the first place. *)
|
_
(* 2 *)
=>
arc_tok
γ
q
∗
P1
q
...
...
This diff is collapsed.
Click to expand it.
theories/lang/lib/lock.v
+
5
−
0
View file @
f3ac56ab
...
...
@@ -11,6 +11,11 @@ Definition acquire : val :=
rec
:
"acquire"
[
"l"
]
:=
if
:
try_acquire
[
"l"
]
then
#
()
else
"acquire"
[
"l"
]
.
Definition
release
:
val
:=
λ
:
[
"l"
],
"l"
<-
ˢᶜ
#
false
.
(* It turns out that we need an accessor-based spec so that we can put the
protocol into shared borrows. Cancellable invariants don't work because
their cancelling view shift has a non-empty mask, and it would have to be
executed in the consequence view shift of a borrow. *)
(** The CMRA we need. *)
(* Not bundling heapG, as it may be shared with other users. *)
Class
lockG
Σ
:=
LockG
{
lock_tokG
:>
inG
Σ
(
exclR
unitC
)
}
.
...
...
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