#pool #object #async #cache

lease

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

10 unstable releases (3 breaking)

0.4.0 Aug 29, 2022
0.3.3 Mar 18, 2022
0.2.3 Jul 8, 2021
0.2.1 Jun 9, 2021
0.1.0 Jun 8, 2021

#731 in Asynchronous

Download history 73/week @ 2023-06-08 175/week @ 2023-06-15 110/week @ 2023-06-22 106/week @ 2023-06-29 107/week @ 2023-07-06 202/week @ 2023-07-13 156/week @ 2023-07-20 131/week @ 2023-07-27 158/week @ 2023-08-03 148/week @ 2023-08-10 97/week @ 2023-08-17 116/week @ 2023-08-24 151/week @ 2023-08-31 193/week @ 2023-09-07 215/week @ 2023-09-14 170/week @ 2023-09-21

765 downloads per month

MIT/Apache

37KB
773 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.

Features

  • async
    • Enables the Pool::get_async() function. Async brings a little bit of overhead to getting leases so it can be disabled. On by default.

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.

Features

  • async
    • Enables the [Pool::get_async()] function. Async brings a little bit of overhead to getting leases so it is behind a feature.
  • stream
    • Enables the async feature and adds the [Pool::stream()] function for creating a stream of leases that resolve anytime there is an available Lease

Dependencies

~0.7–6MB
~16K SLoC