about summary refs log tree commit diff
path: root/src/libstd/sync/task_pool.rs
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2015-02-13 22:58:37 +1100
committerHuon Wilson <dbau.pp+github@gmail.com>2015-02-18 08:19:21 +1100
commitd7b5bc3c2f673ac3edd818cb7bd42555c2cbc2a2 (patch)
tree9fc5d0740225f18a41e9dda8ef5bfbc132a858c2 /src/libstd/sync/task_pool.rs
parentcae969e2a755bd7e8ec22758a8a02146ddb599a4 (diff)
downloadrust-d7b5bc3c2f673ac3edd818cb7bd42555c2cbc2a2.tar.gz
rust-d7b5bc3c2f673ac3edd818cb7bd42555c2cbc2a2.zip
Update the libraries to reflect Send loosing the 'static bound.
In most places this preserves the current API by adding an explicit
`'static` bound.

Notably absent are some impls like `unsafe impl<T: Send> Send for
Foo<T>` and the `std::thread` module. It is likely that it will be
possible to remove these after auditing the code to ensure restricted
lifetimes are safe.

More progress on #22251.
Diffstat (limited to 'src/libstd/sync/task_pool.rs')
-rw-r--r--src/libstd/sync/task_pool.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libstd/sync/task_pool.rs b/src/libstd/sync/task_pool.rs
index 684a46fd6ff..831c4d315b1 100644
--- a/src/libstd/sync/task_pool.rs
+++ b/src/libstd/sync/task_pool.rs
@@ -24,12 +24,12 @@ use thread::Thread;
 use thunk::Thunk;
 
 struct Sentinel<'a> {
-    jobs: &'a Arc<Mutex<Receiver<Thunk>>>,
+    jobs: &'a Arc<Mutex<Receiver<Thunk<'static>>>>,
     active: bool
 }
 
 impl<'a> Sentinel<'a> {
-    fn new(jobs: &Arc<Mutex<Receiver<Thunk>>>) -> Sentinel {
+    fn new(jobs: &'a Arc<Mutex<Receiver<Thunk<'static>>>>) -> Sentinel<'a> {
         Sentinel {
             jobs: jobs,
             active: true
@@ -80,7 +80,7 @@ pub struct TaskPool {
     //
     // This is the only such Sender, so when it is dropped all subthreads will
     // quit.
-    jobs: Sender<Thunk>
+    jobs: Sender<Thunk<'static>>
 }
 
 impl TaskPool {
@@ -105,13 +105,13 @@ impl TaskPool {
 
     /// Executes the function `job` on a thread in the pool.
     pub fn execute<F>(&self, job: F)
-        where F : FnOnce(), F : Send
+        where F : FnOnce(), F : Send + 'static
     {
         self.jobs.send(Thunk::new(job)).unwrap();
     }
 }
 
-fn spawn_in_pool(jobs: Arc<Mutex<Receiver<Thunk>>>) {
+fn spawn_in_pool(jobs: Arc<Mutex<Receiver<Thunk<'static>>>>) {
     Thread::spawn(move || {
         // Will spawn a new thread on panic unless it is cancelled.
         let sentinel = Sentinel::new(&jobs);