thrift.async.base

Defines the interface used for client-side handling of asynchronous I/O operations, based on coroutines.

The main piece of the »client side« (e.g. for TAsyncClient users) of the API is TFuture, which represents an asynchronously executed operation, which can have a return value, throw exceptions, and which can be waited upon.

On the »implementation side«, the idea is that by using a TAsyncTransport instead of a normal TTransport and executing the work through a TAsyncManager, the same code as for synchronous I/O can be used for asynchronous operation as well, for example:

auto socket = new TAsyncSocket(someTAsyncSocketManager(), host, port);
// …
socket.asyncManager.execute(socket, {
  SomeThriftStruct s;

  // Waiting for socket I/O will not block an entire thread but cause
  // the async manager to execute another task in the meantime, because
  // we are using TAsyncSocket instead of TSocket.
  s.read(socket);

  // Do something with s, e.g. set a TPromise result to it.
  writeln(s);
});

Members

Aliases

TSocketEventListener
alias TSocketEventListener = void delegate(TAsyncEventReason callReason)

The type of the delegates used to register socket event handlers.

Enums

TAsyncEventReason
enum TAsyncEventReason

The reason a listener was called.

TAsyncEventType
enum TAsyncEventType

Types of events that can happen for an asynchronous transport.

Interfaces

TAsyncManager
interface TAsyncManager

Manages one or more asynchronous transport resources (e.g. sockets in the case of TAsyncSocketManager) and allows work items to be submitted for them.

TAsyncSocketManager
interface TAsyncSocketManager

A TAsyncManager providing notificiations for socket events.

TAsyncTransport
interface TAsyncTransport

A TTransport which uses a TAsyncManager to schedule non-blocking operations.

Meta