C# 클래스 Akka.Streams.Implementation.Fusing.GraphInterpreter

INTERNAL API From an external viewpoint, the GraphInterpreter takes an assembly of graph processing stages encoded as a Assembly object and provides facilities to execute and interact with this assembly. The lifecycle of the Interpreter is roughly the following: - Boundary logics are attached via AttachDownstreamBoundary and AttachUpstreamBoundary - Init is called - Execute is called whenever there is need for execution, providing an upper limit on the processed events - Finish is called before the interpreter is disposed, preferably after IsCompleted returned true, although in abort cases this is not strictly necessary The Execute method of the interpreter accepts an upper bound on the events it will process. After this limit is reached or there are no more pending events to be processed, the call returns. It is possible to inspect if there are unprocessed events left via the IsSuspended method. IsCompleted returns true once all stages reported completion inside the interpreter. The internal architecture of the interpreter is based on the usage of arrays and optimized for reducing allocations on the hot paths. One of the basic abstractions inside the interpreter is the notion of connection. In the abstract sense a connection represents an output-input port pair (an analogue for a connected RS Publisher-Subscriber pair), while in the practical sense a connection is a number which represents slots in certain arrays. In particular - portStates contains a bitfield that tracks the states of the ports (output-input) corresponding to this connection. This bitfield is used to decode the event that is in-flight. - connectionSlots is a mapping from a connection id to a potential element or exception that accompanies the event encoded in the portStates bitfield - inHandlers is a mapping from a connection id to the InHandlers instance that handles the events corresponding to the input port of the connection - outHandlers is a mapping from a connection id to the OutHandlers instance that handles the events corresponding to the output port of the connection On top of these lookup tables there is an eventQueue, represented as a circular buffer of integers. The integers it contains represents connections that have pending events to be processed. The pending event itself is encoded in the portStates bitfield. This implies that there can be only one event in flight for a given connection, which is true in almost all cases, except a complete-after-push or fail-after-push. The layout of the portStates bitfield is the following: |- state machn.-| Only one bit is hot among these bits 64 32 16 | 8 4 2 1 | +---+---+---|---+---+---+---| | | | | | | | | | | | | | | From the following flags only one is active in any given time. These bits encode | | | | | | | state machine states, and they are "moved" around using XOR masks to keep other bits | | | | | | | intact. | | | | | | | | | | | | | +- InReady: The input port is ready to be pulled | | | | | +----- Pulling: A pull is active, but have not arrived yet (queued) | | | | +--------- Pushing: A push is active, but have not arrived yet (queued) | | | +------------- OutReady: The output port is ready to be pushed | | | | | +----------------- InClosed: The input port is closed and will not receive any events. | | A push might be still in flight which will be then processed first. | +--------------------- OutClosed: The output port is closed and will not receive any events. +------------------------- InFailed: Always set in conjunction with InClosed. Indicates that the close event is a failure Sending an event is usually the following sequence: - An action is requested by a stage logic (push, pull, complete, etc.) - the state machine in portStates is transitioned from a ready state to a pending event - the id of the affected connection is enqueued Receiving an event is usually the following sequence: - id of connection to be processed is dequeued - the type of the event is determined from the bits set on portStates - the state machine in portStates is transitioned to a ready state - using the inHandlers/outHandlers table the corresponding callback is called on the stage logic. Because of the FIFO construction of the queue the interpreter is fair, i.e. a pending event is always executed after a bounded number of other events. This property, together with suspendability means that even infinite cycles can be modeled, or even dissolved (if preempted and a "stealing" external event is injected; for example the non-cycle edge of a balance is pulled, dissolving the original cycle).
파일 보기 프로젝트 열기: rogeralsing/akka.net

공개 프로퍼티들

프로퍼티 타입 설명
Assembly GraphAssembly
ConnectionSlots object[]
FuzzingMode bool
InHandlers IInHandler[]
IsDebug bool
Log ILoggingAdapter
Logics GraphStageLogic[]
Materializer IMaterializer
OnAsyncInput Action>
OutHandlers IOutHandler[]
PortStates int[]
RunningStagesCount int
SingleNoAttribute Attributes[]

Private Properties

프로퍼티 타입 설명
AfterStageHasRun void
Cancel void
Complete void
CompleteConnection void
Dequeue int
Enqueue void
Fail void
FinalizeStage void
InLogicName string
InOwnerName string
IsStageCompleted bool
OutLogicName string
OutOwnerName string
ProcessEvent void
Pull void
Push void
QueueStatus string
SafeLogics GraphStageLogic
SetKeepGoing void
ShutdownCounters string

공개 메소드들

메소드 설명
AttachDownstreamBoundary ( int connection, DownstreamBoundaryStageLogic logic ) : void

Assign the boundary logic to a given connection. This will serve as the interface to the external world (outside the interpreter) to process and inject events.

AttachUpstreamBoundary ( int connection, UpstreamBoundaryStageLogic logic ) : void

Assign the boundary logic to a given connection. This will serve as the interface to the external world (outside the interpreter) to process and inject events.

DumpWaits ( ) : void

Debug utility to dump the "waits-on" relationships in DOT format to the console for analysis of deadlocks. Only invoke this after the interpreter completely settled, otherwise the results might be off. This is a very simplistic tool, make sure you are understanding what you are doing and then it will serve you well.

Execute ( int eventLimit ) : void

Executes pending events until the given limit is met. If there were remaining events, IsSuspended will return true.

Finish ( ) : void

Finalizes the state of all stages by calling GraphStageLogic.PostStop (if necessary).

GraphInterpreter ( GraphAssembly assembly, IMaterializer materializer, ILoggingAdapter log, IInHandler inHandlers, IOutHandler outHandlers, GraphStageLogic logics, Action onAsyncInput, bool fuzzingMode ) : System
Init ( IMaterializer subMaterializer ) : void

Initializes the states of all the stage logics by calling GraphStageLogic.PreStart. The passed-in materializer is intended to be a SubFusingMaterializer that avoids creating new Actors when stages materialize sub-flows.If no such materializer is available, passing in null will reuse the normal materializer for the GraphInterpreter—fusing is only an optimization.

ProcessElement ( int connection ) : void
RunAsyncInput ( GraphStageLogic logic, object evt, Action handler ) : void
SetHandler ( int connection, IInHandler handler ) : void

Dynamic handler changes are communicated from a GraphStageLogic by this method.

SetHandler ( int connection, IOutHandler handler ) : void

Dynamic handler changes are communicated from a GraphStageLogic by this method.

비공개 메소드들

메소드 설명
AfterStageHasRun ( GraphStageLogic logic ) : void
Cancel ( int connection ) : void
Complete ( int connection ) : void
CompleteConnection ( int stageId ) : void

Register that a connection in which the given stage participated has been completed and therefore the stage itself might stop, too.

Dequeue ( ) : int
Enqueue ( int connection ) : void
Fail ( int connection, Exception reason ) : void
FinalizeStage ( GraphStageLogic logic ) : void
InLogicName ( int connection ) : string
InOwnerName ( int connection ) : string
IsStageCompleted ( GraphStageLogic stage ) : bool

Returns true if the given stage is alredy completed

OutLogicName ( int connection ) : string
OutOwnerName ( int connection ) : string
ProcessEvent ( int connection ) : void

Decodes and processes a single event for the given connection

Pull ( int connection ) : void
Push ( int connection, object element ) : void
QueueStatus ( ) : string
SafeLogics ( int id ) : GraphStageLogic
SetKeepGoing ( GraphStageLogic logic, bool enabled ) : void
ShutdownCounters ( ) : string

메소드 상세

AttachDownstreamBoundary() 공개 메소드

Assign the boundary logic to a given connection. This will serve as the interface to the external world (outside the interpreter) to process and inject events.
public AttachDownstreamBoundary ( int connection, DownstreamBoundaryStageLogic logic ) : void
connection int
logic DownstreamBoundaryStageLogic
리턴 void

AttachUpstreamBoundary() 공개 메소드

Assign the boundary logic to a given connection. This will serve as the interface to the external world (outside the interpreter) to process and inject events.
public AttachUpstreamBoundary ( int connection, UpstreamBoundaryStageLogic logic ) : void
connection int
logic UpstreamBoundaryStageLogic
리턴 void

DumpWaits() 공개 메소드

Debug utility to dump the "waits-on" relationships in DOT format to the console for analysis of deadlocks. Only invoke this after the interpreter completely settled, otherwise the results might be off. This is a very simplistic tool, make sure you are understanding what you are doing and then it will serve you well.
public DumpWaits ( ) : void
리턴 void

Execute() 공개 메소드

Executes pending events until the given limit is met. If there were remaining events, IsSuspended will return true.
public Execute ( int eventLimit ) : void
eventLimit int
리턴 void

Finish() 공개 메소드

Finalizes the state of all stages by calling GraphStageLogic.PostStop (if necessary).
public Finish ( ) : void
리턴 void

GraphInterpreter() 공개 메소드

public GraphInterpreter ( GraphAssembly assembly, IMaterializer materializer, ILoggingAdapter log, IInHandler inHandlers, IOutHandler outHandlers, GraphStageLogic logics, Action onAsyncInput, bool fuzzingMode ) : System
assembly GraphAssembly
materializer IMaterializer
log ILoggingAdapter
inHandlers IInHandler
outHandlers IOutHandler
logics GraphStageLogic
onAsyncInput Action
fuzzingMode bool
리턴 System

Init() 공개 메소드

Initializes the states of all the stage logics by calling GraphStageLogic.PreStart. The passed-in materializer is intended to be a SubFusingMaterializer that avoids creating new Actors when stages materialize sub-flows.If no such materializer is available, passing in null will reuse the normal materializer for the GraphInterpreter—fusing is only an optimization.
public Init ( IMaterializer subMaterializer ) : void
subMaterializer IMaterializer
리턴 void

ProcessElement() 공개 메소드

public ProcessElement ( int connection ) : void
connection int
리턴 void

RunAsyncInput() 공개 메소드

public RunAsyncInput ( GraphStageLogic logic, object evt, Action handler ) : void
logic GraphStageLogic
evt object
handler Action
리턴 void

SetHandler() 공개 메소드

Dynamic handler changes are communicated from a GraphStageLogic by this method.
public SetHandler ( int connection, IInHandler handler ) : void
connection int
handler IInHandler
리턴 void

SetHandler() 공개 메소드

Dynamic handler changes are communicated from a GraphStageLogic by this method.
public SetHandler ( int connection, IOutHandler handler ) : void
connection int
handler IOutHandler
리턴 void

프로퍼티 상세

Assembly 공개적으로 프로퍼티

public GraphAssembly Assembly
리턴 GraphAssembly

ConnectionSlots 공개적으로 프로퍼티

public object[] ConnectionSlots
리턴 object[]

FuzzingMode 공개적으로 프로퍼티

public bool FuzzingMode
리턴 bool

InHandlers 공개적으로 프로퍼티

public IInHandler[] InHandlers
리턴 IInHandler[]

IsDebug 공개적으로 정적으로 프로퍼티

public static bool IsDebug
리턴 bool

Log 공개적으로 프로퍼티

public ILoggingAdapter Log
리턴 ILoggingAdapter

Logics 공개적으로 프로퍼티

public GraphStageLogic[] Logics
리턴 GraphStageLogic[]

Materializer 공개적으로 프로퍼티

public IMaterializer Materializer
리턴 IMaterializer

OnAsyncInput 공개적으로 프로퍼티

public Action> OnAsyncInput
리턴 Action>

OutHandlers 공개적으로 프로퍼티

public IOutHandler[] OutHandlers
리턴 IOutHandler[]

PortStates 공개적으로 프로퍼티

public int[] PortStates
리턴 int[]

RunningStagesCount 공개적으로 프로퍼티

public int RunningStagesCount
리턴 int

SingleNoAttribute 공개적으로 정적으로 프로퍼티

public static Attributes[] SingleNoAttribute
리턴 Attributes[]