All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sttp.client4.internal.httpclient.FutureSequencer.scala Maven / Gradle / Ivy

The newest version!
package sttp.client4.internal.httpclient

import java.util.concurrent.Semaphore
import scala.concurrent.{blocking, ExecutionContext, Future}

private[client4] class FutureSequencer(implicit ec: ExecutionContext) extends Sequencer[Future] {
  private val semaphore = new Semaphore(1)

  def apply[T](t: => Future[T]): Future[T] = {
    blocking {
      semaphore.acquire()
    }
    t.andThen { case _ => semaphore.release() }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy