Skip to content

Commit a3e9c9b

Browse files
authored
Token#acquire doesn't remember the old options (#10)
It used to, but that was changed in fbf148d.
1 parent 5d9c349 commit a3e9c9b

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

‎lib/async/limiter/token.rb‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ module Async
99
module Limiter
1010
# Token that represents an acquired resource and can be used to release or re-acquire.
1111
#
12-
# Tokens provide advanced resource management by encapsulating both the acquired
13-
# resource and the acquisition options (timeout, cost, priority, etc.). This enables
14-
# re-acquisition with modified parameters while maintaining the original context.
12+
# Tokens encapsulate the acquired resource and its limiter, allowing the resource
13+
# to be released and re-acquired.
1514
#
1615
# The token automatically tracks release state using the resource itself as the
1716
# state indicator (nil = released, non-nil = acquired). A closed token also
@@ -43,6 +42,7 @@ def self.acquire(limiter, **options, &block)
4342
token.release
4443
end
4544
end
45+
4646
# Initialize a new token.
4747
# @parameter limiter [Generic] The limiter that issued this token.
4848
# @parameter resource [Object] The acquired resource.
@@ -68,15 +68,15 @@ def close
6868
@limiter = nil
6969
end
7070

71-
# Re-acquire the resource with modified options.
72-
#
73-
# This allows changing acquisition parameters (timeout, cost, priority, etc.)
74-
# while maintaining the token context. The current resource is released
75-
# and a new one is acquired with the merged options.
71+
# Re-acquire the resource.
7672
#
77-
# @parameter new_options [Hash] New acquisition options (timeout, cost, priority, etc.).
78-
# These are merged with the original options, with new options taking precedence.
79-
# @returns [Token] A new token for the re-acquired resource.
73+
# @parameter options [Hash] Acquisition options (timeout, cost, priority, etc.).
74+
# Omitted options use the limiter's defaults.
75+
# @yields {|resource| ...} Optional block executed with automatic token release.
76+
# @parameter resource [Object, nil] The acquired resource, or nil if acquisition failed.
77+
# @returns [Object, nil] The acquired resource, or nil if acquisition failed or the token is closed.
78+
# When used with a block, returns the result of the block execution unless the token is closed.
79+
# @raises [RuntimeError] If the token is already acquired.
8080
# @raises [ArgumentError] If the new cost exceeds timing strategy capacity.
8181
# @asynchronous
8282
def acquire(**options, &block)

0 commit comments

Comments
 (0)