This repository was archived by the owner on Oct 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 205
Refactor DispatcherEnv our of the Reactor #864
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cad0a94
Refactor parts of the Dispatcher out to a Scheduler module
lorenzo 6bcf940
Fixed dispatcher tests
lorenzo 716510b
Documenting the Scheduler module
lorenzo 198b2a0
Documenting some other functions
lorenzo 98284d9
Fixed Architecture docs
lorenzo 142419b
Moving all of the Dispatcher into the new Scheduler module
lorenzo 25e0fb7
Merge branch 'master' into refactor-dispatcher
lorenzo 5fb25f3
Merge remote-tracking branch 'origin/master' into refactor-dispatcher
lorenzo 49e7875
Moving some more functions to the Scheduler module
lorenzo 3eae057
Merge remote-tracking branch 'origin/master' into refactor-dispatcher
lorenzo 339224f
commenting out test code to debug circleci
lorenzo 1d44a0d
Revert "commenting out test code to debug circleci"
lorenzo 4901968
Only one thread for tests
lorenzo 9e22aa6
Splitting tests into another package to avoid race condition
lorenzo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,52 @@ | ||
module Haskell.Ide.Engine.Channel | ||
( InChan | ||
, OutChan | ||
, newChan | ||
, newChanSTM | ||
, readChan | ||
, readChanSTM | ||
, writeChan | ||
, writeChanSTM | ||
) | ||
where | ||
|
||
import qualified Control.Concurrent.STM.TChan as TChan | ||
import qualified Control.Concurrent.STM as STM | ||
|
||
-- | The writing end of a STM channel, only values of type 'a' cam be written | ||
-- to the channel | ||
newtype InChan a = InChan (TChan.TChan a) | ||
|
||
-- | The reading end of a STM channel, values of type 'a' can be expected to | ||
-- be read. | ||
newtype OutChan a = OutChan (TChan.TChan a) | ||
|
||
-- | Returns the reading and writing ends of a channel able to trasmit values of | ||
-- a single given type | ||
newChan :: IO (InChan a, OutChan a) | ||
newChan = STM.atomically newChanSTM | ||
|
||
-- | STM version of 'newChan', useful for chaining many STM calls inside a single | ||
-- 'atomically' block. | ||
newChanSTM :: STM.STM (InChan a, OutChan a) | ||
newChanSTM = do | ||
chan <- TChan.newTChan | ||
return (InChan chan, OutChan chan) | ||
|
||
-- | Consumes and returns the next value of the given channel | ||
readChan :: OutChan a -> IO a | ||
readChan = STM.atomically . readChanSTM | ||
|
||
-- | STM version of 'readChan', useful for chaining many STM calls inside a single | ||
-- 'atomically' block. | ||
readChanSTM :: OutChan a -> STM.STM a | ||
readChanSTM (OutChan chan) = STM.readTChan chan | ||
|
||
-- | Writes a value to a channel. | ||
writeChan :: InChan a -> a -> IO () | ||
writeChan chan val = STM.atomically (writeChanSTM chan val) | ||
|
||
-- | STM version of 'writeChan', useful for chaining many STM calls inside a single | ||
-- 'atomically' block. | ||
writeChanSTM :: InChan a -> a -> STM.STM () | ||
writeChanSTM (InChan chan) = STM.writeTChan chan |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line could be moved out of the if statement, it is in both legs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is possible since
scheduler
is parameterised for a different base monad on each leg, so the type ofscheduler
can only be determined after choosing what leg of theif
to follow