diff options
| author | bors <bors@rust-lang.org> | 2020-07-28 23:45:05 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-07-28 23:45:05 +0000 |
| commit | 4cca9505ea9faab261c2769032101cda6a04c212 (patch) | |
| tree | 315fbb56ddc0990b91b5a29f55b3f382425ca4a1 | |
| parent | a7eff79135de09a49b50acb029925275a7b42ccb (diff) | |
| parent | 0a51a9fb0013b33ddec221343b2fbfcd475b286f (diff) | |
| download | rust-4cca9505ea9faab261c2769032101cda6a04c212.tar.gz rust-4cca9505ea9faab261c2769032101cda6a04c212.zip | |
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>),
)
}
```
| -rw-r--r-- | library/core/src/task/wake.rs | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/library/core/src/task/wake.rs b/library/core/src/task/wake.rs index b070b665b4d..92057209d8b 100644 --- a/library/core/src/task/wake.rs +++ b/library/core/src/task/wake.rs @@ -37,6 +37,7 @@ impl RawWaker { /// The `vtable` customizes the behavior of a `Waker` which gets created /// from a `RawWaker`. For each operation on the `Waker`, the associated /// function in the `vtable` of the underlying `RawWaker` will be called. + #[inline] #[rustc_promotable] #[stable(feature = "futures_api", since = "1.36.0")] #[rustc_const_stable(feature = "futures_api", since = "1.36.0")] |
