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

Remove Use Of Interruptible #337

Merged
merged 4 commits into from
Sep 13, 2022
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
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Global / onChangedBuildSource := ReloadOnSourceChanges
addCommandAlias("fmt", "all scalafmtSbt scalafmt test:scalafmt")
addCommandAlias("check", "all scalafmtSbtCheck scalafmtCheck test:scalafmtCheck")

val zioVersion = "2.0.0"
val zioVersion = "2.0.2"
val rsVersion = "1.0.4"
val collCompatVersion = "2.7.0"

Expand Down
8 changes: 4 additions & 4 deletions src/main/scala/zio/interop/reactivestreams/Adapters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object Adapters {
if (subscriber == null) {
throw new NullPointerException("Subscriber must not be null.")
} else
unsafeCompat { implicit unsafe =>
unsafe { implicit unsafe =>
val subscription = new DemandTrackingSubscription(subscriber)
runtime.unsafe.fork(
for {
Expand All @@ -39,7 +39,7 @@ object Adapters {
def subscriberToSink[E <: Throwable, I](
subscriber: => Subscriber[I]
)(implicit trace: Trace): ZIO[Scope, Nothing, (E => UIO[Unit], ZSink[Any, Nothing, I, I, Unit])] =
unsafeCompat { implicit unsafe =>
unsafe { implicit unsafe =>
val sub = subscriber
for {
error <- Promise.make[E, Nothing]
Expand All @@ -59,7 +59,7 @@ object Adapters {
subscriberP <- makeSubscriber[O](bufferSize)
(subscriber, p) = subscriberP
_ <- ZIO.acquireRelease(ZIO.succeed(publisher.subscribe(subscriber)))(_ => ZIO.succeed(subscriber.interrupt()))
subQ <- p.await.interruptible
subQ <- p.await
(sub, q) = subQ
process <- process(sub, q, () => subscriber.await(), () => subscriber.isDone)
} yield process
Expand Down Expand Up @@ -134,7 +134,7 @@ object Adapters {
)(
_.poll.flatMap(_.fold(ZIO.unit)(_.foldZIO(_ => ZIO.unit, { case (sub, _) => ZIO.succeed(sub.cancel()) })))
)
} yield unsafeCompat { implicit unsafe =>
} yield unsafe { implicit unsafe =>
val subscriber =
new InterruptibleSubscriber[A] {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ object PublisherToStreamSpec extends ZIOSpecDefault {
} @@ TestAspect.timeout(3.seconds),
test("cancels subscription when interrupted before subscription") {
val tst =
Unsafe.unsafeCompat { implicit unsafe =>
Unsafe.unsafe { implicit unsafe =>
for {
subscriberP <- Promise.make[Nothing, Subscriber[_]]
cancelledLatch <- Promise.make[Nothing, Unit]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ object SinkToSubscriberSpec extends ZIOSpecDefault {
)

val makePublisherProbe =
Unsafe.unsafeCompat { implicit unsafe =>
Unsafe.unsafe { implicit unsafe =>
for {
subscribed <- Promise.make[Nothing, Unit]
requested <- Promise.make[Nothing, Unit]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object StreamToPublisherSpec extends ZIOSpecDefault {
new PublisherVerification[Int](new TestEnvironment(2000, 500), 2000L) {

def createPublisher(elements: Long): Publisher[Int] =
Unsafe.unsafeCompat { implicit unsafe =>
Unsafe.unsafe { implicit unsafe =>
runtime.unsafe
.run(
ZStream
Expand All @@ -32,7 +32,7 @@ object StreamToPublisherSpec extends ZIOSpecDefault {
}

override def createFailedPublisher(): Publisher[Int] =
Unsafe.unsafeCompat { implicit unsafe =>
Unsafe.unsafe { implicit unsafe =>
runtime.unsafe
.run(
ZStream
Expand Down