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

lease

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

11 releases

0.5.0 Feb 3, 2024
0.4.0 Aug 29, 2022
0.3.3 Mar 18, 2022
0.2.3 Jul 8, 2021
0.1.0 Jun 8, 2021

#58 in Caching

Download history 2/week @ 2023-12-22 97/week @ 2023-12-29 204/week @ 2024-01-05 41/week @ 2024-01-12 47/week @ 2024-01-19 154/week @ 2024-01-26 220/week @ 2024-02-02 203/week @ 2024-02-09 145/week @ 2024-02-16 185/week @ 2024-02-23 193/week @ 2024-03-01 126/week @ 2024-03-08 256/week @ 2024-03-15 480/week @ 2024-03-22 195/week @ 2024-03-29 101/week @ 2024-04-05

1,043 downloads per month

MIT/Apache

43KB
862 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–7MB
~17K SLoC