All Projects → orium → archery

orium / archery

Licence: MPL-2.0 license
Abstract over the atomicity of reference-counting pointers in rust

Programming Languages

rust
11053 projects
shell
77523 projects

Projects that are alternatives of or similar to archery

Cone
Cone Programming Language
Stars: ✭ 257 (+140.19%)
Mutual labels:  concurrency, memory-management
cactusref
🌵 Cycle-Aware Reference Counting in Rust
Stars: ✭ 129 (+20.56%)
Mutual labels:  memory-management, reference-counting
BEW-2.5-Strongly-Typed-Languages
💪 Learn and implement the design patterns and best practices that make Go a top choice at high-velocity startups like Lyft, Heroku, Docker, Medium, and more!
Stars: ✭ 14 (-86.92%)
Mutual labels:  concurrency
concurrent-ll
concurrent linked list implementation
Stars: ✭ 66 (-38.32%)
Mutual labels:  concurrency
pipeline
Pipelines using goroutines
Stars: ✭ 46 (-57.01%)
Mutual labels:  concurrency
threads
Fork threads and wait for their result
Stars: ✭ 28 (-73.83%)
Mutual labels:  concurrency
workerpool
A workerpool that can get expanded & shrink dynamically.
Stars: ✭ 55 (-48.6%)
Mutual labels:  concurrency
Yew
Yew is a modern Rust framework for creating multi-threaded front-end web apps with WebAssembly.
Stars: ✭ 18,243 (+16949.53%)
Mutual labels:  concurrency
p-ratelimit
Promise-based utility to make sure you don’t call rate-limited APIs too quickly.
Stars: ✭ 49 (-54.21%)
Mutual labels:  concurrency
Arcpp
An implementation of the Arc programming language
Stars: ✭ 15 (-85.98%)
Mutual labels:  reference-counting
Actors.jl
Concurrent computing in Julia based on the Actor Model
Stars: ✭ 95 (-11.21%)
Mutual labels:  concurrency
simpledbm
SimpleDBM is an Open Source Multi-Threaded Embeddable Transactional Database Engine in Java.
Stars: ✭ 51 (-52.34%)
Mutual labels:  concurrency
event pool
a header-only event-driven library based on c++11.
Stars: ✭ 27 (-74.77%)
Mutual labels:  concurrency
go-left-right
A faster RWLock primitive in Go, 2-3 times faster than RWMutex. A Go implementation of concurrency control algorithm in paper <Left-Right - A Concurrency Control Technique with Wait-Free Population Oblivious Reads>
Stars: ✭ 42 (-60.75%)
Mutual labels:  concurrency
buddy alloc
A single header buddy memory allocator for C
Stars: ✭ 46 (-57.01%)
Mutual labels:  memory-management
rc-headless-transmitter
DIY 2.4 GHz RC transmitter without display, configurable through smartphone or web browser
Stars: ✭ 28 (-73.83%)
Mutual labels:  rc
actors
Actor Model library for Dart.
Stars: ✭ 40 (-62.62%)
Mutual labels:  concurrency
reactor-workshop
Spring Reactor hands-on training (3 days)
Stars: ✭ 114 (+6.54%)
Mutual labels:  concurrency
haskell-simple-concurrency
Small examples of concurrency in Haskell.
Stars: ✭ 75 (-29.91%)
Mutual labels:  concurrency
java-red
Effective Concurrency Modules for Java
Stars: ✭ 25 (-76.64%)
Mutual labels:  concurrency

Build Status Code Coverage Dependency status crates.io Downloads Github stars Documentation License

Archery

Archery is a rust library that offers a way to abstraction over Rc and Arc smart pointers. This allows you to create data structures where the pointer type is parameterizable, so you can avoid the overhead of Arc when you don’t need to share data across threads.

In languages that supports higher-kinded polymorphism this would be simple to achieve without any library, but rust does not support that yet. To mimic higher-kinded polymorphism Archery implements the approach suggested by Joshua Liebow-Feeser in “Rust has higher kinded types already… sort of”. While other approaches exist, they seem to always offer poor ergonomics for the user.

Setup

To use Archery add the following to your Cargo.toml:

[dependencies]
archery = "<version>"

Using Archery

Archery defines a SharedPointer that receives the kind of pointer as a type parameter. This gives you a convenient and ergonomic way to abstract the pointer type away.

Example

Declare a data structure with the pointer kind as a type parameter bounded by SharedPointerKind:

use archery::*;

struct KeyValuePair<K, V, P: SharedPointerKind> {
    pub key: SharedPointer<K, P>,
    pub value: SharedPointer<V, P>,
}

impl<K, V, P: SharedPointerKind> KeyValuePair<K, V, P> {
    fn new(key: K, value: V) -> KeyValuePair<K, V, P> {
        KeyValuePair {
            key: SharedPointer::new(key),
            value: SharedPointer::new(value),
        }
    }
}

To use it just plug-in the kind of pointer you want:

let pair: KeyValuePair<_, _, RcK> =
    KeyValuePair::new("António Variações", 1944);

assert_eq!(*pair.value, 1944);

Limitations

Currently it is not possible to have unsized types inside a SharedPointer. As a workaround you can put the unsized type inside a Box.

Alternative approaches

An alternative to the approach taken by Archery is to use traits with associated types to encode type-level functions. This has been suggested multiple times, but offers ugly ergonomics (see here and here).

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].