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
d7ea4c29
Commit
d7ea4c29
authored
3 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Use registerNewResource when creating an async
parent
7ff04621
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.hs
+6
-7
6 additions, 7 deletions
src/Quasar/Async.hs
with
6 additions
and
7 deletions
src/Quasar/Async.hs
+
6
−
7
View file @
d7ea4c29
...
...
@@ -54,10 +54,8 @@ instance IsAsyncContext UnlimitedAsyncContext where
asyncOnContextWithUnmask
UnlimitedAsyncContext
action
=
do
resourceManager
<-
askResourceManager
let
asyncContext
=
unlimitedAsyncContext
mask_
do
task
<-
forkTaskWithUnmask
(
\
unmask
->
runReaderT
(
runReaderT
(
action
(
liftUnmask
unmask
))
asyncContext
)
resourceManager
)
registerDisposable
task
pure
$
toAwaitable
task
toAwaitable
<$>
registerNewResource
do
forkTaskWithUnmask
(
\
unmask
->
runReaderT
(
runReaderT
(
action
(
liftUnmask
unmask
))
asyncContext
)
resourceManager
)
where
liftUnmask
::
(
forall
b
.
IO
b
->
IO
b
)
->
ReaderT
AsyncContext
(
ReaderT
ResourceManager
IO
)
a
->
ReaderT
AsyncContext
(
ReaderT
ResourceManager
IO
)
a
liftUnmask
unmask
innerAction
=
do
...
...
@@ -85,12 +83,13 @@ instance {-# OVERLAPPABLE #-} MonadAsync m => MonadAsync (ReaderT r m) where
-- | TODO: Documentation
--
-- The action will be run with asynchronous exceptions masked and will be passed an action that can be used unmask.
--
-- TODO change signature to `Awaitable`
-- The action will be run with asynchronous exceptions unmasked.
async
::
MonadAsync
m
=>
(
forall
f
.
MonadAsync
f
=>
f
a
)
->
m
(
Awaitable
a
)
async
action
=
asyncWithUnmask
\
unmask
->
unmask
action
-- | TODO: Documentation
--
-- The action will be run with asynchronous exceptions masked and will be passed an action that can be used to unmask.
asyncWithUnmask
::
MonadAsync
m
=>
(
forall
f
.
MonadAsync
f
=>
(
forall
a
.
f
a
->
f
a
)
->
f
r
)
->
m
(
Awaitable
r
)
asyncWithUnmask
action
=
do
asyncContext
<-
askAsyncContext
...
...
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