All Projects → LukasKalbertodt → atomig

LukasKalbertodt / atomig

Licence: Apache-2.0, MIT licenses found Licenses found Apache-2.0 LICENSE-APACHE MIT LICENSE-MIT
Generic and convenient `std` atomics via `Atomic<T>`

Programming Languages

rust
11053 projects
shell
77523 projects

Projects that are alternatives of or similar to atomig

Genumerics
Genumerics is a high-performance .NET library for generic numeric operations
Stars: ✭ 16 (-50%)
Mutual labels:  generic
shib-cas-authn3
Integrates an external CAS Server and Shibboleth IdPv3.
Stars: ✭ 21 (-34.37%)
Mutual labels:  cas
ertis-auth
Generic token generator and validator service like auth
Stars: ✭ 28 (-12.5%)
Mutual labels:  generic
QuickDB
A Generic CoreData Manager to accept any type of objects. Fastest way for adding a Database to your project.
Stars: ✭ 16 (-50%)
Mutual labels:  generic
go course
個人多年來學習與實作上的心得筆記
Stars: ✭ 25 (-21.87%)
Mutual labels:  generic
generic
Generic programming library for Python
Stars: ✭ 50 (+56.25%)
Mutual labels:  generic
grails-spring-security-cas
No description or website provided.
Stars: ✭ 16 (-50%)
Mutual labels:  cas
GenericAdapter
⛳️ Easy to use android databinding ready recyclerview adapter
Stars: ✭ 26 (-18.75%)
Mutual labels:  generic
smeagol-galore
A git-based wiki featuring markdown, a WYSIWYG Editor, PlantUML, and much more
Stars: ✭ 21 (-34.37%)
Mutual labels:  cas
simple json
Simple way to dynamically convert from and to JSON using build-time generators given a type.
Stars: ✭ 15 (-53.12%)
Mutual labels:  generic
lemonldap-ng
LemonLDAP::NG main code
Stars: ✭ 49 (+53.13%)
Mutual labels:  cas
Astview
Astview is a graphical viewer for abstract syntax trees
Stars: ✭ 20 (-37.5%)
Mutual labels:  generic
UseCases
This a library that offers a generic implementation of the data layers from the clean architecture by Uncle bob.
Stars: ✭ 23 (-28.12%)
Mutual labels:  generic
SACK
System Abstraction Component Kit
Stars: ✭ 18 (-43.75%)
Mutual labels:  generic
io-api
📐 API design example by I/O, the demo implementation of https://dzone.com/articles/generic-inputoutput-api-java
Stars: ✭ 46 (+43.75%)
Mutual labels:  generic
cas-overlay-template
Apereo CAS WAR Overlay template
Stars: ✭ 1,057 (+3203.13%)
Mutual labels:  cas
Johnny
Melodic Caching for Swift
Stars: ✭ 36 (+12.5%)
Mutual labels:  generic
cassette
A simple content-addressable storage system for .NET 4.5 and .NET Core
Stars: ✭ 34 (+6.25%)
Mutual labels:  cas
Swiftish
A fully generic Swift vector & matrix library
Stars: ✭ 17 (-46.87%)
Mutual labels:  generic
CRISPRCasTyper
CCTyper: Automatic detection and subtyping of CRISPR-Cas operons
Stars: ✭ 43 (+34.38%)
Mutual labels:  cas

Atomig: generic and convenient std atomics

CI status of master Crates.io Version docs.rs

Offers Atomic<T> that can be used with primitive and custom types. However, it only works with types that can actually use atomic operations: a lock-based fallback for other types is not used! This crate is based on std's atomics and therefore does not contain any unsafe code! This crate also does not have any dependencies by default. If you enable the serde feature, then this crate will depend on serde and Serialize / Deserialize will be implemented for Atomic<T> when appropriate, using sequentially-consistent ordering.

Simple example with primitive types:

use atomig::{Atomic, Ordering};

let x = Atomic::new(27); // `Atomic<i32>`
x.store(39, Ordering::SeqCst);

This works with almost all primitive types, including f32, f64 and char, but also with types like std::ptr::NonNull and std::num::NonZero.

You can automatically derive Atom for your own enum or struct types to use them in Atomic<T>. There are some limitations, however.

// Requires the 'derive' feature:
//     atomig = { version = "_", features = ["derive"] }
use atomig::{Atom, Atomic, Ordering};

#[derive(Atom)]
#[repr(u8)]
enum Animal { Dog, Cat, Fox }

let animal = Atomic::new(Animal::Cat);
animal.store(Animal::Fox, Ordering::SeqCst);

#[derive(Atom)]
struct Port(u16);

let port = Atomic::new(Port(80));
port.store(Port(8080), Ordering::SeqCst);

For more examples and information see the documentation.



License

Licensed under either of Apache License, Version 2.0 or MIT license at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].