Skip to content

runtime.operation

Palamecia edited this page Dec 4, 2022 · 1 revision

Module runtime.operation

Description

load runtime.operation

This module provides the Runtime.Operation abstraction used by the runtime scheduler to represent asynchronous I/O work and resume suspended coroutines.

Packages

Classes

Runtime.Operation

This class describe an asynchronous operation.

Operation objects represent asynchronous tasks executed by Runtime.Scheduler.

An operation encapsulates the logic required to perform a specific asynchronous action such as connecting, reading, writing or accepting connections.

The lifecycle of an operation is typically:

  1. Created by an endpoint asynchronous method
  2. Submitted to the scheduler using Runtime.Scheduler.suspend
  3. Executed until the operation blocks
  4. Suspended until the required socket event occurs
  5. Resumed by the scheduler
  6. Completed when the operation's result is available

This design allows asynchronous operations to be expressed in a sequential style using coroutines while the scheduler handles the underlying event loop and I/O readiness notifications.

Public members

Modifiers Member Description
const != Returns false if other is equal to this operation; otherwise returns true.
const == Returns true if other is equal to this operation; otherwise returns false.
const check Checks for completion. Returns true if the operation is completed; otherwise ...
const get Returns the operation result.
final const getCoroutine Returns the coroutine associated with the operation completion.
final const start Starts the asynchronous operation. The scheduler is the instance of Runtime.O...
final const to_async_operation Returns the pointer to the internal mint::AsyncOperation instance.

Protected members

Modifiers Member Description
const setup Returns the operation context pointer.

Package members

Modifiers Member Description
final const getLastResult Returns the result from the last operation completion.

Private members

Modifiers Member Description
final coroutine Internal associated coroutine.
final d_ptr Internal operation context pointer.
@ const g_lib Global library handle.

Descriptions

Runtime.Operation.!=

def (const self, const other)

Returns false if other is equal to this operation; otherwise returns true.

Runtime.Operation.==

def (const self, const other)

Returns true if other is equal to this operation; otherwise returns false.

Runtime.Operation.check

def (self, result)

Checks for completion. Returns true if the operation is completed; otherwise returns false. An exception may be raised on error and would be forwarded to the calling coroutine.

Runtime.Operation.coroutine

null

Internal associated coroutine.

Runtime.Operation.d_ptr

null

Internal operation context pointer.

Runtime.Operation.g_lib

lib ('libmint-runtime')

Global library handle.

Runtime.Operation.get

def (self)

Returns the operation result.

Runtime.Operation.getCoroutine

def (self)

Returns the coroutine associated with the operation completion.

Runtime.Operation.getLastResult

def (self)

Returns the result from the last operation completion.

Runtime.Operation.setup

def (self, scheduler)

Returns the operation context pointer.

Runtime.Operation.start

def (self, scheduler, coroutine)

Starts the asynchronous operation. The scheduler is the instance of Runtime.Scheduler that want to start the operation. The coroutine parameter provides the coroutine associated with the operation execution.

Runtime.Operation.to_async_operation

def (self)

Returns the pointer to the internal mint::AsyncOperation instance.

Clone this wiki locally