3 unstable releases

0.3.0 Mar 10, 2022
0.2.1 Mar 23, 2019
0.2.0 Sep 28, 2017

#486 in Concurrency

Download history 1/week @ 2024-01-01 47/week @ 2024-01-08 116/week @ 2024-01-15 99/week @ 2024-01-22 156/week @ 2024-01-29 86/week @ 2024-02-05 116/week @ 2024-02-12 52/week @ 2024-02-19 157/week @ 2024-02-26 121/week @ 2024-03-04 120/week @ 2024-03-11 224/week @ 2024-03-18 73/week @ 2024-03-25 142/week @ 2024-04-01 130/week @ 2024-04-08 378/week @ 2024-04-15

731 downloads per month
Used in 3 crates (2 directly)

MIT/Apache

11KB
145 lines

thread_tryjoin

It is forked from https://github.com/badboy/thread_tryjoin-rs

Ever needed to wait for a thread to finish, but thought you can still do work until it finishes?

JoinHandle#join() waits for the thread to finish and is blocking, so it doesn't allow you to try again and again.

Luckily there is a non-portable pthread API: pthread_tryjoin_np

This library provides convenient access through a try_join method on JoinHandle. It only works on Linux though.

It uses JoinHandleExt to get to the underlying pthread_t handle.

Usage

[dependencies]
thread_tryjoin = "0.2"

Documentation

Example

use std::time::Duration;
use std::thread;
use thread_tryjoin::TryJoinHandle;

let t = thread::spawn(|| { thread::sleep(Duration::from_secs(1)); });
assert!(t.try_join().is_err());

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~42KB