-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Schedulers (merge of pull #199) #225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
benjchristensen
merged 26 commits into
ReactiveX:master
from
benjchristensen:schedulers-merge
Apr 5, 2013
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
dfc7841
Naive schedulers implementation
mairbek 0aa6ca2
Added ScheduledExecutorServiceScheduler
mairbek 1896da3
Added to Schedulers
mairbek 9eb111e
More tests
mairbek 86a750c
Headers
mairbek df09fcb
ObserveOn/SubscribeOn unit tests
mairbek 2d1c45d
Some documentation
mairbek db9f9a6
Documenting code
mairbek eaa0316
renamed tests
mairbek 81ee35d
Extracted ScheduledObserver as a separate class
mairbek bd32659
Simplified ImmediateScheduler
mairbek b24b42f
Removed SleepingAction from Abstract scheduler.
mairbek 9cfb294
added threadPoolForComputation and threadPoolForIO schedulers
mairbek 48ec950
Merge branch 'schedulers' of git://github.com/mairbek/RxJava into sch…
benjchristensen 4510b6e
Keeping ScheduledObserver out of public API
benjchristensen a78d756
Formatting to match codebase
benjchristensen a6ccf5a
Consolidating ExecutorScheduler and ScheduledExecutorScheduler
benjchristensen a8292de
Make ForwardingScheduler Internal
benjchristensen 7c6a14d
Tweaks to Executor/ExecutorScheduler/IOScheduler and Javadocs
benjchristensen 57875b0
Basic unit tests
benjchristensen 54c1dfd
Scheduler overloads for Subscribe, ToObservable, From, Merge, Empty
benjchristensen 52bf7e1
Set threads to daemons so they don't prevent system from exiting
benjchristensen 56bd8db
Name the NewThreadScheduler threads
benjchristensen cfca6fd
Use long instead of int
benjchristensen d35b3e7
Fix non-deterministic unit test
benjchristensen 97fbcc7
Removing Scheduler overloads on operators (for now)
benjchristensen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* Copyright 2013 Netflix, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package rx; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
import rx.util.functions.Action0; | ||
import rx.util.functions.Func0; | ||
|
||
/** | ||
* Represents an object that schedules units of work. | ||
*/ | ||
public interface Scheduler { | ||
|
||
/** | ||
* Schedules a cancelable action to be executed. | ||
* | ||
* @param action | ||
* action | ||
* @return a subscription to be able to unsubscribe from action. | ||
*/ | ||
Subscription schedule(Func0<Subscription> action); | ||
|
||
/** | ||
* Schedules an action to be executed. | ||
* | ||
* @param action | ||
* action | ||
* @return a subscription to be able to unsubscribe from action. | ||
*/ | ||
Subscription schedule(Action0 action); | ||
|
||
/** | ||
* Schedules an action to be executed in dueTime. | ||
* | ||
* @param action | ||
* action | ||
* @return a subscription to be able to unsubscribe from action. | ||
*/ | ||
Subscription schedule(Action0 action, long dueTime, TimeUnit unit); | ||
|
||
/** | ||
* Schedules a cancelable action to be executed in dueTime. | ||
* | ||
* @param action | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add param for dueTime |
||
* action | ||
* @return a subscription to be able to unsubscribe from action. | ||
*/ | ||
Subscription schedule(Func0<Subscription> action, long dueTime, TimeUnit unit); | ||
|
||
/** | ||
* Returns the scheduler's notion of current time. | ||
*/ | ||
long now(); | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
rxjava-core/src/main/java/rx/concurrency/AbstractScheduler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* Copyright 2013 Netflix, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package rx.concurrency; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
import rx.Scheduler; | ||
import rx.Subscription; | ||
import rx.subscriptions.Subscriptions; | ||
import rx.util.functions.Action0; | ||
import rx.util.functions.Func0; | ||
|
||
/* package */abstract class AbstractScheduler implements Scheduler { | ||
|
||
@Override | ||
public Subscription schedule(Action0 action) { | ||
return schedule(asFunc0(action)); | ||
} | ||
|
||
@Override | ||
public Subscription schedule(Action0 action, long dueTime, TimeUnit unit) { | ||
return schedule(asFunc0(action), dueTime, unit); | ||
} | ||
|
||
@Override | ||
public long now() { | ||
return System.nanoTime(); | ||
} | ||
|
||
private static Func0<Subscription> asFunc0(final Action0 action) { | ||
return new Func0<Subscription>() { | ||
@Override | ||
public Subscription call() { | ||
action.call(); | ||
return Subscriptions.empty(); | ||
} | ||
}; | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add param for dueTime