Skip to content

Commit 4cca950

Browse files
committed
Auto merge of #74791 - tmiasko:raw-waker-inline, r=LukasKalbertodt
Add #[inline] to RawWaker::new `RawWaker::new` is used when creating a new waker or cloning an existing one, for example as in code below. The `RawWakerVTable::new` can be const evaluated, but `RawWaker::new` itself cannot since waker pointer is not known at compile time. Add `#[inline]` to avoid overhead of a function call. ```rust unsafe fn clone_waker<W: Wake + Send + Sync + 'static>(waker: *const ()) -> RawWaker { unsafe { Arc::incr_strong_count(waker as *const W) }; RawWaker::new( waker as *const (), &RawWakerVTable::new(clone_waker::<W>, wake::<W>, wake_by_ref::<W>, drop_waker::<W>), ) } ```
2 parents a7eff79 + 0a51a9f commit 4cca950

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

library/core/src/task/wake.rs

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ impl RawWaker {
3737
/// The `vtable` customizes the behavior of a `Waker` which gets created
3838
/// from a `RawWaker`. For each operation on the `Waker`, the associated
3939
/// function in the `vtable` of the underlying `RawWaker` will be called.
40+
#[inline]
4041
#[rustc_promotable]
4142
#[stable(feature = "futures_api", since = "1.36.0")]
4243
#[rustc_const_stable(feature = "futures_api", since = "1.36.0")]

0 commit comments

Comments
 (0)