@@ -9,19 +9,20 @@ import Control.Concurrent.Strict (newBarrier, signalBarrier,
9
9
import Control.Monad (forever )
10
10
import Control.Monad.Cont (ContT (ContT ))
11
11
12
- -- Note [Serializing runs in separate thread]
13
- -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14
- -- We often want to take long-running actions using some resource that cannot be shared.
15
- -- In this instance it is useful to have a queue of jobs to run using the resource.
16
- -- Like the db writes, session loading in session loader, shake session restarts.
17
- --
18
- -- Originally we used various ways to implement this, but it was hard to maintain and error prone.
19
- -- Moreover, we can not stop these threads uniformly when we are shutting down the server.
20
- --
21
- -- `Development.IDE.Core.WorkerThread` module provides a simple api to implement this easily.
22
- -- * `withWorkerQueue`: accepts an action to run in separate thread and returns a `TQueue` to send the actions to run.
23
- -- * `awaitRunInThread` : accepts a `TQueue` and an action to run in separate thread and waits for the result.
12
+ {-
13
+ Note [Serializing runs in separate thread]
14
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15
+ We often want to take long-running actions using some resource that cannot be shared.
16
+ In this instance it is useful to have a queue of jobs to run using the resource.
17
+ Like the db writes, session loading in session loader, shake session restarts.
24
18
19
+ Originally we used various ways to implement this, but it was hard to maintain and error prone.
20
+ Moreover, we can not stop these threads uniformly when we are shutting down the server.
21
+
22
+ `Development.IDE.Core.WorkerThread` module provides a simple api to implement this easily.
23
+ * `withWorkerQueue`: accepts an action to run in separate thread and returns a `TQueue` to send the actions to run.
24
+ * `awaitRunInThread` : accepts a `TQueue` and an action to run in separate thread and waits for the result.
25
+ -}
25
26
26
27
-- | withWorkerQueue creates a new TQueue and runs the workerAction in a separate thread.
27
28
withWorkerQueue :: (t -> IO a ) -> ContT () IO (TQueue t )
0 commit comments