8000 Final Changes In Preparation For 1.0 Release by adamgfraser · Pull Request #4046 · zio/zio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Final Changes In Preparation For 1.0 Release #4046

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
Aug 3, 2020
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: 0 additions & 2 deletions benchmarks/src/main/scala/zio/internal/BenchUtils.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package zio.internal

import zio.internal.impls._

object BenchUtils {
def queueByType[A](
tpe: BenchQueueType,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
package zio.internal.impls

import zio.internal.MutableConcurrentQueue
package zio.internal

/**
* JCToolsQueue is defined only under `benchmarks` so `coreJVM` doesn't
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package zio.internal.impls
package zio.internal

import java.util.concurrent.LinkedBlockingQueue

import zio.internal.MutableConcurrentQueue

class JucBlockingQueue[A] extends MutableConcurrentQueue[A] {
override val capacity: Int = Int.MaxValue

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
package zio.internal.impls

import zio.internal.MutableConcurrentQueue
package zio.internal

class NotThreadSafeQueue[A](override val capacity: Int) extends MutableConcurrentQueue[A] {
private val buf: Array[AnyRef] = Array.ofDim[AnyRef](capacity)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package zio.internal.impls
package zio.internal

import java.util.concurrent.atomic.AtomicReference

import zio.internal.MutableConcurrentQueue

class OneElementConcQueueNoMetric[A] extends MutableConcurrentQueue[A] {
private[this] final val ref = new AtomicReference[AnyRef]()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import java.util.concurrent.TimeUnit

import org.openjdk.jmh.annotations._

import zio.internal.impls._

@OutputTimeUnit(TimeUnit.NANOSECONDS)
@BenchmarkMode(Array(Mode.AverageTime))
@Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ private[this] class RingBufferMethodDispatchBenchmark {

@Setup(Level.Trial)
def createQ(): Unit = {
q1 = impls.RingBufferPow2[QueueElement](qCapacity)
q2 = impls.RingBufferArb[QueueElement](qCapacity)
q3 = new impls.LinkedQueue[QueueElement]
q1 = RingBufferPow2[QueueElement](qCapacity)
q2 = RingBufferArb[QueueElement](qCapacity)
q3 = new LinkedQueue[QueueElement]
}

@Benchmark
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package zio.internal
import org.openjdk.jcstress.annotations._
import org.openjdk.jcstress.infra.results.{ IIII_Result, II_Result, I_Result }

import zio.internal.impls.OneElementConcurrentQueue

object OneElementConcurrentQueueConcurrencyTests {
/*
* Tests that offer writes are atomic (simple case, doesn't consider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package zio.internal
import org.openjdk.jcstress.annotations._
import org.openjdk.jcstress.infra.results.{ IIIIII_Result, IIII_Result, II_Result }

import zio.internal.impls.RingBufferArb

object RingBufferArbConcurrencyTests {
/*
* Tests that [[RingBufferArb.offer]] is atomic.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package zio.internal
import org.openjdk.jcstress.annotations._
import org.openjdk.jcstress.infra.results.{ IIIIII_Result, IIII_Result, II_Result }

import zio.internal.impls.RingBufferPow2

object RingBufferPow2ConcurrencyTests {
/*
* Tests that [[RingBufferPow2.offer]] is atomic.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
* limitations under the License.
*/

package zio.internal.impls
package zio.internal

import java.io.Serializable

import java.util.concurrent.atomic.{ AtomicBoolean, AtomicLong, AtomicReference }

import zio.internal.MutableConcurrentQueue

final class OneElementConcurrentQueue[A] extends MutableConcurrentQueue[A] with Serializable {
private[this] val ref = new AtomicReference[AnyRef]()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
* limitations under the License.
*/

package zio.internal.impls

import zio.internal.MutableConcurrentQueue
package zio.internal

object RingBuffer {

Expand All @@ -31,7 +29,7 @@ object RingBuffer {
}

/**
* See [[zio.internal.impls.RingBuffer]] for details
* See [[zio.internal.RingBuffer]] for details
* on design, tradeoffs, etc.
*/
final class RingBuffer[A](override final val capacity: Int) extends MutableConcurrentQueue[A] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package zio.internal.impls.padding;
package zio.internal;

import java.io.Serializable;
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
Expand Down
2 changes: 0 additions & 2 deletions core/jvm/src/main/scala/zio/internal/DefaultExecutors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,5 @@ private[internal] abstract class DefaultExecutors {
} catch {
case _: RejectedExecutionException => false
}

def here = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
* limitations under the License.
*/

package zio.internal.impls
package zio.internal

import java.io.Serializable
import java.util.concurrent.atomic.{ AtomicReference, LongAdder }

import zio.internal.MutableConcurrentQueue

/**
* This is a specialized implementation of MutableConcurrentQueue of
* capacity 1. Since capacity 1 queues are by default used under the
Expand All @@ -32,7 +30,7 @@ import zio.internal.MutableConcurrentQueue
* Allocating an object takes only 24 bytes + 8+ bytes in long adder (so 32+ bytes total),
* which is 15x less than the smallest RingBuffer.
*
* zio.internal.impls.OneElementConcurrentQueue object internals:
* zio.internal.OneElementConcurrentQueue object internals:
* OFFSET SIZE TYPE DESCRIPTION
* 0 4 (object header)
* 4 4 (object header)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
* limitations under the License.
*/

package zio.internal.impls
package zio.internal

import java.util.concurrent.atomic.AtomicLongArray

import zio.internal.impls.padding.MutableQueueFieldsPadding
import zio.internal.impls.padding.MutableQueueFieldsPadding.{ headUpdater, tailUpdater }
import zio.internal.MutableQueueFieldsPadding.{ headUpdater, tailUpdater }

object RingBuffer {

Expand Down Expand Up @@ -125,7 +124,7 @@ object RingBuffer {
* to do this except `Unsafe` is to use `AtomicLongFieldUpdater`,
* which is exactly what we have here.
*
* @see [[zio.internal.impls.padding.MutableQueueFieldsPadding]] for more details on padding
* @see [[zio.internal.MutableQueueFieldsPadding]] for more details on padding
* and object's memory layout.
*
* The design is heavily inspired by such libraries as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package zio.internal.impls
package zio.internal

final class RingBufferArb[A] private (capacity: Int) extends RingBuffer[A](capacity) {
protected def posToIdx(pos: Long, capacity: Int): Int = (pos % capacity.toLong).toInt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package zio.internal.impls
package zio.internal

final class RingBufferPow2[A](val requestedCapacity: Int)
extends RingBuffer[A](RingBuffer.nextPow2(requestedCapacity)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
* limitations under the License.
*/

package zio.internal.impls
package zio.internal

import java.io.Serializable
import java.util.concurrent.atomic.{ AtomicBoolean, AtomicLong, AtomicReference }

import zio.internal.MutableConcurrentQueue
import java.util.concurrent.atomic.{ AtomicBoolean, AtomicLong, AtomicReference }

final class OneElementConcurrentQueue[A] extends MutableConcurrentQueue[A] with Serializable {
private[this] val ref = new AtomicReference[AnyRef]()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
* limitations under the License.
*/

package zio.internal.impls

import zio.internal.MutableConcurrentQueue
package zio.internal

object RingBuffer {

Expand All @@ -31,7 +29,7 @@ object RingBuffer {
}

/**
* See [[zio.internal.impls.RingBuffer]] for details
* See [[zio.internal.RingBuffer]] for details
* on design, tradeoffs, etc.
*/
final class RingBuffer[A](override final val capacity: Int) extends MutableConcurrentQueue[A] {
Expand Down
88 changes: 64 additions & 24 deletions core/shared/src/main/scala/zio/Fiber.scala
Original file line number Diff line number Diff line change
Expand Up @@ -444,29 +444,52 @@ object Fiber extends FiberPlatformSpecific {
abstract class Internal[+E, +A] extends Synthetic[E, A]
}

/**
* A record containing information about a [[Fiber]].
*
* @param id The fiber's unique identifier
* @param interrupters The set of fibers attempting to interrupt the fiber or its ancestors.
* @param executor The [[zio.internal.Executor]] executing this fiber
* @param children The fiber's forked children.
*/
final case class Descriptor(
id: Fiber.Id,
status: Status,
interrupters: Set[Fiber.Id],
interruptStatus: InterruptStatus,
executor: Executor,
scope: ZScope[Exit[Any, Any]]
)

final case class Dump(
fiberId: Fiber.Id,
fiberName: Option[String],
status: Status,
trace: Option[ZTrace]
) extends Serializable {
sealed abstract class Descriptor {
def id: Fiber.Id
def status: Status
def interrupters: Set[Fiber.Id]
def interruptStatus: InterruptStatus
def executor: Executor
def scope: ZScope[Exit[Any, Any]]
}

object Descriptor {

/**
* A record containing information about a [[Fiber]].
*
* @param id The fiber's unique identifier
* @param interrupters The set of fibers attempting to interrupt the fiber or its ancestors.
* @param executor The [[zio.internal.Executor]] executing this fiber
* @param children The fiber's forked children.
*/
def apply(
id0: Fiber.Id,
status0: Status,
interrupters0: Set[Fiber.Id],
interruptStatus0: InterruptStatus,
executor0: Executor,
scope0: ZScope[Exit[Any, Any]]
): Descriptor =
new Descriptor {
def id: Fiber.Id = id0
def status: Status = status0
def interrupters: Set[Fiber.Id] = interrupters0
def interruptStatus: InterruptStatus = interruptStatus0
def executor: Executor = executor0
def scope: ZScope[Exit[Any, Any]] = scope0
}
}

sealed abstract class Dump extends Serializable { self =>

def fiberId: Fiber.Id

def fiberName: Option[String]

def status: Status

def trace: Option[ZTrace]

/**
* {{{
Expand All @@ -478,7 +501,24 @@ object Fiber extends FiberPlatformSpecific {
* at ...
* }}}
*/
def prettyPrintM: UIO[String] = FiberRenderer.prettyPrintM(this)
def prettyPrintM: UIO[String] =
FiberRenderer.prettyPrintM(self)
}

object Dump {
def apply(
fiberId0: Fiber.Id,
fiberName0: Option[String],
status0: Status,
trace0: Option[ZTrace]
): Dump =
new Dump {
def fiberId: Fiber.Id = fiberId0
def fiberName: Option[String] = fiberName0
def status: Status = status0
def trace: Option[ZTrace] = trace0
}

}

/**
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 @@ -43,7 +43,7 @@ final case class Reservation[-R, +E, +A](acquire: ZIO[R, E, A], release: Exit[An
* has been consumed, the resource will not be valid anymore and may fail with
* some checked error, as per the type of the functions provided by the resource.
*/
abstract class ZManaged[-R, +E, +A] extends Serializable { self =>
sealed abstract class ZManaged[-R, +E, +A] extends Serializable { self =>

/**
* The ZIO value that underlies this ZManaged value. To evaluate it, a ReleaseMap is
Expand Down
8 changes: 4 additions & 4 deletions core/shared/src/main/scala/zio/ZQueue.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import zio.internal.MutableConcurrentQueue
* type `EA`. The dequeueing operations may utilize an environment of type `RB` and may fail
* with errors of type `EB`.
*/
abstract class ZQueue[-RA, -RB, +EA, +EB, -A, +B] extends Serializable { self =>
sealed abstract class ZQueue[-RA, -RB, +EA, +EB, -A, +B] extends Serializable { self =>

/**
* Waits until the queue is shutdown.
Expand Down Expand Up @@ -653,7 +653,7 @@ object ZQueue {
*
* @note when possible use only power of 2 capacities; this will
* provide better performance by utilising an optimised version of
* the underlying [[zio.internal.impls.RingBuffer]].
* the underlying [[zio.internal.RingBuffer]].
*
* @param requestedCapacity capacity of the `Queue`
* @tparam A type of the `Queue`
Expand All @@ -668,7 +668,7 @@ object ZQueue {
*
* @note when possible use only power of 2 capacities; this will
* provide better performance by utilising an optimised version of
* the underlying [[zio.internal.impls.RingBuffer]].
* the underlying [[zio.internal.RingBuffer]].
*
* @param requestedCapacity capacity of the `Queue`
* @tparam A type of the `Queue`
Expand All @@ -684,7 +684,7 @@ object ZQueue {
*
* @note when possible use only power of 2 capacities; this will
* provide better performance by utilising an optimised version of
* the underlying [[zio.internal.impls.RingBuffer]].
* the underlying [[zio.internal.RingBuffer]].
*
* @param requestedCapacity capacity of the `Queue`
* @tparam A type of the `Queue`
Expand Down
Loading
0