Mojo · Threads and Polling

Threads and Polling

from ucall import Polling, CPUClass 1.0.0-rc.1 · 60202332

The binding starts no threads and keeps no queues; the application polls every event loop, batch endpoint and client on threads it owns. A route handler runs on the thread inside take_call or take_calls for its event loop, and a batch handler on the thread inside take_batches for its endpoint. On the polling thread nothing arrives while a handler runs, so a pull finding nothing there raises WOULD_BLOCK instead of waiting, and a streamed body is read from another thread.

API

StructPollingWhat Server.take_call found of its event loop. Binding-only.
struct Polling

Fields

codec_intWhich of the two it is.

Values

SERVINGPolling(Int32(0))The loop serves, or drains what it holds after a stop.
RETIREDPolling(Int32(1))The loop drained or cut everything after Server.stop, so a caller polling in slices stops.

Conforms to

Copyable, Deinitable, Equatable, ImplicitlyCopyable, Movable, RegisterPassable, TrivialRegisterPassable
StructCPUClassA CPU kernel bundle, ucall_cpu_class_t in C. Library.cpu_class_name spells each one.
struct CPUClass

Fields

codec_intThe raw ucall_cpu_class_t value the ABI exchanges.

Values

UNKNOWNCPUClass(Int32(0))No class requested: initialization picks the best class this machine runs.
SERIALCPUClass(Int32(1))Portable kernels with no SIMD, which every machine runs.
INTEL_HASWELLCPUClass(Int32(2))AVX2 kernels, as on Intel Haswell.
INTEL_SKYLAKECPUClass(Int32(3))Adds AVX-512 kernels, as on Intel Skylake-X.
INTEL_ICELAKECPUClass(Int32(4))Adds Ice Lake's AVX-512 extensions and SHA.
INTEL_ALDERCPUClass(Int32(5))AVX2 kernels with SHA and no AVX-512, as on Intel Alder Lake.
AWS_G2CPUClass(Int32(6))NEON kernels with the AES and SHA extensions, as on AWS Graviton2.
AWS_G5CPUClass(Int32(7))As on AWS Graviton5, running the kernels of AWS_G2.
MONOVERSIONEDCPUClass(Int32(8))The one class a monoversioned build compiles, over every capability it targets.

Conforms to

Copyable, Deinitable, Equatable, ImplicitlyCopyable, Movable, RegisterPassable, TrivialRegisterPassable