Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
potential 2.1.0
Borrowing for futures - a bit like Option
, but async and with a return channel.
A bit like a Mutex
, compensating for MutexGuard
not being safe to send.
The item is moved (leased) from the owner Potential into the Lease.
When the Lease is dropped, the item is sent back to the owner.
Owner of the Potential can await the return of the leased item.
It is geared towards asynchronous servers. The use case is that some resources can or should be reused, such as TCP connections or crypto configuration or backend storage but they need to be sent off with futures where there is no track of the future of the shared resource unless &mut is used so single copy is guaranteed, Mutex is used with a lifetime bound for the future or you use Potential which allows you not to bind the future lifetime to the source. Still, only one running future/task can use the resource at a time. The owner can thus control the concurrency which is by default 1 and can be increased by resetting the Potential to a new value.
If the lease is not dropped properly (such as if you mem::forget()
it
or when its thread panics badly), the Potential
calls will be stuck forever.
If you suspect that this may happen, await with a timeout to be able to recover.
Sync + Send future example
Notice the mutation of String through immutable reference, initializing the potential through a lease, and that futures are Sync + Send. Futures on a lease naturally serialize (are mutually exclusive).
use Potential;
use Future;
use Poll;
use Pin;
async
let trial = default;
let mut fut = test;
assert_eq!;
is_sync_and_send;
;
;
Example: 'static + Sync + Send future with Arc
Not sure how to pull this off with async fn sugar. Suggestions welcome. Self must not be captured by the future for this to work.
use Potential;
use Arc;
use Future;
let trial = default;
let fut = trial.back_to_the_static_future;
is_sync_and_send_and_static;
;
License
MIT OR Apache-2.0
Contribution
Unless you explicitly state otherwise, any contribution submitted for inclusion in samotop projects by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.