8000 Rename Fiber.Id to FiberId by adamgfraser · Pull Request #5512 · zio/zio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Rename Fiber.Id to FiberId #5512

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
merged 2 commits into from
Sep 2, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core-tests/jvm/src/test/scala/zio/SerializableSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ object SerializableSpec extends ZIOBaseSpec {
assert(serializeAndDeserialize(cause))(equalTo(cause))
},
testSync("Cause.traced is serializable") {
val fiberId = Fiber.Id(0L, 0L)
val fiberId = FiberId(0L, 0L)
val cause = Cause.traced(Cause.fail("test"), ZTrace(fiberId, List.empty, List.empty, None))
assert(serializeAndDeserialize(cause))(equalTo(cause))
},
Expand Down Expand Up @@ -207,7 +207,7 @@ object SerializableSpec extends ZIOBaseSpec {
},
testSync("ZTrace is serializable") {
val trace = ZTrace(
Fiber.Id(0L, 0L),
FiberId(0L, 0L),
List(ZTraceElement.NoLocation("test")),
List(ZTraceElement.SourceLocation("file.scala", "Class", "method", 123)),
None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object ZSTMConcurrencyTests {
)
@State
class ConcurrentAcquireAndInterruptDone {
val promise: Promise[Nothing, Unit] = Promise.unsafeMake[Nothing, Unit](Fiber.Id.None)
val promise: Promise[Nothing, Unit] = Promise.unsafeMake[Nothing, Unit](FiberId.None)
val semaphore: Semaphore = runtime.unsafeRun(Semaphore.make(1L))
var fiber: Fiber[Nothing, Unit] = null.asInstanceOf[Fiber[Nothing, Unit]]

Expand Down Expand Up @@ -72,7 +72,7 @@ object ZSTMConcurrencyTests {
)
@State
class ConcurrentAcquireAndInterruptSuspend {
val promise: Promise[Nothing, Unit] = Promise.unsafeMake[Nothing, Unit](Fiber.Id.None)
val promise: Promise[Nothing, Unit] = Promise.unsafeMake[Nothing, Unit](FiberId.None)
val semaphore: Semaphore = runtime.unsafeRun(Semaphore.make(0L))
var fiber: Fiber[Nothing, Unit] = null.asInstanceOf[Fiber[Nothing, Unit]]

Expand Down Expand Up @@ -122,7 +122,7 @@ object ZSTMConcurrencyTests {
)
@State
class ConcurrentWithPermit {
val promise: Promise[Nothing, Unit] = Promise.unsafeMake[Nothing, Unit](Fiber.Id.None)
val promise: Promise[Nothing, Unit] = Promise.unsafeMake[Nothing, Unit](FiberId.None)
val semaphore: Semaphore = runtime.unsafeRun(Semaphore.make(1L))
var fiber: Fiber[Nothing, Unit] = null.asInstanceOf[Fiber[Nothing, Unit]]

Expand Down Expand Up @@ -162,7 +162,7 @@ object ZSTMConcurrencyTests {
)
@State
class ConcurrentWithPermitManaged {
val promise: Promise[Nothing, Unit] = Promise.unsafeMake[Nothing, Unit](Fiber.Id.None)
val promise: Promise[Nothing, Unit] = Promise.unsafeMake[Nothing, Unit](FiberId.None)
val semaphore: Semaphore = runtime.unsafeRun(Semaphore.make(1L))
var fiber: Fiber[Nothing, Unit] = null.asInstanceOf[Fiber[Nothing, Unit]]

Expand Down
10 changes: 5 additions & 5 deletions core-tests/shared/src/test/scala/zio/CauseSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ object CauseSpec extends ZIOBaseSpec {
} @@ zioTag(interruption),
test("Traced") {
check(causes) { cause1 =>
val trace1 = ZTrace(Fiber.Id(0L, 0L), Nil, Nil, None)
val trace1 = ZTrace(FiberId(0L, 0L), Nil, Nil, None)
val result = Cause.traced(cause1, trace1) match {
case Cause.Traced(cause2, trace2) => cause1 == cause2 && trace1 == trace2
case _ => false
Expand Down Expand Up @@ -209,7 +209,7 @@ object CauseSpec extends ZIOBaseSpec {
val failOrDie = Gen.elements[Throwable => Cause[Throwable]](Cause.fail, Cause.die)
check(throwable, failOrDie) { (e, makeCause) =>
val rootCause = makeCause(e)
val cause = Cause.traced(rootCause, ZTrace(Fiber.Id(0L, 0L), Nil, Nil, None))
val cause = Cause.traced(rootCause, ZTrace(FiberId(0L, 0L), Nil, Nil, None))
val causeMessage = e.getCause.getMessage
val throwableMessage = e.getMessage
val renderedCause = Cause.stackless(cause).prettyPrint
Expand Down Expand Up @@ -247,7 +247,7 @@ object CauseSpec extends ZIOBaseSpec {
(causes <*> causes <*> causes).flatMap { case (a, b, c) =>
Gen.elements(
(a, a),
(a, Cause.traced(a, ZTrace(Fiber.Id(0L, 0L), Nil, Nil, None))),
(a, Cause.traced(a, ZTrace(FiberId(0L, 0L), Nil, Nil, None))),
(Then(Then(a, b), c), Then(a, Then(b, c))),
(Then(a, Both(b, c)), Both(Then(a, b), Then(a, c))),
(Both(Both(a, b), c), Both(a, Both(b, c))),
Expand All @@ -265,8 +265,8 @@ object CauseSpec extends ZIOBaseSpec {
val errors: Gen[Has[Random] with Has[Sized], String] =
Gen.string

val fiberIds: Gen[Has[Random], Fiber.Id] =
Gen.long.zipWith(Gen.long)(Fiber.Id(_, _))
val fiberIds: Gen[Has[Random], FiberId] =
Gen.long.zipWith(Gen.long)(FiberId(_, _))

val throwables: Gen[Has[Random], Throwable] =
Gen.throwable
Expand Down
2 changes: 1 addition & 1 deletion core-tests/shared/src/test/scala/zio/FiberSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ object FiberSpec extends ZIOBaseSpec {
),
suite("`Fiber.join` on interrupted Fiber")(
test("is inner interruption") {
val fiberId = Fiber.Id(0L, 123L)
val fiberId = FiberId(0L, 123L)

for {
exit <- Fiber.interruptAs(fiberId).join.exit
Expand Down
4 changes: 2 additions & 2 deletions core-tests/shared/src/test/scala/zio/LoggingSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import scala.annotation.tailrec
object LoggingSpec extends ZIOBaseSpec {
final case class LogEntry(
trace: ZTraceElement,
fiberId: Fiber.Id,
fiberId: FiberId,
logLevel: LogLevel,
message: () => String,
context: Map[FiberRef.Runtime[_], AnyRef],
Expand All @@ -31,7 +31,7 @@ object LoggingSpec extends ZIOBaseSpec {
@tailrec
def apply(
trace: ZTraceElement,
fiberId: Fiber.Id,
fiberId: FiberId,
logLevel: LogLevel,
message: () => String,
context: Map[FiberRef.Runtime[_], AnyRef],
Expand Down
6 changes: 3 additions & 3 deletions core-tests/shared/src/test/scala/zio/ZIOSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ object ZIOSpec extends ZIOBaseSpec {
suite("done")(
test("Check done lifts exit result into IO") {

val fiberId = Fiber.Id(0L, 123L)
val fiberId = FiberId(0L, 123L)
val error = exampleError

for {
Expand Down Expand Up @@ -1651,7 +1651,7 @@ object ZIOSpec extends ZIOBaseSpec {
suite("orElse")(
test("does not recover from defects") {
val ex = new Exception("Died")
val fiberId = Fiber.Id(0L, 123L)
val fiberId = FiberId(0L, 123L)
implicit val canFail = CanFail
for {
plain <- (ZIO.die(ex) <> IO.unit).exit
Expand Down Expand Up @@ -3875,7 +3875,7 @@ object ZIOSpec extends ZIOBaseSpec {
for {
future <- ZIO.fail(new Throwable(new IllegalArgumentException)).toFuture
result <- ZIO.fromFuture(_ => future).either
} yield assert(result)(isLeft(hasSuppressed(exists(hasMessage(containsString("Fiber:Id("))))))
} yield assert(result)(isLeft(hasSuppressed(exists(hasMessage(containsString("Fiber:FiberId("))))))
}
) @@ zioTag(future),
suite("resurrect")(
Expand Down
2 changes: 1 addition & 1 deletion core-tests/shared/src/test/scala/zio/ZManagedSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1876,7 +1876,7 @@ object ZManagedSpec extends ZIOBaseSpec {

def doInterrupt(
managed: IO[Nothing, Unit] => ZManaged[Any, Nothing, Unit],
expected: Fiber.Id => Option[Exit[Nothing, Unit]]
expected: FiberId => Option[Exit[Nothing, Unit]]
): ZIO[Has[Live], Nothing, TestResult] =
for {
fiberId <- ZIO.fiberId
Expand Down
4 changes: 2 additions & 2 deletions core/js/src/main/scala/zio/internal/PlatformSpecific.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package zio.internal

import zio.internal.stacktracer.{Tracer, ZTraceElement}
import zio.internal.tracing.TracingConfig
import zio.{Cause, Fiber, FiberRef, LogLevel, LogSpan, Supervisor}
import zio.{Cause, FiberId, FiberRef, LogLevel, LogSpan, Supervisor}

import java.util.{HashMap, HashSet, Map => JMap, Set => JSet}
import scala.concurrent.ExecutionContext
Expand Down Expand Up @@ -80,7 +80,7 @@ private[internal] trait PlatformSpecific {
val logger: ZLogger[Unit] =
(
trace: ZTraceElement,
fiberId: Fiber.Id,
fiberId: FiberId,
level: LogLevel,
message: () => String,
context: Map[FiberRef.Runtime[_], AnyRef],
Expand Down
4 changes: 2 additions & 2 deletions core/jvm/src/main/scala/zio/FiberPlatformSpecific.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private[zio] trait FiberPlatformSpecific {

final def getRef[A](ref: FiberRef.Runtime[A]): UIO[A] = UIO(ref.initial)

final def interruptAs(id: Fiber.Id): UIO[Exit[Throwable, A]] = join.fold(Exit.fail, Exit.succeed)
final def interruptAs(id: FiberId): UIO[Exit[Throwable, A]] = join.fold(Exit.fail, Exit.succeed)

final def inheritRefs: UIO[Unit] = IO.unit
}
Expand Down Expand Up @@ -70,7 +70,7 @@ private[zio] trait FiberPlatformSpecific {

def getRef[A](ref: FiberRef.Runtime[A]): UIO[A] = UIO(ref.initial)

def interruptAs(id: Fiber.Id): UIO[Exit[Throwable, A]] = join.fold(Exit.fail, Exit.succeed)
def interruptAs(id: FiberId): UIO[Exit[Throwable, A]] = join.fold(Exit.fail, Exit.succeed)

def inheritRefs: UIO[Unit] = UIO.unit
}
Expand Down
16 changes: 8 additions & 8 deletions core/shared/src/main/scala/zio/Cause.scala
F7B8
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ sealed abstract class Cause[+E] extends Product with Serializable { self =>
* Returns a set of interruptors, fibers that interrupted the fiber described
* by this `Cause`.
*/
final def interruptors: Set[Fiber.Id] =
foldLeft[Set[Fiber.Id]](Set()) { case (acc, Interrupt(fiberId)) =>
final def interruptors: Set[FiberId] =
foldLeft[Set[FiberId]](Set()) { case (acc, Interrupt(fiberId)) =>
acc + fiberId
}

Expand Down Expand Up @@ -193,7 +193,7 @@ sealed abstract class Cause[+E] extends Product with Serializable { self =>
empty: => Z,
failCase: E => Z,
dieCase: Throwable => Z,
interruptCase: Fiber.Id => Z
interruptCase: FiberId => Z
)(thenCase: (Z, Z) => Z, bothCase: (Z, Z) => Z, tracedCase: (Z, ZTrace) => Z): Z =
self match {
case Empty => empty
Expand Down Expand Up @@ -335,7 +335,7 @@ sealed abstract class Cause[+E] extends Product with Serializable { self =>
List(Failure("An unchecked error was produced." :: renderThrowable(t, maybeData) ++ renderTrace(maybeTrace)))
)

def renderInterrupt(fiberId: Fiber.Id, maybeTrace: Option[ZTrace]): Sequential =
def renderInterrupt(fiberId: FiberId, maybeTrace: Option[ZTrace]): Sequential =
Sequential(
List(Failure(s"An interrupt was produced by #${fiberId.seqNumber}." :: renderTrace(maybeTrace)))
)
Expand Down Expand Up @@ -550,7 +550,7 @@ object Cause extends Serializable {
val empty: Cause[Nothing] = Internal.Empty
def die(defect: Throwable): Cause[Nothing] = Internal.Die(defect)
def fail[E](error: E): Cause[E] = Internal.Fail(error)
def interrupt(fiberId: Fiber.Id): Cause[Nothing] = Internal.Interrupt(fiberId)
def interrupt(fiberId: FiberId): Cause[Nothing] = Internal.Interrupt(fiberId)
def stack[E](cause: Cause[E]): Cause[E] = Internal.Meta(cause, Internal.Data(false))
def stackless[E](cause: Cause[E]): Cause[E] = Internal.Meta(cause, Internal.Data(true))
def traced[E](cause: Cause[E], trace: ZTrace): Cause[E] = Internal.Traced(cause, trace)
Expand Down Expand Up @@ -657,9 +657,9 @@ object Cause extends Serializable {
}

object Interrupt {
def apply(fiberId: Fiber.Id): Cause[Nothing] =
def apply(fiberId: FiberId): Cause[Nothing] =
Internal.Interrupt(fiberId)
def unapply[E](cause: Cause[E]): Option[Fiber.Id] =
def unapply[E](cause: Cause[E]): Option[FiberId] =
cause.find {
case cause if cause eq Internal.Empty => None
case Internal.Fail(_) => None
Expand Down Expand Up @@ -751,7 +751,7 @@ object Cause extends Serializable {
}
}

final case class Interrupt(fiberId: Fiber.Id) extends Cause[Nothing] {
final case class Interrupt(fiberId: FiberId) extends Cause[Nothing] {
override def equals(that: Any): Boolean =
(this eq that.asInstanceOf[AnyRef]) || (that match {
case interrupt: Interrupt => fiberId == interrupt.fiberId
Expand Down
2 changes: 1 addition & 1 deletion core/shared/src/main/scala/zio/Exit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ object Exit extends Serializable {
final case class Success[+A](value: A) extends Exit[Nothing, A]
final case class Failure[+E](cause: Cause[E]) extends Exit[E, Nothing]

def interrupt(id: Fiber.Id): Exit[Nothing, Nothing] =
def interrupt(id: FiberId): Exit[Nothing, Nothing] =
failCause(Cause.interrupt(id))

def collectAll[E, A](exits: Iterable[Exit[E, A]]): Option[Exit[E, List[A]]] =
Expand Down
Loading
0