11module Unfork
22 (
3- -- * Asynchronous
4- -- ** I/O
3+ -- * Asynchronous I/O
54 unforkAsyncVoidIO ,
65 unforkAsyncIO ,
7- -- ** STM
6+ Promise (.. ),
7+ -- * Asynchronous STM
88 unforkAsyncVoidSTM ,
99 unforkAsyncSTM ,
10- -- * Synchronous
10+ -- * Synchronous I/O
1111 unforkSyncIO ,
1212 unforkSyncVoidIO ,
1313 ) where
@@ -88,11 +88,11 @@ unforkAsyncVoidIO action =
8888-}
8989
9090unforkAsyncSTM ::
91- (a -> IO b )
91+ (task -> IO result )
9292 -- ^ Action that needs to be run serially
93- -> ((a -> STM (STM b )) -> IO c )
93+ -> ((task -> STM (STM result )) -> IO conclusion )
9494 -- ^ Continuation with a thread-safe version of the action
95- -> IO c
95+ -> IO conclusion
9696unforkAsyncSTM action =
9797 unforkAsync Unfork { threadSafeAction, step }
9898 where
@@ -117,11 +117,11 @@ unforkAsyncSTM action =
117117-}
118118
119119unforkAsyncIO ::
120- (a -> IO b )
120+ (task -> IO result )
121121 -- ^ Action that needs to be run serially
122- -> ((a -> IO (Promise b )) -> IO c )
122+ -> ((task -> IO (Promise result )) -> IO conclusion )
123123 -- ^ Continuation with a thread-safe version of the action
124- -> IO c
124+ -> IO conclusion
125125unforkAsyncIO action =
126126 unforkAsync Unfork { threadSafeAction, step }
127127 where
@@ -147,11 +147,11 @@ unforkAsyncIO action =
147147-}
148148
149149unforkSyncIO ::
150- (a -> IO b )
150+ (task -> IO result )
151151 -- ^ Action that needs to be run serially
152- -> ((a -> IO b ) -> IO c )
152+ -> ((task -> IO result ) -> IO conclusion )
153153 -- ^ Continuation with a thread-safe version of the action
154- -> IO c
154+ -> IO conclusion
155155unforkSyncIO action continue = do
156156 lock <- newMVar Lock
157157 continue \ x -> do
@@ -165,11 +165,11 @@ unforkSyncIO action continue = do
165165-}
166166
167167unforkSyncVoidIO ::
168- (a -> IO b )
168+ (task -> IO result )
169169 -- ^ Action that needs to be run serially
170- -> ((a -> IO () ) -> IO c )
170+ -> ((task -> IO () ) -> IO conclusion )
171171 -- ^ Continuation with a thread-safe version of the action
172- -> IO c
172+ -> IO conclusion
173173unforkSyncVoidIO action =
174174 unforkSyncIO \ x -> do
175175 _ <- action x
@@ -188,7 +188,7 @@ data Task a b = Task{ arg :: !a, resultVar :: !b }
188188
189189data Run q = Run { queue :: ! (TQueue q ), stopper :: ! (TVar Bool ) }
190190
191- data Promise a = Promise { block :: IO a , peek :: IO (Maybe a ) }
191+ data Promise result = Promise { block :: IO result , peek :: IO (Maybe result ) }
192192
193193data Lock = Lock
194194
0 commit comments