Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
13 changes: 13 additions & 0 deletions core-tests/jvm/src/test/scala/zio/SerializableSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ object SerializableSpec extends ZIOBaseSpec {
} yield assert(v1)(equalTo(10)) &&
assert(v2)(equalTo(20))
},
testM("Hub is serializable") {
for {
hub <- Hub.bounded[Int](100)
queue <- hub.subscribe.reserve.flatMap(_.acquire)
_ <- hub.publish(10)
tuple <- serializeAndBack((hub, queue))
(returnHub, returnQueue) = tuple
v1 <- returnQueue.take
_ <- returnHub.publish(20)
v2 <- returnQueue.take
} yield assert(v1)(equalTo(10)) &&
assert(v2)(equalTo(20))
},
testM("Ref is serializable") {
val current = "This is some value"
for {
Expand Down
2 changes: 1 addition & 1 deletion core/shared/src/main/scala-2.11/zio/NeedsEnv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import scala.annotation.implicitNotFound
"However, your effect has Any for the environment type, which means it " +
"has no requirement, so there is no need to provide the environment."
)
sealed abstract class NeedsEnv[+R]
sealed abstract class NeedsEnv[+R] extends Serializable

object NeedsEnv extends NeedsEnv[Nothing] {

Expand Down
2 changes: 1 addition & 1 deletion core/shared/src/main/scala-2.12-2.13/zio/NeedsEnv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import scala.annotation.implicitAmbiguous
* environment type `R` needs an environment, that is, that `R` is not equal to
* `Any`.
*/
sealed abstract class NeedsEnv[+R]
sealed abstract class NeedsEnv[+R] extends Serializable

object NeedsEnv extends NeedsEnv[Nothing] {

Expand Down
2 changes: 1 addition & 1 deletion core/shared/src/main/scala-dotty/zio/NeedsEnv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import scala.util.NotGiven
"However, your effect has Any for the environment type, which means it " +
"has no requirement, so there is no need to provide the environment."
)
sealed abstract class NeedsEnv[+R]
sealed abstract class NeedsEnv[+R] extends Serializable

object NeedsEnv extends NeedsEnv[Nothing] {

Expand Down
2 changes: 1 addition & 1 deletion core/shared/src/main/scala/zio/ZHub.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import java.util.concurrent.atomic.AtomicBoolean
* messages can require an environment of type `RB` and fail with an error of
* type `EB`.
*/
sealed trait ZHub[-RA, -RB, +EA, +EB, -A, +B] { self =>
sealed trait ZHub[-RA, -RB, +EA, +EB, -A, +B] extends Serializable { self =>

/**
* Waits for the hub to be shut down.
Expand Down
2 changes: 1 addition & 1 deletion core/shared/src/main/scala/zio/ZManaged.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ object ZManaged extends ZManagedPlatformSpecific {
* The design of `ReleaseMap` is inspired by ResourceT, written by Michael Snoyman @snoyberg.
* (https://github.com/snoyberg/conduit/blob/master/resourcet/Control/Monad/Trans/Resource/Internal.hs)
*/
abstract class ReleaseMap {
abstract class ReleaseMap extends Serializable {

/**
* An opaque identifier for a finalizer stored in the map.
Expand Down
4 changes: 2 additions & 2 deletions core/shared/src/main/scala/zio/internal/Hub.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import zio.Chunk
* guarantee that all subscribers will receive all values published to the hub
* while they are subscribed.
*/
abstract class Hub[A] {
abstract class Hub[A] extends Serializable {

/**
* The maximum capacity of the hub.
Expand Down Expand Up @@ -92,7 +92,7 @@ object Hub {
* The guarantee is that a subscriber will receive all values published to
* hub while it is subscribed.
*/
abstract class Subscription[A] {
abstract class Subscription[A] extends Serializable {

/**
* Checks whether there are values available to take from the hub.
Expand Down