Skip to content
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

refactor(eval): get rid of OnFinish type alias b/c of bad naming #424

Merged
merged 1 commit into from Sep 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 9 additions & 11 deletions monix-eval/shared/src/main/scala/monix/eval/Task.scala
Expand Up @@ -1255,13 +1255,13 @@ object Task extends TaskInstances {
* execution (e.g. `asyncOnSuccess` and `asyncOnError`)
*
* **WARNING:** note that not only is this builder unsafe, but also
* unstable, as the [[OnFinish]] callback type is exposing volatile
* internal implementation details. This builder is meant to create
* unstable, as the callback type is exposing volatile internal
* implementation details. This builder is meant to create
* optimized asynchronous tasks, but for normal usage prefer
* [[Task.create]].
*/
def unsafeCreate[A](onFinish: OnFinish[A]): Task[A] =
Async(onFinish)
def unsafeCreate[A](register: (Context, Callback[A]) => Unit): Task[A] =
Async(register)

/** Converts the given Scala `Future` into a `Task`.
*
Expand Down Expand Up @@ -1506,11 +1506,6 @@ object Task extends TaskInstances {
*/
type FrameIndex = Int

/** Type alias representing callbacks for
* [[unsafeCreate asynchronous]] tasks.
*/
type OnFinish[+A] = (Context, Callback[A]) => Unit

/** Set of options for customizing the task's behavior.
*
* @param autoCancelableRunLoops should be set to `true` in
Expand Down Expand Up @@ -1754,9 +1749,12 @@ object Task extends TaskInstances {
* Unsafe to build directly, only use if you know what you're doing.
* For building `Async` instances safely, see [[create]].
*/
private[eval] final case class Async[+A](onFinish: OnFinish[A]) extends Task[A] {
private[eval] final case class Async[+A](
register: (Context, Callback[A]) => Unit)
extends Task[A] {

override def toString: String =
s"Task.Async($onFinish)"
s"Task.Async($register)"
}

/** Internal [[Task]] state that defers the evaluation of the
Expand Down
Expand Up @@ -17,7 +17,7 @@

package monix.eval.internal

import monix.eval.Task.{Async, Context, Error, Eval, FlatMap, FrameIndex, MemoizeSuspend, Now, OnFinish, Suspend, fromTry}
import monix.eval.Task.{Async, Context, Error, Eval, FlatMap, FrameIndex, MemoizeSuspend, Now, Suspend, fromTry}
import monix.eval.{Callback, Task}
import monix.execution.atomic.AtomicAny
import monix.execution.cancelables.StackedCancelable
Expand Down Expand Up @@ -145,7 +145,7 @@ private[eval] object TaskRunLoop {
rcb: RestartCallback,
bFirst: Bind,
bRest: CallStack,
onFinish: OnFinish[Any],
register: (Context, Callback[Any]) => Unit,
nextFrame: FrameIndex): Unit = {

if (!context.shouldCancel) {
Expand All @@ -163,7 +163,7 @@ private[eval] object TaskRunLoop {
// rcb reference might be null, so initializing
val restartCallback = if (rcb != null) rcb else new RestartCallback(context, cb)
restartCallback.prepare(bFirst, bRest)
onFinish(context, restartCallback)
register(context, restartCallback)
}
}

Expand Down
3 changes: 2 additions & 1 deletion project/MimaFilters.scala
Expand Up @@ -154,7 +154,8 @@ object MimaFilters {
exclude[MissingTypesProblem]("monix.eval.Coeval$Error"),
exclude[MissingTypesProblem]("monix.eval.Coeval$Now"),
exclude[ReversedAbstractMethodProblem]("monix.eval.internal.Transformation.apply"),
exclude[ReversedMissingMethodProblem]("monix.eval.TaskInstances.catsInstances")
exclude[ReversedMissingMethodProblem]("monix.eval.TaskInstances.catsInstances"),
exclude[DirectMissingMethodProblem]("monix.eval.Task#Async.onFinish")
)

/** `monix-react` 3.0.0 */
Expand Down