sttp.client4.httpclient.monix.MonixSequencer.scala Maven / Gradle / Ivy
package sttp.client4.httpclient.monix
import cats.effect.Concurrent
import cats.effect.concurrent.Semaphore
import monix.eval.Task
import sttp.client4.internal.httpclient.Sequencer
private[monix] class MonixSequencer(s: Semaphore[Task]) extends Sequencer[Task] {
override def apply[T](t: => Task[T]): Task[T] = s.withPermit(t)
}
private[monix] object MonixSequencer {
def create(implicit c: Concurrent[Task]): Task[MonixSequencer] = Semaphore(1).map(new MonixSequencer(_))
}