Skip to content

Conversation

diesalbla
Copy link
Contributor

The takeToken method uses the Ref.access method, which yields a setter. The setter yields true if it can set the value, or false if it could not, perhaps because of a concurrent write. In the latter case, the method has to re-try.

Currently, that recursion goes through emitting an Option and flatMap. This commit changes that to a direct recursive call.

@mergify mergify bot added series/0.23 PRs targeting 0.23.x module:server labels Apr 9, 2022
@diesalbla diesalbla force-pushed the no_option_just_loop branch from 4e6ffad to f23c0ed Compare April 9, 2022 03:25
@diesalbla diesalbla changed the title Throttle Server middleware: Throttle Server middleware: use recursion Apr 9, 2022
The `takeToken` method uses the Ref.access method, which yields a
setter that yields true if it can set the value, or false if it
cannot, maybe because of a concurrent write. In the latter case,
the method has to re-try by using a recursive call to `takeToken`.

Currently, that recursion goes through emitting an Option and
flatMapping. This commit changes that to a direct call.
@diesalbla diesalbla force-pushed the no_option_just_loop branch from 2dcab45 to c9ec045 Compare April 9, 2022 21:39
Copy link
Member

@rossabaker rossabaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup.

@rossabaker rossabaker added the behind-the-scenes Appreciated, but not user-facing label Jun 4, 2022
@rossabaker rossabaker merged commit 820656a into http4s:series/0.23 Jun 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
behind-the-scenes Appreciated, but not user-facing module:server series/0.23 PRs targeting 0.23.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants