-
Notifications
You must be signed in to change notification settings - Fork 11
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
Concurrency primitimes and thread safety #34
Comments
Another problem with the greatEscape :: IO ()
greatEscape = do
hSetBuffering stdout LineBuffering
res <- runEff . runConcurrent $ do
_ <- async $ do
liftIO $ forever do
print "still alive"
threadDelay 2_000
return "eff done"
print res
threadDelay 10_000 This is mentioned in the documentation, but I don't think it's necessary as a primitive, it can be done with Speaking of which, I did some experiments with Ki. The Naive version just exposes that this is This is my current best idea, with explicit |
Thanks! I have some ideas forthcoming about structured concurrency in Bluefin which give thread safety by construction, so watch this space. I have some concerns about the ki API, but think I have worked out how to make it type safe with Bluefin. |
Oh, for the record, this doesn't with my wrapper. useFile = runEff \io -> do
runScope io \scope -> do
_ <- BIO.withFile io "/dev/null" WriteMode \h -> do
_ <- forkWithNewEff scope do
BIO.hPutStr h "foo"
-- • Ambiguous type variable ‘forkEs0’ arising from a use of ‘BIO.hPutStr’
-- prevents the constraint ‘(e2 :> forkEs0)’ from being solved.
pure ()
pure () But to be fair, nothing works. Anyway looking forward to what is cooking! |
You can have a look at branch The thread safety story is this:
If you're feeling adventurous you might want to check it out. I envisage writing up a better explanation over the coming weeks. |
We don't have any Bluefin-specific concurrency primitives and just rely on
MonadUnliftIO
to give us access toIO
currency primitives. This seems dangerous, firstly in light of #29, but also because we could actually use Bluefin's type system to forbid thread-unsafe access to resources.By way of comparison, effectful seems fairly lax. See haskell-effectful/effectful#292.
The text was updated successfully, but these errors were encountered: