-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(runtime): towards support for async i/o
- Loading branch information
1 parent
99ceaf5
commit 89a1a97
Showing
8 changed files
with
65 additions
and
65 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
33 changes: 0 additions & 33 deletions
33
src/runtime-prototype/src/StuntDouble/EventLoop/AsyncHandler.hs
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
src/runtime-prototype/src/StuntDouble/EventLoop/AsyncIOHandler.hs
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,22 @@ | ||
module StuntDouble.EventLoop.AsyncIOHandler where | ||
|
||
import Control.Concurrent.Async | ||
import Control.Concurrent.STM | ||
import Control.Monad | ||
import Data.List | ||
|
||
import StuntDouble.EventLoop.State | ||
import StuntDouble.EventLoop.Event | ||
|
||
------------------------------------------------------------------------ | ||
|
||
handleAsyncIO :: LoopState -> IO () | ||
handleAsyncIO ls = forever go | ||
where | ||
go = atomically $ do | ||
-- XXX: Use waitAnyCatchSTM and handle exceptions appropriately here, e.g. | ||
-- by extending `AsyncIODone` with `Fail` and `Info`. | ||
as <- readTVar (loopStateIOAsyncs ls) | ||
(a, ioResult) <- waitAnySTM as | ||
writeTBQueue (loopStateQueue ls) (AsyncIODone a ioResult) | ||
writeTVar (loopStateIOAsyncs ls) (delete a as) |
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