Comments (7)
By default it will run in own thread.
The thread model is abstracted as Scheduler. If you want to switch, you can switch with TaskPoolScheduler, ThreadScheduler, observeOn or subscribeOn.
However, if you always want to run on UI threads, write the scheduler yourself.
An example of this is the DlangUIScheduler.
https://github.com/lempiji/rx/blob/dev/examples/scheduler-dlangui/source/app.d
from rx.
So, it's pretty simple to start some long-running tasks on a specific event and utilize multi-core machines? That's pretty cool...
What's the best way to exchange data between threads in RX manner? Or just use plain D infrastructure for this?
from rx.
From #33 "But keeping everything lock-free is really hard and tedious..."
Can you explain the thread concept a bit more? If I just use RX as is it's single-threaded? So, all the lock-free handling is there for cases, where I use a scheduler?
from rx.
Need to come back to this:
-
I just use RX as is. Nothing special, no scheduler, etc. Just out-of-the-box.
-
I have a single-threaded D app, which a couple of streams and many observers per stream.
-
The app crashes when there is a heavy load on the streams. I have the suspicion that this has something to do with multiple threads and some race-condition, that might origin from RX.
Some questions:
-
When I put a value into a stream, will this start a new thread?
-
When observers are notified, is this done sequentially or via threads?
from rx.
I'm back now.
A1. With simple usage, no threads are created. Always works on a single thread.
A2. Observers will be notified in the order they were subscribed. Internally, the Subject is just an array of Observers.
At the moment, threads are only created when using "debounce", "subscribeOn" or "observeOn".
If you suspect a crash due to data races between threads, look at "Thread.id" for something.
from rx.
Ok, thanks.
Any reason why you don't use std.signals for implementation? IMO that would make RX a bit more standard compatible.
from rx.
The reason is "lack of multi-thread support".
I think the method of unsubscribing in ReactiveX is superior to Signal's disconnect in terms of encapsulation and ownership.
from rx.
Related Issues (17)
- subscribeOn is broken with TaskPoolScheduler and ThreadScheduler HOT 4
- Implement groupBy HOT 7
- Rename AnonymouseDisposable to AnonymousDisposable
- Observer not triggered HOT 7
- Commented examples / Basic Docs HOT 6
- Speed of message distribution? HOT 5
- Return type of filter!(...) HOT 3
- Filter subscribers HOT 27
- CompositeObserver / several times the same observer HOT 1
- CompositeObserver.remove() returning Observer? HOT 3
- Why three different makeObserver(...) functions instead of one? HOT 1
- How to get reference to underlying object/function of an observer? HOT 1
- makeObserver in a loop / why does it use static struct? HOT 2
- RX fails with DMD 2.089 HOT 5
- Compile error from v0.11.0 on / .filter() / casts give different sizes error HOT 8
- Observable pipeline question
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 rx.