-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b6ffeff
commit 3da2c21
Showing
3 changed files
with
34 additions
and
1 deletion.
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 @@ | ||
module Network.Socket.STM where | ||
|
||
import Control.Concurrent | ||
import Control.Concurrent.STM | ||
import Network.Socket.Types | ||
import System.Posix.Types | ||
|
||
-- | STM action to wait until the socket is ready for reading. | ||
waitReadSocketSTM :: Socket -> IO (STM ()) | ||
waitReadSocketSTM s = fst <$> waitAndCancelReadSocketSTM s | ||
|
||
-- | STM action to wait until the socket is ready for reading and STM | ||
-- action to cancel the waiting. | ||
waitAndCancelReadSocketSTM :: Socket -> IO (STM (), IO ()) | ||
waitAndCancelReadSocketSTM s = withFdSocket s $ threadWaitReadSTM . Fd | ||
|
||
-- | STM action to wait until the socket is ready for writing. | ||
waitWriteSocketSTM :: Socket -> IO (STM ()) | ||
waitWriteSocketSTM s = fst <$> waitAndCancelWriteSocketSTM s | ||
|
||
-- | STM action to wait until the socket is ready for writing and STM | ||
-- action to cancel the waiting. | ||
waitAndCancelWriteSocketSTM :: Socket -> IO (STM (), IO ()) | ||
waitAndCancelWriteSocketSTM s = withFdSocket s $ threadWaitWriteSTM . Fd |
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