Files
boc/aamos-ledger-rust/target/debug/deps/libatomic_waker-2433aa5dc1ef41d0.rmeta
T

24 lines
14 KiB
Plaintext
Raw Normal View History

rust
ž4#rustc 1.96.0 (ac68faa20 2026-05-25)ÁíàÄTËŸ ÜJîÄ)'ß\¥!-3d1337db07d0b3aeÁ¤°ð ¾ä-±($²ï=©Ã-7e98a21bfd32b0edÁ AtomicUsizeÁ\§»portable-atomicÁÜôí AtomicWakerÁ º wakerÁWAITINGÁ REGISTERINGÁWAKINGÁæ 
AssertSyncÁregisterÁ wakeÁtakeÁ>×






ããWakerÁ䃸 È
4åê邳  ê º
ƒHXhù"-e¿cýÌìý ýã    ³¿cÌì 0b01Á0b10ÁÌàF
„àF
ŒÄ<ñF 7¬ŽG$žG Û¼¿%
,|ŽG
õ0Û¼ݼÞ¼©ß¼à¼ÛἈcSñŸ«‡zÙ¿ ¢Gü¿Fo   ­G´Gü«E‰ý$ÁE¤]¤]V¦]Á‚]üß3ø¤”&_î0î0
UnsafeCellÁð0»Ì-·}—KEüC£ÄdÄd¢ í¸î0×Å `F4íÃÀFÄÀG<õÁÀGÂÀÌ¿ÀÌÀÀËã Š„Ä
ü§ü>; `futures::task::AtomicWaker` extracted into its own crate.Á?útC # FeaturesÁRúüVGD This crate adds a feature, `portable-atomic`, which uses a polyfillÁüžHE from the [`portable-atomic`] crate in order to provide functionalityÁüçNK to targets without atomics. See the [`README`] for the [`portable-atomic`]Áü¶0- crate for more information on how to use it.ÁçúüëA> [`portable-atomic`]: https://crates.io/crates/portable-atomicÁü­[X [`README`]: https://github.com/taiki-e/portable-atomic/blob/main/README.md#optional-cfgÁahttps://raw.githubusercontent.com/smol-rs/smol/master/assets/images/logo_fullsize_transparent.pngÁ„¡Þ íȸÉî0×È `FÇÃÀFÙÄÀGÇÁÀGÙÂÀÌÇ¿ÀÌÚÀÀËÇã ŠÆ„Ä
´£L¿äÎz}Z]9<ŒŒüÍ´Ùüµ0- A synchronization primitive for task wakeup.ÁæúüêIF Sometimes the task interested in a given event will change over time.Áü´ NK An `AtomicWaker` can coordinate concurrent notifications with the consumerÁüƒ
LI potentially "updating" the underlying task to wake up. This is useful inÁüÐ
JG scenarios where a computation completes in another thread and wants toÁü› PM notify the consumer, but the consumer is in the process of being migrated toÁ¼ì  a new logical task.Á úüˆ PM Consumers should call `register` before checking the result of a computationÁüÙ JG and producers should call `wake` after producing the computation (thisÁü¤
LI differs from the usual `thread::park` pattern). It is also permitted forÁüñ
GD `wake` to be called **before** `register`. This results in a no-op.Á¹úü½QN A single `AtomicWaker` may be reused for any number of calls to `register` orÁ\ `wake`.Áú¬Ÿ # Memory orderingÁµúü¹JG Calling `register` "acquires" all memory "released" by calls to `wake`Áü„GD before the call to `register`. Later calls to `wake` will wake theÁüÌPM registered waker (on contention this wake might be triggered in `register`).Áúü¡OL For concurrent calls to `register` (should be avoided) the ordering is onlyÁüñ$! guaranteed for the winning call.Áú # ExamplesÁ©úü­NK Here is a simple example providing a `Flag` that can be signalled manuallyÁ¬ü when it is ready.Áú< ```Áüž  use futures::future::Future;Áü¿41 use futures::task::{Context, Poll, AtomicWaker};Á¼ô use std::sync::Arc;ÁüŒ&# use std::sync::atomic::AtomicBool;Áü³-* use std::sync::atomic::Ordering::Relaxed;Á´á use std::pin::Pin;Áøú”ü struct Inner {ÁÜ waker: AtomicWaker,ÁÄ« set: AtomicBool,ÁÊú¤Î #[derive(Clone)]Áäã struct Flag(Arc<Inner>);Áú|„ impl Flag {Áô” pub fn new() -> Self {Áü³! Flag(Arc::new(Inner {ÁüÕ*' waker: AtomicWaker::new(),Áü€,) set: AtomicBool::new(false),Á|­ }))ÁÇúôË pub fn signal(&self) {Áüê,) self.0.set.store(true, Relaxed);Áü—  self.0.waker.wake();ÁL¸¼%è"ÈúÔÌ impl Future for Flag {ÁÌç type Output = ();Áúü…IF fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {ÁüÏA> // quick check to avoid registration if already done.Áü‘)& if self.0.set.load(Relaxed) {Áü»'$ return Poll::Ready(());Á
ñúüõ.+ self.0.waker.register(cx.waker());Á¤úü¨KH // Need to check condition **after** `register` to avoid a raceÁüôA> // condition that would result in lost notifications.Áü¶)õ(üà Poll::Ready(())Á¤€ } else {Áì• Poll::PendingÁØ)¼%è"ÞýHXhù"-e