Comments (1)
Reposting a possible change to HandlerThreadScheduler to address the issue of a sync unsubscribe.
Regarding recursive scheduling resulting in stack overflows, the provided Action should be responsible to break the recursion and avoid the stack overflow just like any recursive call should it not? I am not sure I understand the issue so please apologize if I am not following you :)
Another alternative would be something like this:
private ThreadLocal<Queue<Action0>> pendingActions = new ThreadLocal<Queue<Action0>>() {
@Override
protected Queue<Action0> initialValue() {
return new LinkedList<Action0>();
}
};
private ThreadLocal<Boolean> isCalling = new ThreadLocal<Boolean>() {
@Override
protected Boolean initialValue() {
return false;
}
};
@Override
public Subscription schedule(final Action0 action) {
final Looper handlerLooper = handler.getLooper();
if (Looper.myLooper() == handlerLooper) {
if (isCalling.get()) {
Queue<Action0> actions = pendingActions.get();
actions.add(action);
} else {
isCalling.set(true);
action.call();
Queue<Action0> actions = pendingActions.get();
while(!actions.isEmpty()) {
actions.poll().call();
}
isCalling.set(false);
}
return Subscriptions.empty();
} else {
return schedule(action, 0, TimeUnit.MILLISECONDS);
}
}
from rxandroid.
Related Issues (20)
- move from version 2 to version 3 HOT 2
- BUG with gradle 3.6.1 and RxJava and RxAndroid 3.0.0 HOT 2
- RX Android & Release apk HOT 1
- RxAndroid
- HandlerScheduler throws NPE on schedule() in tests HOT 4
- AndroidRuntime: FATAL EXCEPTION -> observeOn(AndroidSchedulers.mainThread()) HOT 5
- Bug or Help Long running observable in background crashes app HOT 1
- [email protected]: Permission denied (publickey). HOT 1
- java.lang.NoSuchMethodError HOT 17
- IllegalAccessError: FlowableDoOnLifecycle: 2.2.3 HOT 1
- docs/content/github/collaborating-with-issues-and-pull-requests/merging-a-pull-request.md
- Gi
- issue with the indirect dependency component reactive-stream License HOT 2
- Does RxAndroid have any plans to release a new version? HOT 1
- Add Sonatype secrets to repo for GitHub Actions usage HOT 9
- RxAndroid 3.0.1 NPE in JVM unit tests HOT 1
- ERROR: Failed to resolve: io.reactivex.rxjava3:rxandroid:3.0.2 HOT 5
- Sms2
- Why the HandlerScheduler class overrides scheduleDirect. It's not more explicit to let the HandlerWorker do the work HOT 4
- Kotlin multiplaform support HOT 2
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 rxandroid.