4 releases
0.2.1 | Aug 15, 2021 |
---|---|
0.2.0 | Aug 15, 2021 |
0.1.1 | Aug 13, 2021 |
0.1.0 | Aug 13, 2021 |
#2 in #familiar
99KB
2K
SLoC
net_sync
This is a pure-rust asynchronous network synchronization crate (using tokio) that recreates familiar asynchronous paradigms but in a network context.
Let A
and B
be two nodes with a pre-established ordered+reliable connection to each other (e.g., over TCP, TLS, QUIC, etc)
- join Given
A
executing functionf_a -> r_a
andB
executing functionf_b -> r_b
, returnr_a
toA
andr_b
toB
- try_join Given
A
executing functionf_a -> Result<r_a>
andB
executing functionf_b -> Result<r_b>
, returnResult<r_a>
toA
andResult<r_b>
toB
iffResult<r_a> = Ok(r_a)
ANDResult<r_b> = Ok(r_b)
. A global error is returned if either one of the nodes fails - select Given
A
executing functionf_a -> r_a
andB
executing functionf_b -> r_b
, returnr_a
toA
ifr_a
is computed first, or, returnr_b
toB
ifr_b
is computed first - try_select Given
A
executing functionf_a -> Result<r_a>
andB
executing functionf_b -> Result<r_b>
, returnResult<r_a>
toA
ifResult<r_a>
is computed first ANDResult<r_a> = Ok(r_a)
, or, returnResult<r_b>
toB
ifResult<r_b>
is computed first ANDResult<r_b> = Ok(r_b)
. Returns a global error if both nodes fail.
NetMutex: A mutual exclusion algorithm for sharing memory in a synchronized manner between two nodes
Additionally, there is a sync_start
file that allows the synchronization of two operations at approximately the same time.
Examples for every operation are in the source code under src/sync/[...]
In the future, this crate will include a NetRwLock
abstraction
Dependencies
~5–14MB
~166K SLoC