-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve active objects, restructure project
- Loading branch information
Showing
22 changed files
with
1,250 additions
and
452 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
module Examples.TestCall where | ||
|
||
open import Prelude | ||
open import Libraries.SelectiveReceive | ||
open import Libraries.Call | ||
|
||
open SelRec | ||
|
||
AddReplyMessage : MessageType | ||
AddReplyMessage = ValueType UniqueTag ∷ [ ValueType ℕ ]ˡ | ||
|
||
AddReply : InboxShape | ||
AddReply = [ AddReplyMessage ]ˡ | ||
|
||
AddMessage : MessageType | ||
AddMessage = ValueType UniqueTag ∷ ReferenceType AddReply ∷ ValueType ℕ ∷ [ ValueType ℕ ]ˡ | ||
|
||
Calculator : InboxShape | ||
Calculator = [ AddMessage ]ˡ | ||
|
||
calculatorActor : ∀ {i} → ∞ActorM (↑ i) Calculator (Lift ⊤) [] (λ _ → []) | ||
calculatorActor = loop | ||
where | ||
loop : ∀ {i} → ∞ActorM i Calculator (Lift ⊤) [] (λ _ → []) | ||
loop .force = receive ∞>>= λ { | ||
(Msg Z (tag ∷ _ ∷ n ∷ m ∷ [])) → do | ||
Z ![t: Z ] ((lift tag) ∷ [ lift (n + m) ]ᵃ ) | ||
strengthen [] | ||
loop | ||
; (Msg (S ()) _) } | ||
|
||
TestBox : InboxShape | ||
TestBox = AddReply | ||
|
||
calltestActor : ∀ {i} → ∞ActorM i TestBox (Lift ℕ) [] (λ _ → []) | ||
calltestActor .force = spawn∞ calculatorActor ∞>> do | ||
x ← call [] Z Z 0 | ||
((lift 10) ∷ [ lift 32 ]ᵃ) | ||
⊆-refl Z | ||
strengthen [] | ||
return-result x | ||
where | ||
return-result : SelRec TestBox (call-select 0 ⊆-refl Z) → | ||
∀ {i} → ∞ActorM i TestBox (Lift ℕ) [] (λ _ → []) | ||
return-result record { msg = (Msg Z (tag ∷ n ∷ [])) } = return n | ||
return-result record { msg = (Msg (S x) x₁) ; msg-ok = () } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module Examples.TestSelectiveReceive where | ||
|
||
open import Prelude | ||
open import Libraries.SelectiveReceive | ||
|
||
open SelRec | ||
|
||
BoolMessage = [ ValueType Bool ]ˡ | ||
SelectiveTestBox : InboxShape | ||
SelectiveTestBox = [ BoolMessage ]ˡ | ||
|
||
testActor : ∀ {i} → ActorM i SelectiveTestBox (Lift Bool) [] (λ _ → []) | ||
testActor = selective-receive [] only-true ∞>>= after-receive | ||
where | ||
only-true : Message SelectiveTestBox → Bool | ||
only-true (Msg Z (b ∷ [])) = b | ||
only-true (Msg (S ()) x₁) | ||
after-receive : ∀ {i} | ||
(x : SelRec SelectiveTestBox only-true) → | ||
∞ActorM i SelectiveTestBox (Lift Bool) | ||
(add-references [] (msg x) ++ waiting-refs (waiting x)) | ||
(λ _ → []) | ||
after-receive record { msg = (Msg Z (.true ∷ [])) ; msg-ok = refl } = | ||
strengthen [] >> | ||
return true | ||
after-receive record { msg = (Msg (S ()) _) } | ||
|
||
spawner : ∀ {i} → ActorM i [] ⊤₁ [] (λ _ → []) | ||
spawner = begin do | ||
spawn testActor | ||
Z ![t: Z ] [ lift true ]ᵃ | ||
strengthen [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.