Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

connectedcars/thread_tryjoin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

About

No description, website, or topics provided.

Resources

License

MIT and 2 other licenses found

Licenses found

MIT
LICENSE
Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%