Channel

fs2.concurrent.Channel$
See theChannel companion trait
object Channel

Attributes

Companion
trait
Source
Channel.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Channel.type

Members list

Type members

Classlikes

object Closed

Attributes

Source
Channel.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Closed.type

Types

type Closed = Closed.type

Attributes

Source
Channel.scala

Value members

Concrete methods

def State.this._1 case1=> State.this._2 case2=> State.this._3 case3=> State.this._4 case4=> State.this._5 case_=> thrownewIndexOutOfBoundsException(n.toString()) } } objectStateextendsAnyRefwithProduct{ overridedeftoString:String="State" typeMirroredMonoType deffromProduct(`x$0₃`:Product):MirroredMonoType=newState(`x$0₃`.productElement(0).$asInstanceOf$[List[A]],`x$0₃`.productElement(1).$asInstanceOf$[Int],`x$0₃`.productElement(2).$asInstanceOf$[Option[Deferred[F,Unit]]],`x$0₃`.productElement(3).$asInstanceOf$[List[Tuple2[A,Deferred[F,Unit]]]],`x$0₃`.productElement(4).$asInstanceOf$[Boolean]) } valopen:State=State.apply(List.empty[A],0,None,List.empty[Tuple2[A,Deferred[F,Unit]]],closed=false) defempty(isClosed:Boolean):State=if(isClosed)State.apply(List.empty[A],0,None,List.empty[Tuple2[A,Deferred[F,Unit]]],closed=true)elseopen catsSyntaxTuple2Semigroupal[F,Ref[F,State],Deferred[F,Unit]](Tuple2.apply[F[Ref[F,State]],F[Deferred[F,Unit]]](F.ref[State](open),F.deferred[Unit])).mapN[Channel[F,A]](((state:Ref[F,State],closedGate:Deferred[F,Unit])=>{ finalclass$anon()extendsChannel[F,A]{ defsendAll:Pipe[F,A,Nothing]=((in:Stream[F,A])=>{ val$1$:Stream[[x>:Nothing<:Any]=>F[x],Either[Closed,Unit]]=in.++[[x>:Nothing<:Any]=>F[x],A](Stream.exec[F](toFunctorOps[F,Either[Closed,Unit]]($anon.this.close)(F).void)).evalMap[[x>:Nothing<:Any]=>F[x],Either[Closed,Unit]](((a:A)=>$anon.this.send(a))) $1$.takeWhile(((_$5:Either[Closed,Unit])=>_$5.isRight),$1$.takeWhile$default$2) }.drain) defsend(`a₂`:A):F[Either[Closed,Unit]]=toFlatMapOps[F,Deferred[F,Unit]](F.deferred[Unit])(F).flatMap[Either[Closed,Unit]](((producer:Deferred[F,Unit])=>state.flatModifyFull[Either[Closed,Unit]](((x$1:Poll[F],x$2:State)=>Tuple2.apply[Poll[F],State](x$1,x$2)match{ caseTuple2(poll,state)=> `state₂`match{ cases@State(_,_,_,_,closed@true)=> Tuple2.apply[State,F[Either[Closed,Unit]]](s,catsSyntaxApplicativeId[Either[Closed,Unit]](Channel.closed[Unit]).pure[F](F)) caseState(values,size,waiting,producers,closed@false)=> if(`size₂`.<(capacity))Tuple2.apply[State,F[Either[Closed,Unit]]](State.apply(`values₂`.::[A](`a₂`),`size₂`.+(1),None,`producers₂`,false),toFunctorOps[F,Option[Boolean]]($anon.this.notifyStream(`waiting₂`))(F).as[Either[Closed,Unit]](rightUnit))elseTuple2.apply[State,F[Either[Closed,Unit]]](State.apply(`values₂`,`size₂`,None,{ valelem$1:Tuple2[A,Deferred[F,Unit]]=Tuple2.apply[A,Deferred[F,Unit]](`a₂`,producer) `producers₂`.::[Tuple2[A,Deferred[F,Unit]]](elem$1) },false),catsSyntaxApply[F,Either[Closed,Unit]](toFunctorOps[F,Option[Boolean]]($anon.this.notifyStream(`waiting₂`))(F).as[Either[Closed,Unit]](rightUnit))(F).<*[Unit]($anon.this.waitOnBound(producer,poll))) } }))(F))) deftrySend(`a₃`:A):F[Either[Closed,Boolean]]=state.flatModify[Either[Closed,Boolean]](((`x$1₂`:State)=>`x$1₂`match{ cases@State(_,_,_,_,closed@true)=> Tuple2.apply[State,F[Either[Closed,Boolean]]](`s₂`,catsSyntaxApplicativeId[Either[Closed,Boolean]](Channel.closed[Boolean]).pure[F](F)) cases@State(values,size,waiting,producers,closed@false)=> if(`size₃`.<(capacity))Tuple2.apply[State,F[Either[Closed,Boolean]]](State.apply(`values₃`.::[A](`a₃`),`size₃`.+(1),None,`producers₃`,false),toFunctorOps[F,Option[Boolean]]($anon.this.notifyStream(`waiting₃`))(F).as[Either[Closed,Boolean]](rightTrue))elseTuple2.apply[State,F[Either[Closed,Boolean]]](`s₃`,catsSyntaxApplicativeId[Either[Closed,Boolean]](rightFalse).pure[F](F)) }))(F) defclose:F[Either[Closed,Unit]]=state.flatModify[Either[Closed,Unit]](((`x$1₃`:State)=>`x$1₃`match{ cases@State(_,_,_,_,closed@true)=> Tuple2.apply[State,F[Either[Closed,Unit]]](`s₄`,catsSyntaxApplicativeId[Either[Closed,Unit]](Channel.closed[Unit]).pure[F](F)) caseState(values,size,waiting,producers,closed@false)=> Tuple2.apply[State,F[Either[Closed,Unit]]](State.apply(`values₄`,`size₄`,None,`producers₄`,true),catsSyntaxApply[F,Either[Closed,Unit]](toFunctorOps[F,Option[Boolean]]($anon.this.notifyStream(`waiting₄`))(F).as[Either[Closed,Unit]](rightUnit))(F).<*[Boolean]($anon.this.signalClosure)) }))(F) defisClosed:F[Boolean]=toFunctorOps[F,Option[Unit]](closedGate.tryGet)(F).map[Boolean](((_$6:Option[Unit])=>_$6.isDefined)) defclosed:F[Unit]=closedGate.get defstream:Stream[F,A]=StreamPullOps[F,A]($anon.this.consumeLoop).stream defconsumeLoop:Pull[F,A,Unit]=catsSyntaxFlatten[[R>:Nothing<:Any]=>Pull[F,A,R],Unit](Pull.eval[F,Pull[F,A,Unit]](toFlatMapOps[F,Deferred[F,Unit]](F.deferred[Unit])(F).flatMap[Pull[F,A,Unit]](((`waiting₅`:Deferred[F,Unit])=>monadCancelOps_[F,Pull[F,A,Unit]](toFlatMapOps[F,State](state.modify[State](((`state₃`:State)=>if($anon.this.shouldEmit(`state₃`))Tuple2.apply[State,State](empty(`state₃`.closed),`state₃`)elseTuple2.apply[State,State]({ valwaiting$2:Option[Deferred[F,Unit]]=catsSyntaxOptionId[Deferred[F,Unit]](`waiting₅`).some valvalues$2:List[A]@uncheckedVariance=`state₃`.copy$default$1 valsize$2:Int@uncheckedVariance=`state₃`.copy$default$2 valproducers$2:List[Tuple2[A,Deferred[F,Unit]]]@uncheckedVariance=`state₃`.copy$default$4 valclosed$2:Boolean@uncheckedVariance=`state₃`.copy$default$5 `state₃`.copy(values$2,size$2,waiting=waiting$2,producers$2,closed$2) },`state₃`))))(F).flatMap[Pull[F,A,Unit]](((`x$1₄`:State)=>`x$1₄`match{ cases@State(initValues,stateSize,ignorePreviousWaiting,producers,closed)=> if($anon.this.shouldEmit(`s₅`)){ var`size₅`:Int=stateSize valtailValues:Builder[A,List[A]]=List.newBuilder[A] varunblock:F[Unit]=F.unit `producers₅`.foreach[Unit](((`x$1₅`:Tuple2[A,Deferred[F,Unit]])=>`x$1₅`match{ caseTuple2(value,producer)=> `size₅`=`size₅`.+(1) tailValues.+=(value) unblock=catsSyntaxApply[F,Unit](unblock)(F).<*[Boolean](`producer₂`.complete(())) })) valtoEmit:Chunk[A]=$anon.this.makeChunk(initValues,tailValues.result(),`size₅`) toFunctorOps[F,Unit](unblock)(F).as[Pull[F,A,Unit]](Pull.output[Nothing,A](toEmit).>>[F,A,Unit]($anon.this.consumeLoop)) }elseF.pure[Pull[F,A,Unit]](if(`closed₂`)Pull.doneelsePull.eval[F,Unit](`waiting₅`.get).>>[[x>:Nothing<:Any]=>F[x],A,Unit]($anon.this.consumeLoop)) }))).uncancelable(F)))))(monadErrorInstance[F,A]).flatten(monadErrorInstance[F,A]) defnotifyStream(waitForChanges:Option[Deferred[F,Unit]]):F[Option[Boolean]]=toTraverseOps[Option,Deferred[F,Unit]](waitForChanges)(catsTraverseForOption).traverse[F,Boolean](((_$7:Deferred[F,Unit])=>_$7.complete(())))(F) defwaitOnBound(`producer₃`:Deferred[F,Unit],`poll₂`:Poll[F]):F[Unit]=monadCancelOps_[F,Unit](`poll₂`.apply[Unit](`producer₃`.get)).onCancel(state.update(((`s₆`:State)=>{ valproducers$1:List[Tuple2[A,Deferred[F,Unit]]]=`s₆`.producers.filter(((_$8:Tuple2[A,Deferred[F,Unit]])=>_$8._2.ne(`producer₃`))) valvalues$1:List[A]@uncheckedVariance=`s₆`.copy$default$1 valsize$1:Int@uncheckedVariance=`s₆`.copy$default$2 valwaiting$1:Option[Deferred[F,Unit]]@uncheckedVariance=`s₆`.copy$default$3 valclosed$1:Boolean@uncheckedVariance=`s₆`.copy$default$5 `s₆`.copy(values$1,size$1,waiting$1,producers=producers$1,closed$1) })))(F) defsignalClosure:F[Boolean]=closedGate.complete(()) @inlinedefshouldEmit(`s₇`:State):Boolean=`s₇`.values.nonEmpty.||(`s₇`.producers.nonEmpty) defmakeChunk(init:List[A],tail:List[A],`size₆`:Int):Chunk[A]={ valarr:Array[Any]=newArray[Any](`size₆`) vari:Int=`size₆`.-(1) var`values₅`:List[A]=tail while(i.>=(0)){ if(`values₅`.isEmpty)`values₅`=initelse() arr.update(i,`values₅`.head) `values₅`=`values₅`.tail i=i.-(1) } Chunk.array[Any](arr)(ClassTag.Any).asInstanceOf[Chunk[A]] } } (new$anon():Channel[F,A]) }))(F,F) }" t="n"class="documentableName ">bounded[F[_], A](capacity: Int)(implicit F: Concurrent[F]): F[Channel[F, A]]

Attributes

Source
Channel.scala
def synchronous[F[_] : Concurrent, A]: F[Channel[F, A]]

Attributes

Source
Channel.scala
def unbounded[F[_] : Concurrent, A]: F[Channel[F, A]]

Attributes

Source
Channel.scala