fixed doctest for threadpool
This commit is contained in:
parent
044a3f3747
commit
43bd19643b
|
@ -1,4 +1,4 @@
|
||||||
mod multithreading;
|
pub mod multithreading;
|
||||||
|
|
||||||
pub fn add(left: usize, right: usize) -> usize {
|
pub fn add(left: usize, right: usize) -> usize {
|
||||||
left + right
|
left + right
|
||||||
|
|
|
@ -36,7 +36,8 @@ fn get_default_thread_count() -> usize {
|
||||||
/// The pool will also keep track of every `JoinHandle` created by running every closure on
|
/// The pool will also keep track of every `JoinHandle` created by running every closure on
|
||||||
/// its on thread. The closures can be obtained by either calling `join_all` or `get_finished`.
|
/// its on thread. The closures can be obtained by either calling `join_all` or `get_finished`.
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```rust ignore
|
/// ```rust
|
||||||
|
/// use imsearch::multithreading::ThreadPool;
|
||||||
/// let mut pool = ThreadPool::new();
|
/// let mut pool = ThreadPool::new();
|
||||||
///
|
///
|
||||||
/// // launch some work in parallel
|
/// // launch some work in parallel
|
||||||
|
@ -60,7 +61,7 @@ fn get_default_thread_count() -> usize {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ThreadPool<F, T>
|
pub struct ThreadPool<F, T>
|
||||||
where
|
where
|
||||||
F: Send + FnOnce() -> T + Send + 'static,
|
F: Send + FnOnce() -> T,
|
||||||
{
|
{
|
||||||
/// maximum number of threads to launch at once
|
/// maximum number of threads to launch at once
|
||||||
max_thread_count: usize,
|
max_thread_count: usize,
|
||||||
|
@ -79,7 +80,7 @@ where
|
||||||
|
|
||||||
impl<F, T> Default for ThreadPool<F, T>
|
impl<F, T> Default for ThreadPool<F, T>
|
||||||
where
|
where
|
||||||
F: Send + FnOnce() -> T + Send + 'static,
|
F: Send + FnOnce() -> T,
|
||||||
{
|
{
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
@ -95,7 +96,7 @@ where
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
impl<F, T> ThreadPool<F, T>
|
impl<F, T> ThreadPool<F, T>
|
||||||
where
|
where
|
||||||
F: Send + FnOnce() -> T,
|
F: Send + FnOnce() -> T + 'static,
|
||||||
T: Send + 'static,
|
T: Send + 'static,
|
||||||
{
|
{
|
||||||
/// Create a new empty thread pool with the maximum number of threads set be the recommended amount of threads
|
/// Create a new empty thread pool with the maximum number of threads set be the recommended amount of threads
|
||||||
|
@ -218,7 +219,7 @@ fn execute<F, T>(
|
||||||
closure: F,
|
closure: F,
|
||||||
) where
|
) where
|
||||||
T: Send + 'static,
|
T: Send + 'static,
|
||||||
F: Send + FnOnce() -> T + Send + 'static,
|
F: Send + FnOnce() -> T + 'static,
|
||||||
{
|
{
|
||||||
let handles_copy = handles.clone();
|
let handles_copy = handles.clone();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue