Files
boc/aamos-ledger-rust/target/debug/deps/libatomic_waker-0451c32a97f709fe.rmeta
T

26 lines
14 KiB
Plaintext
Raw Normal View History

rust
5#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åê邳  ê º
ƒ³ª2G“*¿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ÁØ)¼%è"Þý³ª2G“*
”ö  ùüŽ   ® ¤ƒC<‰CÄåC\ëCœÖD4ÜD„óDýÔ«EäŠE Create an `AtomicWaker`.Á¸Eý
´÷ETýEÎìÌ÷E ­0$‰F¥0%·0¥0/·0%Ì™F¿ü©W%üºG:7 Registers the waker to be notified on calls to `wake`.ÁùGúüHKH The new task will take place of any previous tasks that were registeredÁüÑHJG by previous calls to `register`. Any calls to `wake` that happen afterÁü IHE a call to `register` (as defined by the memory ordering rules), willÁüíILI notify the `register` caller's task and deregister the waker from futureÁü¾JIF notifications. Because of this, callers should ensure `register` getsÁüŒKC@ invoked with a new `Waker` **each** time they require a wakeup.ÁÔKúüÜKJG It is safe to call `register` with multiple other threads concurrentlyÁü«LGD calling `wake`. This will result in the `register` caller's currentÁì÷L task being notified once.Á™Múü¡MKH This function is safe to call concurrently, but this is generally a badÁüñMKH idea. Concurrent calls to `register` will attempt to register differentÁüÁNLI tasks to be notified. One of the callers will win and have its task set,Áü’O>; but there is no guarantee as to which caller will succeed.ÁÕOútÝO¹ðOúüøO<9 Here is how `register` is used when implementing a flag.Á¹Pú<ÁPÞüÍP ïüòP4ü«Q&÷ üÖQ-§!´ˆRÝ!£RúŒ«R struct Flag {ÁÜÁR£"ÄáRÇ",þRè"ˆSúÔS…'̯S¨'ÍSúüÕSI×'ü£TKH // Register **before** checking `set` to avoid a race conditionÁüóT74 // that would result in lost notifications.Áü¯U,) self.waker.register(cx.waker());ÁàUúüèU'$ if self.set.load(Relaxed) {Áü”Vì+¤¸V”,ìÑV±,lóVØ)L…W¼%,“Wè"<WÞD°W  ý  ¿ ¹W