-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Experiment with using an onIdle like combinator in my solver.
This discovered a bug in the interpreter: issue #190.
- Loading branch information
Showing
2 changed files
with
87 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
-- Run g if f becomes idle/quiescent but not halted. Kill the whole mess when either half publishes. | ||
def ifIdle[A](f :: lambda() :: A, g :: lambda() :: A) :: A = | ||
{| | ||
Vclock(IntegerTimeOrder) >> ( | ||
(Vawait(0) >> Some(f()) ; None() ) | | ||
Vawait(1) >> Some(g()) | ||
) | ||
|} >Some(x)> x | ||
|
||
val c = Channel() | ||
|
||
def test() = | ||
--ifIdle({ c.get() }, { Println("get idle") }) | | ||
--ifIdle({ stop }, { Println("FAIL: stop idle") }) | | ||
ifIdle({ "Publish from left" }, { Println("FAIL: publication idle") }) | | ||
stop | ||
|
||
def f(n) if (n :> 0) = | ||
test() >x> Println(x) >> stop ; Println("============") >> f(n-1) | ||
|
||
f(1000) | ||
|
||
-- TODO: Once https://github.com/orc-lang/orc/issues/190 is fixed this should be made into a real regression test. | ||
-- It's not a test at the moment because I really don't want to deal with a deadlock in the testing harness. |