Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
quasar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jens Nolte
quasar
Commits
0f4d066d
Commit
0f4d066d
authored
3 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Change TIOWorker to use TQueue
parent
3d786053
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Quasar/Async/STMHelper.hs
+7
-7
7 additions, 7 deletions
src/Quasar/Async/STMHelper.hs
with
7 additions
and
7 deletions
src/Quasar/Async/STMHelper.hs
+
7
−
7
View file @
0f4d066d
...
@@ -14,13 +14,13 @@ import Quasar.Exceptions
...
@@ -14,13 +14,13 @@ import Quasar.Exceptions
import
Quasar.Prelude
import
Quasar.Prelude
newtype
TIOWorker
=
TIOWorker
(
T
MVar
(
IO
()
))
newtype
TIOWorker
=
TIOWorker
(
T
Queue
(
IO
()
))
startTrivialIO
::
forall
a
.
TIOWorker
->
ExceptionChannel
->
IO
a
->
STM
(
Awaitable
a
)
startTrivialIO
::
forall
a
.
TIOWorker
->
ExceptionChannel
->
IO
a
->
STM
(
Awaitable
a
)
startTrivialIO
(
TIOWorker
job
Var
)
exChan
fn
=
do
startTrivialIO
(
TIOWorker
job
Queue
)
exChan
fn
=
do
resultVar
<-
newAsyncVarSTM
resultVar
<-
newAsyncVarSTM
putTMVar
jobVar
$
job
resultVar
writeTQueue
jobQueue
$
job
resultVar
pure
$
toAwaitable
resultVar
pure
$
toAwaitable
resultVar
where
where
job
::
AsyncVar
a
->
IO
()
job
::
AsyncVar
a
->
IO
()
...
@@ -37,11 +37,11 @@ startTrivialIO_ x y z = void $ startTrivialIO x y z
...
@@ -37,11 +37,11 @@ startTrivialIO_ x y z = void $ startTrivialIO x y z
newTIOWorker
::
IO
TIOWorker
newTIOWorker
::
IO
TIOWorker
newTIOWorker
=
do
newTIOWorker
=
do
job
Var
<-
new
EmptyTMVar
IO
job
Queue
<-
new
TQueue
IO
void
$
forkIO
$
void
$
forkIO
$
handle
catch
(
forever
$
join
$
atomically
$
readTQueue
jobQueue
)
-- Relies on garbage collection to remove the thread when it is no longer needed
-- Relies on garbage collection to remove the thread when it is no longer needed
(
\
(
_
::
BlockedIndefinitelyOnSTM
)
->
pure
()
)
(
\
(
_
::
BlockedIndefinitelyOnSTM
)
->
pure
()
)
(
forever
$
join
$
atomically
$
takeTMVar
jobVar
)
pure
$
TIOWorker
job
Var
pure
$
TIOWorker
job
Queue
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment