Skip to content

Implement blockWhenExhausted #555

@rossabaker

Description

@rossabaker

commons-pool2 functionality

In commons-pool2, borrowObject, when no object is available, it may immediately raise an error or block for a specified duration, depending on the blockWhenExhausted property.

Current behavior

keypool effectively hardcodes this to true with semantic blocking. The effect can be canceled, so the duration can be emulated with a simple Cats Effect timeout. There is not presently a way to immediately fail, similar to tryAcquire on a Semaphore.

Analysis

It is not clear why this should be a property on the pool rather than an operation on the caller. A tryTake: Resource[F, Option[Managed[F]] is a possibility.

Workarounds

timeout with a short enough duration to not introduce lag, but a long enough duration to not generate false positives.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions