| @@ -15,7 +15,7 @@ pub use self::task_queue::JoinNotifier; |
|
|
| 15 |
15 |
|
| 16 |
16 |
mod task_queue { |
| 17 |
17 |
use super::wait_notify; |
| 18 |
|
-use crate::sync::{Mutex, MutexGuard, Once}; |
|
18 |
+use crate::sync::{Mutex, MutexGuard}; |
| 19 |
19 |
|
| 20 |
20 |
pub type JoinHandle = wait_notify::Waiter; |
| 21 |
21 |
|
| @@ -32,6 +32,8 @@ mod task_queue { |
|
|
| 32 |
32 |
done: JoinNotifier, |
| 33 |
33 |
} |
| 34 |
34 |
|
|
35 |
+unsafe impl Send for Task {} |
|
36 |
+ |
| 35 |
37 |
impl Task { |
| 36 |
38 |
pub(super) fn new(p: Box<dyn FnOnce()>) -> (Task, JoinHandle) { |
| 37 |
39 |
let (done, recv) = wait_notify::new(); |
| @@ -45,18 +47,12 @@ mod task_queue { |
|
|
| 45 |
47 |
} |
| 46 |
48 |
} |
| 47 |
49 |
|
| 48 |
|
-#[cfg_attr(test, linkage = "available_externally")] |
| 49 |
|
-#[export_name = "_ZN16__rust_internals3std3sys3sgx6thread15TASK_QUEUE_INITE"] |
| 50 |
|
-static TASK_QUEUE_INIT: Once = Once::new(); |
| 51 |
50 |
#[cfg_attr(test, linkage = "available_externally")] |
| 52 |
51 |
#[export_name = "_ZN16__rust_internals3std3sys3sgx6thread10TASK_QUEUEE"] |
| 53 |
|
-static mut TASK_QUEUE: Option<Mutex<Vec<Task>>> = None; |
|
52 |
+static TASK_QUEUE: Mutex<Vec<Task>> = Mutex::new(Vec::new()); |
| 54 |
53 |
|
| 55 |
54 |
pub(super) fn lock() -> MutexGuard<'static, Vec<Task>> { |
| 56 |
|
-unsafe { |
| 57 |
|
-TASK_QUEUE_INIT.call_once(| |
| 58 |
|
-TASK_QUEUE.as_ref().unwrap().lock().unwrap() |
| 59 |
|
-} |
|
55 |
+TASK_QUEUE.lock().unwrap() |
| 60 |
56 |
} |
| 61 |
57 |
} |
| 62 |
58 |
|