Auto merge of #126038 - matthiaskrgr:rollup-h4rm3x2, r=matthiaskrgr · model-checking/verify-rust-std@29932f3 (original) (raw)

`@@ -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

``

`@@ -28,12 +28,12 @@ mod task_queue {

`

28

28

`}

`

29

29

``

30

30

`pub(super) struct Task {

`

31

``

`-

p: Box<dyn FnOnce()>,

`

``

31

`+

p: Box<dyn FnOnce() + Send>,

`

32

32

`done: JoinNotifier,

`

33

33

`}

`

34

34

``

35

35

`impl Task {

`

36

``

`-

pub(super) fn new(p: Box<dyn FnOnce()>) -> (Task, JoinHandle) {

`

``

36

`+

pub(super) fn new(p: Box<dyn FnOnce() + Send>) -> (Task, JoinHandle) {

`

37

37

`let (done, recv) = wait_notify::new();

`

38

38

`let done = JoinNotifier(Some(done));

`

39

39

`(Task { p, done }, recv)

`

`@@ -45,18 +45,12 @@ mod task_queue {

`

45

45

`}

`

46

46

`}

`

47

47

``

48

``

`-

#[cfg_attr(test, linkage = "available_externally")]

`

49

``

`-

#[export_name = "_ZN16__rust_internals3std3sys3sgx6thread15TASK_QUEUE_INITE"]

`

50

``

`-

static TASK_QUEUE_INIT: Once = Once::new();

`

51

48

`#[cfg_attr(test, linkage = "available_externally")]

`

52

49

`#[export_name = "_ZN16__rust_internals3std3sys3sgx6thread10TASK_QUEUEE"]

`

53

``

`-

static mut TASK_QUEUE: Option<Mutex<Vec>> = None;

`

``

50

`+

static TASK_QUEUE: Mutex<Vec> = Mutex::new(Vec::new());

`

54

51

``

55

52

`pub(super) fn lock() -> MutexGuard<'static, Vec> {

`

56

``

`-

unsafe {

`

57

``

`-

TASK_QUEUE_INIT.call_once(|| TASK_QUEUE = Some(Default::default()));

`

58

``

`-

TASK_QUEUE.as_ref().unwrap().lock().unwrap()

`

59

``

`-

}

`

``

53

`+

TASK_QUEUE.lock().unwrap()

`

60

54

`}

`

61

55

`}

`

62

56

``

`@@ -101,7 +95,7 @@ pub mod wait_notify {

`

101

95

``

102

96

`impl Thread {

`

103

97

`// unsafe: see thread::Builder::spawn_unchecked for safety requirements

`

104

``

`-

pub unsafe fn new(_stack: usize, p: Box<dyn FnOnce()>) -> io::Result {

`

``

98

`+

pub unsafe fn new(_stack: usize, p: Box<dyn FnOnce() + Send>) -> io::Result {

`

105

99

`let mut queue_lock = task_queue::lock();

`

106

100

`unsafe { usercalls::launch_thread()? };

`

107

101

`let (task, handle) = task_queue::Task::new(p);

`