std: rename Parker::new to Parker::new_in_place, add safe Parker::new constructor for SGX
This commit is contained in:
@@ -35,7 +35,7 @@ pub struct Parker {
|
||||
impl Parker {
|
||||
/// Construct the futex parker. The UNIX parker implementation
|
||||
/// requires this to happen in-place.
|
||||
pub unsafe fn new(parker: *mut Parker) {
|
||||
pub unsafe fn new_in_place(parker: *mut Parker) {
|
||||
parker.write(Self { state: AtomicU32::new(EMPTY) });
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ pub struct Parker {
|
||||
impl Parker {
|
||||
/// Construct the generic parker. The UNIX parker implementation
|
||||
/// requires this to happen in-place.
|
||||
pub unsafe fn new(parker: *mut Parker) {
|
||||
pub unsafe fn new_in_place(parker: *mut Parker) {
|
||||
parker.write(Parker {
|
||||
state: AtomicUsize::new(EMPTY),
|
||||
lock: Mutex::new(()),
|
||||
|
||||
@@ -26,9 +26,13 @@ const EMPTY: i8 = 0;
|
||||
const NOTIFIED: i8 = 1;
|
||||
|
||||
impl Parker {
|
||||
pub fn new() -> Parker {
|
||||
Parker { state: AtomicI8::new(EMPTY), tid: UnsafeCell::new(None) }
|
||||
}
|
||||
|
||||
/// Create a new thread parker. UNIX requires this to happen in-place.
|
||||
pub unsafe fn new(parker: *mut Parker) {
|
||||
parker.write(Parker { state: AtomicI8::new(EMPTY), tid: UnsafeCell::new(None) })
|
||||
pub unsafe fn new_in_place(parker: *mut Parker) {
|
||||
parker.write(Parker::new())
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
|
||||
@@ -41,7 +41,7 @@ pub struct Parker {
|
||||
impl Parker {
|
||||
/// Construct a parker for the current thread. The UNIX parker
|
||||
/// implementation requires this to happen in-place.
|
||||
pub unsafe fn new(parker: *mut Parker) {
|
||||
pub unsafe fn new_in_place(parker: *mut Parker) {
|
||||
parker.write(Parker { state: AtomicI8::new(EMPTY), wait_flag: WaitFlag::new() })
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user