Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
gershomb
GHC
Commits
448fd22d
Commit
448fd22d
authored
4 years ago
by
Marcin Szamotulski
Committed by
Marge Bot
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Apply 1 suggestion(s) to 1 file(s)
parent
4b068fc3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libraries/base/Control/Exception/Base.hs
+15
-7
15 additions, 7 deletions
libraries/base/Control/Exception/Base.hs
with
15 additions
and
7 deletions
libraries/base/Control/Exception/Base.hs
+
15
−
7
View file @
448fd22d
...
...
@@ -214,13 +214,21 @@ onException io what = io `catch` \e -> do _ <- what
--
-- > withFile name mode = bracket (openFile name mode) hClose
--
-- Implementation of bracket is using 'mask', which means that the release
-- handler should be uninterruptible to run to completion in presence of
-- asynchronous exceptions. 'hClose' is uninterruptible if used
-- non-concurrently, closing a socket (from \"network\" package) is
-- uninterruptible as well, an example of interruptible close handler is
-- 'killThread' which should be wrapped using 'uninterruptibleMask_' when used
-- with 'bracket'. Comments in 'uninterruptibleMask' still aply.
-- Bracket wraps the release action with 'mask', which is sufficient to ensure
-- that the release action executes to completion when it does not invoke any
-- interruptible actions, even in the presence of asynchronous exceptions. For
-- example, `hClose` is uninterruptible when it is not racing other uses of the
-- handle. Similarly, closing a socket (from \"network\" package) is also
-- uninterruptible under similar conditions. An example of an interruptible
-- action is 'killThread'. Completion of interruptible release actions can be
-- ensured by wrapping them in in 'uninterruptibleMask_', but this risks making
-- the program non-responsive to @Control-C@, or timeouts. Another option is to
-- run the release action asynchronously in its own thread:
--
-- > void $ uninterruptibleMask_ $ forkIO $ do { ... }
--
-- The resource will be released as soon as possible, but the thread that invoked
-- bracket will not block in an uninterruptible state.
--
bracket
::
IO
a
-- ^ computation to run first (\"acquire resource\")
...
...
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