Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
soulomoon committed Jun 8, 2024
2 parents c832da3 + c1b3e7d commit 6bdba37
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ghcide/src/Development/IDE/Core/WorkerThread.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ Moreover, we can not stop these threads uniformly when we are shutting down the
* `awaitRunInThread` : accepts a `TQueue` and an action to run in separate thread and waits for the result.
-}

-- | withWorkerQueue creates a new TQueue and runs the workerAction in a separate thread.
-- | 'withWorkerQueue' creates a new 'TQueue', and launches a worker
-- thread which polls the queue for requests and runs the given worker
-- function on them.
withWorkerQueue :: (t -> IO a) -> ContT () IO (TQueue t)
withWorkerQueue workerAction = ContT $ \mainAction -> do
q <- newTQueueIO
Expand All @@ -35,7 +37,8 @@ withWorkerQueue workerAction = ContT $ \mainAction -> do
l <- atomically $ readTQueue q
workerAction l

-- | awaitRunInThread run and wait for the result
-- | 'awaitRunInThread' queues up an 'IO' action to be run by a worker thread,
-- and then blocks until the result is computed.
awaitRunInThread :: TQueue (IO ()) -> IO result -> IO result
awaitRunInThread q act = do
-- Take an action from TQueue, run it and
Expand Down

0 comments on commit 6bdba37

Please sign in to comment.