synchronized
Convenient and simple macro for code synchronization in multithreading.
Use
1. easy/sync
use synchronized;
/*
Quick implementation examples of blocking anonymous code.
*/
2. sync_static
use spawn;
use synchronized;
/*
A more illustrative example of code blocking implementation
for SAFE mutability of two or more static variables.
The code creates 5 threads that try to change static variables at the same
time without synchronization, but the code synchronization block
does not allow this code to execute at the same time, which makes
the implementation of changing static variables SAFE and even somewhat
easier and more beneficial in terms of use and performance.
*/
3. sync_let
use spawn;
use synchronized;
/*
An example that describes how to quickly create an anonymous
sync with a mutable variable.
This code creates 5 threads, each of which tries to update
the `sync_let` variable with data while executing the synchronized anonymous code.
*/
4. point
use synchronized_point;
use synchronized;
/*
An example implementation of synchronized code with
one non-anonymous synchronization point.
This example creates a set of anonymous sync codes associated with a
single named sync point. Each synchronization code executes in the same
way as ordinary anonymous code, but execution occurs simultaneously in a
multi-threaded environment in only one of them.
*/
Connection
This section only describes how to choose the default synchronization method for a synchronized
macro.
1. PlugAndPlay (Minimal, Std)
= "1.0.0"
default-features = false
features =
version
2. PlugAndPlay (Minimal, parking_lot)
= "1.0.0"
default-features = false
features =
version
Additionally inf
-
The macro is an alternative to the
synchronized
keyword from the Java programming language for the Rust programming language with all sorts of extensions. -
This macro was created by an author who has not written in Java for a very long time, inspired by the memory of the Java programming language (versions 1.5-1.6).
License
Copyright 2022 #UlinProject Denis Kotlyarov (Денис Котляров)
Licensed under the Apache License, Version 2.0