mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-22 00:00:11 +02:00
threadpool: move threadpool into tokio-executor (#1452)
The threadpool is behind a feature flag. Refs: #1264
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
use super::worker::Worker;
|
||||
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct Callback {
|
||||
f: Arc<dyn Fn(&Worker) + Send + Sync>,
|
||||
}
|
||||
|
||||
impl Callback {
|
||||
pub(crate) fn new<F>(f: F) -> Self
|
||||
where
|
||||
F: Fn(&Worker) + Send + Sync + 'static,
|
||||
{
|
||||
Callback { f: Arc::new(f) }
|
||||
}
|
||||
|
||||
pub(crate) fn call(&self, worker: &Worker) {
|
||||
(self.f)(worker)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Callback {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(fmt, "Fn")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user