Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
stm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Glasgow Haskell Compiler
Packages
stm
Commits
2575c29e
Unverified
Commit
2575c29e
authored
1 year ago
by
Ben Gamari
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #67 from konsumlamm/retry
Update documentation for `TBQueue`
parents
0b06d0da
73741627
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
Control/Concurrent/STM/TBQueue.hs
+5
-5
5 additions, 5 deletions
Control/Concurrent/STM/TBQueue.hs
with
5 additions
and
5 deletions
Control/Concurrent/STM/TBQueue.hs
+
5
−
5
View file @
2575c29e
...
...
@@ -19,7 +19,7 @@
--
-- 'TBQueue' is a bounded version of 'TQueue'. The queue has a maximum
-- capacity set when it is created. If the queue already contains the
-- maximum number of elements, then 'writeTBQueue'
block
s until an
-- maximum number of elements, then 'writeTBQueue'
retrie
s until an
-- element is removed from the queue.
--
-- The implementation is based on an array to obtain /O(1)/
...
...
@@ -109,7 +109,7 @@ newTBQueueIO size
where
size'
=
fromIntegral
size
-- | Write a value to a 'TBQueue';
block
s if the queue is full.
-- | Write a value to a 'TBQueue';
retrie
s if the queue is full.
writeTBQueue
::
TBQueue
a
->
a
->
STM
()
writeTBQueue
(
TBQueue
_
windex
elements
size
)
a
=
do
w
<-
readTVar
windex
...
...
@@ -119,7 +119,7 @@ writeTBQueue (TBQueue _ windex elements size) a = do
Just
_
->
retry
writeTVar
windex
$!
incMod
w
size
-- | Read the next value from the 'TBQueue'.
-- | Read the next value from the 'TBQueue'
; retries if the queue is empty
.
readTBQueue
::
TBQueue
a
->
STM
a
readTBQueue
(
TBQueue
rindex
_
elements
size
)
=
do
r
<-
readTVar
rindex
...
...
@@ -156,7 +156,7 @@ flushTBQueue (TBQueue _rindex windex elements size) = do
go
(
decMod
i
size
)
(
a
:
acc
)
-- | Get the next value from the @TBQueue@ without removing it,
-- retrying if the
channel
is empty.
-- retrying if the
queue
is empty.
peekTBQueue
::
TBQueue
a
->
STM
a
peekTBQueue
(
TBQueue
rindex
_
elements
_
)
=
do
r
<-
readTVar
rindex
...
...
@@ -171,7 +171,7 @@ tryPeekTBQueue :: TBQueue a -> STM (Maybe a)
tryPeekTBQueue
q
=
fmap
Just
(
peekTBQueue
q
)
`
orElse
`
pure
Nothing
-- | Put a data item back onto a channel, where it will be the next item read.
--
Block
s if the queue is full.
--
Retrie
s if the queue is full.
unGetTBQueue
::
TBQueue
a
->
a
->
STM
()
unGetTBQueue
(
TBQueue
rindex
_
elements
size
)
a
=
do
r
<-
readTVar
rindex
...
...
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