3 ms·
Just implement concurrency with actors and u save up on some locks and mutexes... The patterns are available, its up to the community to apply proper concurren
by zwnow 1y ago
Just implement concurrency with actors and u save up on some locks and mutexes...
The patterns are available, its up to the community to apply proper concurrency patterns.
- paulddraper 1y agoThe x86 instruction set is available as well.
- PaulDavisThe1st 1y agoThe only replacement for locks/mutexes is a lock free data structure. Locks are not what make concurrency possible, they are what makes it data-safe. You can use platform threads, user-space threads, language-provided "green" threads, goroutines, continuations or whatever you wish for concurrency management, but that's almost orthogonal to data safety.
- MaxBarraclough 1y agoI'm not sure what you mean here, as far as I'm aware data safety isn't standard terminology.
- lazide 1y agoI think they’re using it in the context of what you’ll get without some degree of locking, which is data corruption and/or other issues. It’s not that you need locking to use threads. You need locking to stop threads from ruining any shared resource/data they are both trying to touch at the same time.
- saagarjha 1y agoActors are implemented using locks.
- pimeys 1y agoIs it really so? I haven't checked all the implementations, but my take here would be to use a channel with atomics instead of a lock...
- saagarjha 1y agoIt's probably possible to do if you think about it carefully but generally enqueuing a message is going to take a lock, especially if you can send an arbitrary number of messages (which may require the queue to be reallocated).
- pimeys 1y agoOne very common queue implementation you can use to implement actors is the crossbeam-deque. It's work-stealing in nature, works in multi-threaded environments and has no locks. The implementation is quite simple to follow: https://github.com/crossbeam-rs/crossbeam/blob/master/crossbeam-deque/src/deque.rs https://github.com/crossbeam-rs/crossbeam/blob/master/crossb...
- surajrmal 1y agoNote that the mpsc queue in the rust stdlib is also a clone of crossbeam and therefore also lockless.
- saagarjha 1y agoOh, interesting. Ok I take back my claim then.
- yubblegum 1y ago> One very common queue implementation you can use to implement actors is the crossbeam-deque I can't find any references to a "crossbeam dequeue" outside of Rust sources. Is this a neologism for a "very common" pattern, or just very common in Rust?
- steveklabnik 1y ago