#object-pool #pool #object #async #cache

lease

Object pool that leases values and automatically returns them with async support

13 releases

new 0.5.2 Oct 28, 2024
0.5.1 Oct 28, 2024
0.5.0 Feb 3, 2024
0.4.0 Aug 29, 2022
0.1.0 Jun 8, 2021

#42 in Caching

Download history 268/week @ 2024-07-10 455/week @ 2024-07-17 684/week @ 2024-07-24 561/week @ 2024-07-31 295/week @ 2024-08-07 533/week @ 2024-08-14 491/week @ 2024-08-21 255/week @ 2024-08-28 419/week @ 2024-09-04 388/week @ 2024-09-11 484/week @ 2024-09-18 480/week @ 2024-09-25 498/week @ 2024-10-02 336/week @ 2024-10-09 497/week @ 2024-10-16 533/week @ 2024-10-23

1,920 downloads per month

MIT/Apache

42KB
860 lines

Lease

This crate provides a Pool struct that allows taking Leasees and using them. When a Lease is dropped it is automatically returned to the pool.

One nice thing about this api is that the lifetime of a Lease is not connected to the lifetime of a Pool so they can be sent across threads.

There is also an InitPool that ensures that all new leases are created the same way

A LockedPool only allows calling functions that do not add or remove any Leases

Features

  • async
    • Enables the [Pool::get()] function. Async brings a little bit of overhead to getting leases so it is behind a feature.
    • Enables the [Pool::stream()] function that allows getting a stream of leases as they become available

lib.rs:

Lease

This crate provides a Pool struct that allows taking Leasees and using them. When a Lease is dropped it is automatically returned to the pool.

One nice thing about this api is that the lifetime of a Lease is not connected to the lifetime of a Pool so they can be sent across threads.

There is also an InitPool that ensures that all new leases are created the same way

A LockedPool only allows calling functions that do not add or remove any Leases

Features

  • async
    • Enables the [Pool::get()] function. Async brings a little bit of overhead to getting leases so it is behind a feature.
    • Enables the [Pool::stream()] function that allows getting a stream of leases as they become available

Dependencies

~0.7–5MB
~17K SLoC