Skip to content

Commit

Permalink
refactor(gstd): use waker-fn instead of unsafe code
Browse files Browse the repository at this point in the history
  • Loading branch information
playX18 committed Oct 1, 2024
1 parent 5d67331 commit 4c647b5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions gstd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ hex = { workspace = true, features = ["alloc"] }
parity-scale-codec = { workspace = true, features = ["derive"] }
scale-info = { workspace = true, features = ["derive"] }
futures = { workspace = true, features = ["alloc"] }
waker-fn = "1.1.1"

[features]
#! ## Default features
Expand Down
16 changes: 2 additions & 14 deletions gstd/src/async_runtime/waker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,8 @@

//! Module for Gear programs asynchronous waker.

use core::{
ptr,
task::{RawWaker, RawWakerVTable, Waker},
};

const VTABLE: RawWakerVTable = RawWakerVTable::new(clone_waker, wake, wake_by_ref, drop_waker);
use core::task::Waker;

pub(crate) fn empty() -> Waker {
unsafe { Waker::from_raw(RawWaker::new(ptr::null(), &VTABLE)) }
}

unsafe fn clone_waker(ptr: *const ()) -> RawWaker {
RawWaker::new(ptr, &VTABLE)
waker_fn::waker_fn(|| {})
}
unsafe fn wake(_ptr: *const ()) {}
unsafe fn wake_by_ref(_ptr: *const ()) {}
unsafe fn drop_waker(_ptr: *const ()) {}

0 comments on commit 4c647b5

Please sign in to comment.