Files
boc/aamos-ledger-rust/target/debug/deps/libspin-3a8b51dc255a56e1.rmeta
T

111 lines
54 KiB
Plaintext
Raw Normal View History

rust
#rustc 1.96.0 (ac68faa20 2026-05-25)ÁíàÄTËŸ ÜJîÄ)'ß\¥!-3d1337db07d0b3aeÁ¤°ð ¾ä-±($²ï=©Ã-7e98a21bfd32b0edÁí»À¼Ëportable_atomicÁ|ª»¯ÜÿatomicÁ4¸»¯܃barrierÁ<˜»ðœÇlazyÁ$ò»„§testsÁ,ëU$àUticketÁ4â» ticket_mutexÁć TicketMutexÁ\Ú»ÑÄðTicketMutexGuardÁ„ç»Ñ&(fairÁ$Ø »
fair_mutexÁ´  FairMutexÁLÈ
»¼´ä FairMutexGuardÁtÓ
»¼$&
StarvationÁTã
»¼BD
InnerMutexÁTé»use_ticket_mutexÁäÅInnerMutexGuardÁ|Ç»Åä£onceÁ$£»„زYieldÁ,Õ»À|‰rwlockÁ4»º”¾Ÿ»À|‚Ó»º”…BarrierÁ<ì »ðœš LazyÁ$—$»„Ë#OnceÁ$•+»„É*Ò4ß.»º.RwLockUpgradableGuardÁ¬Ï2»º”ÿ1Ô„®6»º”Þ5lock_apiÁD´8»ª¤á7,ëG»¼´ÏGímutexÁspinÁ 
  
 SpinMutexÁ¥£phantomÁlockÁdataÁSpinMutexGuardÁ'aÁ¥íø¥£"¥"£%¥'¥)¥)£)æ )
into_innerÁ)
as_mut_ptrÁ/¥/£/í3¥3£3 is_lockedÁ3 force_unlockÁ3try_lockÁ3get_mutÁ:¥:£:×= = @¥@£@> D¥D£D÷
H˜ H¥HleakÁ L˜ L¥L× P˜ P¥P×
T˜ T¥TåT´Y˜ Y¥Y]˜ ]¥]ã 
¯l¥l£ßo˜ o¥¤r¥r£rinnerÁv¥v£y¥y£¥|˜ |¥|ô
¥£æ 
¥£í¥£Ö
æ
ù
Ž ˆ ¥£×¥£>¥£÷˜ ¥ú  ¡˜ ¡¥¡×
¥˜ ¥¥¥× ©˜ ©¥©å©´ ®˜ ®¥®relaxÁ²
RelaxStrategyÁ³ ²SpinÁµ
²· ²LoopÁ¹
²» ¤Á¥%
'
.
2
6
7
8
9
=
=
=
O
O
O
S
S
S
X
\
`
ˆ
Œ

Ž




¤
¤
¤
¨
¨
¨
­
±
³ Áßíøæk–
Swø¥£ÌìÇ ƒ íøŸÇ.øœ&8¥Ì죿cdzÇéÇ¿cƒ íøŸÇ.øœ&˜ ÜÄcé!ö!Œ" rr¤uô
SG,¬,ÌÌì¿c³é¿c||¥ô
b~,Ž8
˜ ÜÄcäé!äö!ä³µµÊ tôp(æh&'³¹¹ºè vŽx*Ñ¿`%vr"'yr:L|@rDrP¥|T©|Y®|]·µ»¹ ~Ìì¿c³é Äc é! ö! Œ" ³´ë
&,
3
¶] Z¬•-
4|•
õ0EV © üÍŠ  ÖÝü¡¼ Ü,3Ǥ]¤]V¦]Á‚]üß3ø¤”&î0î0
UnsafeCellÁð0»Ì-·}—KEüC£}} PhantomDataÁFu\»Ÿ\øøÇ´à#,ð#
"|à#
,5F õ#üÆ#; r €$‡$ü™#nƒ$·#,ª#DZ°»I²ÁíÔ‚]¥|½­³¿ÊµÀÊÀü¼Küz\Y This crate provides [spin-based](https://en.wikipedia.org/wiki/Spinlock) versions of theÁü×`] primitives in `std::sync` and `std::lazy`. Because synchronization is done through spinning,Áü¸A> the primitives are suitable for use in `no_std` environments.Áúú # FeaturesÁúü‘JG - `Mutex`, `RwLock`, `Once`/`SyncOnceCell`, and `SyncLazy` equivalentsÁÜúüà'$ - Support for `no_std` environmentsÁˆúüŒC@ - [`lock_api`](https://crates.io/crates/lock_api) compatibilityÁÐúüÔ! - Upgradeable `RwLock` guardsÁöúüú30 - Guards can be sent and shared between threadsÁ®úœ² - Guard leakingÁÆú”Ê - Ticket locksÁÝúüá63 - Different strategies for dealing with contentionÁ˜úüœ# # Relationship with `std::sync`ÁÀúüÄB? While `spin` is not a drop-in replacement for `std::sync` (andÁü‡ol [should not be considered as such](https://matklad.github.io/2020/01/02/spinlocks-considered-harmful.html))Áü÷PM an effort is made to keep this crate reasonably consistent with `std::sync`.ÁÈúüÌhe Many of the types defined in this crate have 'additional capabilities' when compared to `std::sync`:Áµ úü¹ if - Because spinning does not depend on the thread-driven model of `std::sync`, guards ([`MutexGuard`],Áü£
^[ [`RwLockReadGuard`], [`RwLockWriteGuard`], etc.) may be sent and shared between threads.Á úü† TQ - [`RwLockUpgradableGuard`] supports being upgraded into a [`RwLockWriteGuard`].ÁÛ úüß OL - Guards support [leaking](https://doc.rust-lang.org/nomicon/leaking.html).Á¯ úü³ FC - [`Once`] owns the value returned by its `call_once` initializer.Áú úüþ 74 - [`RwLock`] supports counting readers and writers.Á
úüº
YV Conversely, the types in this crate do not have some of the features `std::sync` has:Áúü˜]Z - Locks do not track [panic poisoning](https://doc.rust-lang.org/nomicon/poisoning.html).Áöú¤ú ## Feature flagsÁúü“FC The crate comes with a few feature flags that you may wish to use.ÁÚúüÞTQ - `lock_api` enables support for [`lock_api`](https://crates.io/crates/lock_api)Á³úü·IF - `ticket_mutex` uses a ticket lock for the implementation of `Mutex`Áúü…b_ - `fair_mutex` enables a fairer implementation of `Mutex` that uses eventual fairness to avoidÁ„è
starvationÁùúüýC@ - `std` enables support for thread yielding instead of spinningÁ²Áí" Ô# ]¥" |½­! ³¿Ê µÀÊ1 À ”é ü2/ Locks that have the same behaviour as a mutex.Á3úü7_\ The [`Mutex`] in the root of the crate, can be configured using the `ticket_mutex` feature.Áü—^[ If it's enabled, [`TicketMutex`] and [`TicketMutexGuard`] will be re-exported as [`Mutex`]ÁüöRO and [`MutexGuard`], otherwise the [`SpinMutex`] and guard will be re-exported.ÁÉúüÍ*' `ticket_mutex` is disabled by default.Áøúüü# [`Mutex`]: ../struct.Mutex.htmlÁü -* [`MutexGuard`]: ../struct.MutexGuard.htmlÁüÎ.+ [`TicketMutex`]: ./struct.TicketMutex.htmlÁüý85 [`TicketMutexGuard`]: ./struct.TicketMutexGuard.htmlÁü¶*' [`SpinMutex`]: ./struct.SpinMutex.htmlÁüá41 [`SpinMutexGuard`]: ./struct.SpinMutexGuard.htmlÁ»òŒþÌølor|Ábƒ tïc­
³e¿Ê µfÀÊfÀ×£  `hr,² é!jDerefMutÁD¹ ö!kdìä A naïve spinning mutex.Áúü!ro Waiting threads hammer an atomic variable until it becomes available. Best-case latency is low, but worst-caseÁü”&# latency is theoretically infinite.Á»
spin_mutexÁ´ô—
AtomicBoolÁTÖ¬]®¼À ­³
¿Ê$€µ ÀÊ Àîî0
ׯ `ºº  ManuallyDropÁdÖÃÛr,îé!»>Dõö!œÀõ÷åçÒÔ$„™°Ÿ¡œ¸”ŒÑ^\^MOüý )ü„he A [spin lock](https://en.m.wikipedia.org/wiki/Spinlock) providing mutually exclusive access to data.Áíú
# ExampleÁÿú ```Ál
use spin;Áúü30 let lock = spin::mutex::SpinMutex::<_>::new(0);ÁÑú´Õ // Modify the dataÁ¬ì *lock.lock() = 2;Áú¤† // Read the dataÁô› let answer = *lock.lock();ÁÔº assert_eq!(answer, 2);ÁÒDÝúÜá # Thread safety exampleÁýú<ÒDl‰âDü—" use std::sync::{Arc, Barrier};Áºúä¾ let thread_count = 1000;ÁüÛC@ let spin_mutex = Arc::new(spin::mutex::SpinMutex::<_>::new(0));ÁŸúü£GD // We use a barrier to ensure the readout happens after all writingÁüë;8 let barrier = Arc::new(Barrier::new(thread_count + 1));Á§úô« # let mut ts = Vec::new();ÁüÊ  for _ in (0..thread_count) {Áüë)& let my_barrier = barrier.clone();Áü• )& let my_lock = spin_mutex.clone();Ál¿ 
# let t =ÁüÍ $! std::thread::spawn(move || {Áüò +( let mut guard = my_lock.lock();ÁÄž
 *guard += 1;Á·
úü»
52 // Release the lock to prevent a deadlockÁÄñ
 drop(guard);ÁôŠ  my_barrier.wait();Á  });ÁŒµ  # ts.push(t);Á Í úœÑ  barrier.wait();Áå úüé (% let answer = { *spin_mutex.lock() };Áü’ %" assert_eq!(answer, thread_count);Á¸ úœ¼  # for t in ts {ÁäÐ  # t.join().unwrap();Á  # }Á ÒDLˆ
¥£Îì
ÍìD
Çæk
Swø.0+
¼¼­
<­
¬ÜÊ

°œë

äüö-üƒ.+ A guard that provides mutable data access.Á²úü¶?< When the guard falls out of scope it will release the lock.Át˜ ¥ÎìÜ Ü˜  ŸÇ.øœ&`35¤ª ˜ ° Üü€9¥ £!! õQ Œ…R žÌìÇ $&ü½9¥#£$#$õQ É…R ÛŽV$ÕÇüû<8Ã¥&Ã&ÐT  Ü$“£ü»<8Ä¥(Ä(ÐT ÇÌìÜ£Ôü¥*£+*+Íì …R Ç,-.ü¡!ü;8 Creates a new [`SpinMutex`] wrapping the supplied data.ÁÝú°D÷ú<ÿÒDü‹ use spin::mutex::SpinMutex;Á¯úü·:7 static MUTEX: SpinMutex<()> = SpinMutex::<_>::new(());Áöú fn demo() {Áü’  let lock = MUTEX.lock();Áü·! // do something with lockÁœÝ drop(lock);ÁÇN<ÿÒD®Ç))¸ø*äÜüã@= Consumes this [`SpinMutex`] and unwraps the underlying data.Á¨ú°DÂúÒDüÖ41 let lock = spin::mutex::SpinMutex::<_>::new(42);Áü&# assert_eq!(42, lock.into_inner());ÁÒDTãÇ))
-üÐ"üÃ52 Returns a mutable pointer to the underlying data.Áýúü…^[ This is mostly meant to be used for applications which require manual unlocking, but whereÁüèMJ storing both the lock and the pointer to the inner data gets inefficient.Áºú°DÒDüà4÷\ú unsafe {Áü²'$ core::mem::forget(lock.lock());ÁÞúüæ1. assert_eq!(lock.as_mut_ptr().read(), 42);Áüœ$! lock.as_mut_ptr().write(58);ÁÅúäÍ lock.force_unlock();ÁÇNøúü€! assert_eq!(*lock.lock(), 58);Á¦úÒDT×Å ÅÇ ) â)
.ü– 1¥0£110õQ …R ¦ ³Ç2!%'üƒ%'üÎ VS Locks the [`SpinMutex`] and returns a guard that permits access to the inner data.Á©!úü±!:7 The returned value may be dereferenced for data accessÁüð!C@ and the lock will be dropped when the guard falls out of scope.Á¸"ú<À"ÒDüÌ"3…E,„#üŽ## let mut data = lock.lock();Áü¶#>; // The lock is now locked and the data can be accessedÁœù# *data += 1;Áü‘$A> // The lock is implicitly dropped at the end of the scopeÁ,×$ÇN<á$ÒD$Š%Æ ÆÇƒ íøŸÇ.øœ&Æ/ %/
2$%üê)"¥4£554õQ ï)…R ú)Ç6789üê,ü“*1. Returns `true` if the lock is currently held.ÁÉ*údÑ* # SafetyÁâ*úüê*mj This function provides no synchronization guarantees and so its result should be considered 'out of date'ÁüÜ+sp the instant it is called. Do not use it for synchronization purposes. However, it may
 `£cbufÁ `àB¤GS
ÍÖ¿Ù¿Ú¿«Û¿ˆÜ¿Ý¿Þ¿ˆ‚†f|Â
¤rŸÈŸÈ ÈErrorÁ O˜éBL: £?:
=$¤?± ª?$Å@=<closure_kind>Á><closure_signature>Á><upvars>Á>>=>¤rï~ ƒ íøŸÇ.øœ&   c cˆ¢cµ
 `£cÈ} `àB¤GS
$ö@=?Î?ë??=?Þü×A8¥A£BABõQ ÜA…R ñA³<èAÇC´C&(,.¤–B<™BÇ@@
CüÜB&¥E£FEFÛX áB…R äBÇGëGĉC$ŒCÇDD
Gø$‘CüÅC)˜ I¥JJIÐT ÎCKÊCü¡G$üõCMJ Leak the lock guard, yielding a mutable reference to the underlying data.ÁÇDúüÏDMJ Note that this function will permanently lock the original [`SpinMutex`].Á¡Eú<©EÒDüµE52 let mylock = spin::mutex::SpinMutex::<_>::new(0);ÁïEúü÷EJG let data: &mut i32 = spin::mutex::SpinMutexGuard::leak(mylock.lock());ÁÆFútÎF *data = 1;ÁÌáF assert_eq!(*data, 1);Á<ÿFÒD$¨G ˜ ÜHH
K˜ ÜthisÁ$­Gü¥IE˜ M¥NMNÐT ®I¿cÜTºIOÀcOªI%'üñI4ôIÎÏÐ Î Ï c cˆ¢cµ