Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala Soundness scenario 10 to check for cancellation using relent() #558

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions scala-soundness/src/main/scala/EasyRacerClient.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import capricious.RandomSize
import com.sun.management.OperatingSystemMXBean
import parasite.ConcurrencyError.Reason.Timeout
import parasite.Subordinate
import soundness.*
import soundness.executives.direct
import soundness.internetAccess.enabled
Expand Down Expand Up @@ -103,16 +103,11 @@ def scenario10(scenarioUrl: Text => HttpUrl): Text raises HttpError raises Concu
val id = random[Int]()
val messageDigest = MessageDigest.getInstance("SHA-512")

def blocking: Text =
def blocking(using Subordinate): Text =
given RandomSize = (_: Random) => 512
@tailrec def digest(bytes: Array[Byte]): Text raises ConcurrencyError =
// TODO
// Per parasite README, this is supposedly how you check for cancellation:
// https://github.com/propensive/parasite?tab=readme-ov-file#cancelation
// But it doesn't appear to be implemented yet
// acquiesce() // Does not compile
if Thread.interrupted() then abort(ConcurrencyError(Timeout))
else digest(messageDigest.digest(bytes))
@tailrec def digest(bytes: Array[Byte]): Text =
relent()
digest(messageDigest.digest(bytes))

digest(IArray.genericWrapArray(random[IArray[Byte]]()).toArray)

Expand Down
Loading