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

Add message to requirements #4259

Merged
merged 1 commit into from
Jan 28, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ final class TestContext private (_seed: Long) extends ExecutionContext { self =>
}

def advance(time: FiniteDuration): Unit = {
require(time > Duration.Zero)
require(time > Duration.Zero, "time must be > 0")
stateRef.currentNanos.addAndGet(time.toNanos)
()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ object Backpressure {
strategy: Strategy,
bound: Int
)(implicit GC: GenConcurrent[F, ?]): F[Backpressure[F]] = {
require(bound > 0)
require(bound > 0, "bound must be > 0")
val notAcquired: F[None.type] = GC.pure(None)

Semaphore[F](bound.toLong).map(sem =>
Expand Down
11 changes: 7 additions & 4 deletions std/shared/src/main/scala/cats/effect/std/Queue.scala
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ object Queue {
*/
def unsafeBounded[F[_], A](capacity: Int)(
implicit F: Async[F]): F[unsafe.BoundedQueue[F, A]] = {
require(capacity > 1 && capacity < Short.MaxValue.toInt * 2)
require(
capacity > 1 && capacity < Short.MaxValue.toInt * 2,
"capacity must be > 1 and < 32768"
)
F.delay(new BoundedAsyncQueue(capacity))
}

Expand Down Expand Up @@ -509,7 +512,7 @@ object Queue {
implicit F: GenConcurrent[F, ?]
) extends AbstractQueue(capacity, state) {

require(capacity > 0)
require(capacity > 0, "capacity must be > 0")

protected def onOfferNoCapacity(
s: State[F, A],
Expand Down Expand Up @@ -595,7 +598,7 @@ object Queue {
private abstract class BaseBoundedAsyncQueue[F[_], A](capacity: Int)(implicit F: Async[F])
extends Queue[F, A] {

require(capacity > 1)
require(capacity > 1, "capacity must be > 1")

protected[this] val buffer = new UnsafeBounded[A](capacity)

Expand Down Expand Up @@ -1009,7 +1012,7 @@ object Queue {

// ported with love from https://github.com/JCTools/JCTools/blob/master/jctools-core/src/main/java/org/jctools/queues/MpmcArrayQueue.java
private[effect] final class UnsafeBounded[A](bound: Int) {
require(bound > 1)
require(bound > 1, "bound must be > 1")

private[this] val buffer = new Array[AnyRef](bound)

Expand Down
Loading