Skip to content

Commit

Permalink
Merge pull request ReactiveX#599 from benjchristensen/rx.schedulers
Browse files Browse the repository at this point in the history
Refactor rx.concurrency to rx.schedulers
  • Loading branch information
benjchristensen committed Dec 10, 2013
2 parents c4cc4c3 + 7ba5924 commit 73fc535
Show file tree
Hide file tree
Showing 104 changed files with 1,606 additions and 895 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.junit.Test

import rx.Observable
import rx.Scheduler
import rx.concurrency.Schedulers
import rx.schedulers.Schedulers
import rx.util.functions.Func1

class TestParallel {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* 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.lang.scala.examples

import scala.concurrent.duration.DurationInt
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* 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.lang.scala

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ trait Scheduler {

private [scala] object Scheduler {
def apply(scheduler: rx.Scheduler): Scheduler = scheduler match {
case s: rx.concurrency.CurrentThreadScheduler => new CurrentThreadScheduler(s)
case s: rx.concurrency.ExecutorScheduler => new ExecutorScheduler(s)
case s: rx.concurrency.ImmediateScheduler => new ImmediateScheduler(s)
case s: rx.concurrency.NewThreadScheduler => new NewThreadScheduler(s)
case s: rx.concurrency.TestScheduler => new TestScheduler(s)
case s: rx.schedulers.CurrentThreadScheduler => new CurrentThreadScheduler(s)
case s: rx.schedulers.ExecutorScheduler => new ExecutorScheduler(s)
case s: rx.schedulers.ImmediateScheduler => new ImmediateScheduler(s)
case s: rx.schedulers.NewThreadScheduler => new NewThreadScheduler(s)
case s: rx.schedulers.TestScheduler => new TestScheduler(s)
case s: rx.Scheduler => new Scheduler{ val asJavaScheduler = s }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object CurrentThreadScheduler {
* Returns a [[rx.lang.scala.Scheduler]] that queues work on the current thread to be executed after the current work completes.
*/
def apply(): CurrentThreadScheduler = {
new CurrentThreadScheduler(rx.concurrency.Schedulers.currentThread())
new CurrentThreadScheduler(rx.schedulers.Schedulers.currentThread())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object ExecutorScheduler {
* Note that this does not support scheduled actions with a delay.
*/
def apply(executor: Executor): ExecutorScheduler = {
new ExecutorScheduler(rx.concurrency.Schedulers.executor(executor))
new ExecutorScheduler(rx.schedulers.Schedulers.executor(executor))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object ImmediateScheduler {
* Returns a [[rx.lang.scala.Scheduler]] that executes work immediately on the current thread.
*/
def apply(): ImmediateScheduler = {
new ImmediateScheduler(rx.concurrency.Schedulers.immediate())
new ImmediateScheduler(rx.schedulers.Schedulers.immediate())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object NewThreadScheduler {
* Returns a [[rx.lang.scala.Scheduler]] that creates a new {@link Thread} for each unit of work.
*/
def apply(): NewThreadScheduler = {
new NewThreadScheduler(rx.concurrency.Schedulers.newThread())
new NewThreadScheduler(rx.schedulers.Schedulers.newThread())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object ScheduledExecutorServiceScheduler {
* Returns a [[rx.lang.scala.Scheduler]] that queues work on an `java.util.concurrent.ScheduledExecutorService`.
*/
def apply(executor: ScheduledExecutorService): ScheduledExecutorServiceScheduler = {
new ScheduledExecutorServiceScheduler(rx.concurrency.Schedulers.executor(executor))
new ScheduledExecutorServiceScheduler(rx.schedulers.Schedulers.executor(executor))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import rx.lang.scala.Scheduler
*/
object TestScheduler {
def apply(): TestScheduler = {
new TestScheduler(new rx.concurrency.TestScheduler())
new TestScheduler(new rx.schedulers.TestScheduler())
}
}

Expand Down Expand Up @@ -64,7 +64,7 @@ object TestScheduler {
* }
* }}}
*/
class TestScheduler private[scala] (val asJavaScheduler: rx.concurrency.TestScheduler) extends Scheduler {
class TestScheduler private[scala] (val asJavaScheduler: rx.schedulers.TestScheduler) extends Scheduler {

def advanceTimeBy(time: Duration) {
asJavaScheduler.advanceTimeBy(time.length, time.unit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ object ThreadPoolForComputationScheduler {
* Do not perform IO-bound work on this scheduler. Use [[rx.lang.scala.schedulers.ThreadPoolForIOScheduler]] instead.
*/
def apply(): ThreadPoolForComputationScheduler = {
new ThreadPoolForComputationScheduler(rx.concurrency.Schedulers.threadPoolForComputation())
new ThreadPoolForComputationScheduler(rx.schedulers.Schedulers.threadPoolForComputation())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ object ThreadPoolForIOScheduler {
* Do not perform computational work on this scheduler. Use [[rx.lang.scala.schedulers.ThreadPoolForComputationScheduler]] instead.
*/
def apply(): ThreadPoolForIOScheduler = {
new ThreadPoolForIOScheduler(rx.concurrency.Schedulers.threadPoolForIO())
new ThreadPoolForIOScheduler(rx.schedulers.Schedulers.threadPoolForIO())
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* 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.lang.scala

import java.util.Calendar
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* 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.lang.scala
import scala.language.postfixOps
import org.junit.Assert._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* 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.lang.scala


Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* 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.lang.scala

import scala.concurrent.{Future, Await}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* 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.lang.scala

import org.junit.{Assert, Test}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* 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.lang.scala


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,25 @@
*/
package rx.android.concurrency;

import android.os.Handler;
import android.os.Looper;
import rx.Scheduler;
import android.os.Handler;

/**
* Schedulers that have Android specific functionality
* Deprecated. Package changed from rx.android.concurrency to rx.android.schedulers.
*
* @deprecated Use {@link rx.android.schedulers.AndroidSchedulers} instead. This will be removed before 1.0 release.
*/
@Deprecated
public class AndroidSchedulers {

private static final Scheduler MAIN_THREAD_SCHEDULER =
new HandlerThreadScheduler(new Handler(Looper.getMainLooper()));

private AndroidSchedulers(){

}

/**
* {@link Scheduler} which uses the provided {@link Handler} to execute an action
* @param handler The handler that will be used when executing the action
* @return A handler based scheduler
*/
@Deprecated
public static Scheduler handlerThread(final Handler handler) {
return new HandlerThreadScheduler(handler);
return rx.android.schedulers.AndroidSchedulers.handlerThread(handler);
}

/**
* {@link Scheduler} which will execute an action on the main Android UI thread.
*
* @return A Main {@link Looper} based scheduler
*/
@Deprecated
public static Scheduler mainThread() {
return MAIN_THREAD_SCHEDULER;
return rx.android.schedulers.AndroidSchedulers.mainThread();
}

}
Loading

0 comments on commit 73fc535

Please sign in to comment.