--- /dev/null
+use std::thread;
+
+struct Worker {
+ id: usize,
+ thread: thread::JoinHandle<()>,
+}
+
+impl Worker {
+ fn new(id: usize) -> Worker {
+ Worker { id, thread: thread::spawn(|| {}) }
+ }
+}
+
+pub struct ThreadPool {
+ workers: Vec<Worker>,
+}
+
+impl ThreadPool {
+ /// Create a new thread pool.
+ ///
+ /// # Panics
+ ///
+ /// - if size is zero
+ pub fn new(size: usize) -> ThreadPool {
+ assert!(size > 0);
+ let mut workers = Vec::with_capacity(size);
+
+ for id in 0..size {
+ workers.push(Worker::new(id));
+ }
+
+ ThreadPool { workers }
+ }
+
+ pub fn execute<F>(&self, f: F)
+ where F: FnOnce() + Send + 'static
+ {
+ thread::spawn(f);
+ }
+}