Comments (7)
Scala's SyncVar
has a different semantic than yours, it is more like to a "single element queue", where a put
on a set component just blocks the thread.
Maybe we can try to add a non-blocking try_put(value)
method that returns true if the value has been set and false otherwise or a timeout to a blocking put
I don't like the name, it sounds too much "academic" and it is not well suited for everyday use, but I also think is a good building block: Ruby standard library is very poor in concurrency and those facilities are very useful.
from concurrent-ruby.
You're right about the semantics of SyncVar
and put
, and that's what MVar
is - my example was wrong. The Scala semantics are what I intend to implement.
I'll go ahead and implement this as well. I'll call it SyncVar
for now.
from concurrent-ruby.
I'm not familiar with Scala's SyncVar
but I like the idea expressed by MVar. If Scala's SyncVar
implements the desired behavior then I like the idea of basing our implementation on Scala. It fits withe the theme of this library.
from concurrent-ruby.
SynchVar
seems a little too cryptic to me...
I mean: we're describing a container that can hold only one object, blocking when we try to put into another one object or if we try to get something that is not available yet.
What about Slot
?
from concurrent-ruby.
I just read the documentation for Scala's SyncVar and the description therein is "A class to provide safe concurrent access to a mutable cell."
Is "Cell" a reasonable name for this class, or is that too obscure? I'm fine with SyncVar, too. It's obscure but since that's the name Scala uses there is precedent.
from concurrent-ruby.
I prefer "Cell" over "SyncVar" because it conveys the idea: we have one cell that could be empty or full with blocking operations.
from concurrent-ruby.
Starting implementation in #17.
from concurrent-ruby.
Related Issues (20)
- why use wait_for_termination method will stuck the code HOT 2
- DaemonThreadFactory creating new Java thread factory each time it creates a new thread HOT 8
- `Concurrent::Promises::Future#value!` can return `nil` even when promise is not resolved yet HOT 6
- Version 1.2.2 crashes with Segmentation fault HOT 3
- Fiber.new causes SEGV when using Ruby 3.3.0 on Rails 7.1.2 in M1 Mac Docker environment HOT 5
- Segfault in lock_local_var.rb on aarch64 HOT 3
- [REDIRECT] Segfault on Ruby 3.3.0 on linux-aarch64? See https://bugs.ruby-lang.org/issues/20085
- Add new CI job with RUBY_MN_THREADS=1 HOT 4
- Add API to prestart threads in threadpools HOT 4
- Don't know how to build task 'parallel_spec' HOT 2
- Segmentation fault related to concurrent-ruby HOT 4
- Segmentation fault with Ruby 3.3.0 running with Docker HOT 1
- Add keyword arguments to async HOT 1
- ThreadPoolExecutor#shutdown? inconsistency in JRuby and C Ruby HOT 4
- test failure due to "uninitialized constant Concurrent::CAtomicReference" HOT 7
- CAtomicFixnum should probably be a private constant HOT 1
- support re-raising exceptions when shutting down a timertask HOT 4
- v1.2.0 release notes do not mention that RubyThreadLocalVar class was removed HOT 8
- NameError: uninitialized constant Concurrent::RubyThreadLocalVar HOT 1
- The Concurrent::Map default_proc is passed a Concurrent::Hash instead of the Concurrent::Map HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from concurrent-ruby.