Class CallSlot
Represents a class that is immediately returned after transport sends RequestMsg.
This class provides CallStatus and RequestID properties where the later is used to match the incoming ResponseMsg.
CallSlots are kinds of "spirit-less" mailboxes that keep state about the call, but do not own any threads/call events.
Working with CallSlots from calling code's existing thread of execution is the most efficient way of working with Glue (in high load cases), as
it does not create extra object instances (tasks do) for asynchronous coordination and continuation.
It is possible to obtain an instance of CallSlot.AsTask in which case that instance is registered with the framework-internal reactor
so task does complete normally even on timeout, however, in high-throughput apps (10K+ calls per second) this method is not the most efficient one
as it allocates additional objects (task, list entry etc.) that eventually increase GC load for long runs.
Note: A 3.2 Ghz 4-Core I7 server with 8Gb of ram can easily handle 50K+ 2-way calls a second (given little business server logic and simple payload).
See also: CallReactor class
Inheritance
System.Object
CallSlot
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Assembly: Azos.dll
Syntax
public sealed class CallSlot
Constructors
CallSlot(ClientEndPoint, ClientTransport, RequestMsg, CallStatus, Int32)
INTERNAL METHOD. Developers do not call!
This constructor is used by an Async binding that delivers response after call slot was created
Declaration
public CallSlot(ClientEndPoint client, ClientTransport clientTransport, RequestMsg request, CallStatus status, int timeoutMs = 0)
Parameters
CallSlot(ClientEndPoint, ClientTransport, Int64, DateTime, RequestMsg, ResponseMsg, Int32)
INTERNAL METHOD. Developers do not call!
This constructor is used by a synchronous binding that delivers response right after sending it.
ONLY for OneWayCall = false
Declaration
public CallSlot(ClientEndPoint client, ClientTransport clientTransport, long actualStartTimeTicks, DateTime actualStartTimeUtc, RequestMsg request, ResponseMsg response, int timeoutMs)
Parameters
Fields
DEFAULT_TIMEOUT_MS
Declaration
public const int DEFAULT_TIMEOUT_MS = 20000
Field Value
Type |
Description |
System.Int32 |
|
Properties
AsTask
Gets the CallSlot instance as a task that gets completed either instantly for one-way calls or when result arrives or timeout happens.
The returned task never gets canceled
Declaration
public Task<CallSlot> AsTask { get; }
Property Value
Type |
Description |
System.Threading.Tasks.Task<CallSlot> |
|
Available
Returns true when response has come and available so no blocking will occur when reading response. This is a non-blocking call.
Always returns true for operations marked as [OneWay]
Declaration
public bool Available { get; }
Property Value
Type |
Description |
System.Boolean |
|
CallContext
General-purpose property that clients can use for attaching an arbitrary context to this instance. This property has no use in the framework
Declaration
public object CallContext { get; set; }
Property Value
Type |
Description |
System.Object |
|
CallStatus
Returns current call status. Timeout is returned when response has not arrived from the other side in allotted time. This is a non-blocking call
Declaration
public CallStatus CallStatus { get; }
Property Value
Client
Returns client endpoint that initiated this call
Declaration
public ClientEndPoint Client { get; }
Property Value
ClientTransport
Returns client transport that this instance is originated from
Declaration
public ClientTransport ClientTransport { get; }
Property Value
DispatchErrorMessage
Optionally returns reason of the dispatch message failure
Declaration
public string DispatchErrorMessage { get; }
Property Value
Type |
Description |
System.String |
|
OneWay
Indicates that this call does not expect a response message from the server side
Declaration
public bool OneWay { get; }
Property Value
Type |
Description |
System.Boolean |
|
RequestID
Returns request ID for the request that was sent and generated this slot instance
Declaration
public FID RequestID { get; }
Property Value
ResponseMsg
Blocks until response comes or timeout happens. Response message inspection happens in the context of a calling thread
Declaration
public ResponseMsg ResponseMsg { get; }
Property Value
StartTime
Returns UTC timestamp of call initiation
Declaration
public DateTime StartTime { get; }
Property Value
Type |
Description |
System.DateTime |
|
StatRoundtripEndTimeTicks
When binding's MeasureStatTimes enabled, returns the operation end (when response arrives) tick count
Declaration
public long StatRoundtripEndTimeTicks { get; }
Property Value
Type |
Description |
System.Int64 |
|
StatRoundtripTimeKey
When binding's MeasureStatTimes enabled, returns the name of the stat key
Declaration
public string StatRoundtripTimeKey { get; }
Property Value
Type |
Description |
System.String |
|
StatStartTimeTicks
When binding's MeasureStatTimes enabled, returns the operation start tick count
Declaration
public long StatStartTimeTicks { get; }
Property Value
Type |
Description |
System.Int64 |
|
TimeoutMs
Returns timeout for this instance
Declaration
public int TimeoutMs { get; }
Property Value
Type |
Description |
System.Int32 |
|
Methods
AsTaskReturning<TCallResult>()
Creates a wrapper task around CallSlot.AsTask and returns CallSlot.GetValue() as TCallResult-returning Task.
Note: the created wrapper task is not cached. For less allocations '(await slot).GetValue<T>()' instead
Declaration
public Task<TCallResult> AsTaskReturning<TCallResult>()
Returns
Type |
Description |
System.Threading.Tasks.Task<TCallResult> |
|
Type Parameters
Name |
Description |
TCallResult |
|
AsTaskReturningVoid()
Creates a wrapper task around CallSlot.AsTask and returns CallSlot.CheckVoidValue()
Note: the created wrapper task is not cached. For less allocations '(await slot).CheckVoidValue()' instead
Declaration
public Task AsTaskReturningVoid()
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
CheckVoidValue()
Checks for a valid void value returned from the other side, that is -
gets the response message and checks it for errors,
throwing RemoteError exception if one came from server.
Accessing this property blocks calling thread until either ResponseMsg arrives or timeout expires.
Check 'Available' property not to block. Accessing this method for [OneWay] methods throws.
Declaration
public void CheckVoidValue()
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
System.Object.Equals(System.Object)
GetAwaiter()
Awaits task status change - either timeout or value delivery. Already completed for one-way calls
Declaration
public TaskAwaiter<CallSlot> GetAwaiter()
Returns
Type |
Description |
System.Runtime.CompilerServices.TaskAwaiter<CallSlot> |
|
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type |
Description |
System.Int32 |
|
Overrides
System.Object.GetHashCode()
GetValue<T>()
Returns a value from the other side, that is -
gets the response message and checks it for errors,
throwing RemoteError exception if one came from server.
Accessing this property blocks calling thread until either ResponseMsg arrives or timeout expires.
Check 'Available' property not to block. Accessing this method for [OneWay] methods throws.
Declaration
Returns
Type Parameters
ToString()
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
Overrides
System.Object.ToString()
Extension Methods