C++ · Design

Design

#include <ucall/types.hpp> 1.0.0-rc.1 · b7577426

Ask your coding agent about this page, or add the docs server to it

curl -s 'https://www.unum.cloud/docs/ucall/cpp/design.md' | claude -p "How would this fit my code?"

The interface is a thin layer over UCall’s native library, and every rule below follows from that.

  • Verbs share one name across languages. take_call, take_calls, take_batch, take_batches, submit and take_completed name the same calls in C++, Go, Python and Rust.
  • Blocking stays simple, deferring stays symmetric. A reply that is final on return answers a status_t, and one that may finish later answers a deferred that waits, is awaited through co_await call.wait(loop), or waits as it is destroyed, as Rust’s Deferred does when dropped.
  • Ownership is a type, not a flag. A reply takes its request_t, a destroyed request answers 500, a response_t frees itself, and a deferred never moves, so the stack or the coroutine frame holding it outlives the call.
  • Handlers stay the caller’s, never boxed. A function or a member is a template argument and an object or a callable with state stays the caller’s until the server or client is destroyed, so registration copies no closure, and every handler is noexcept, as no fault can unwind through the library.
  • Polling allocates nothing. Blocking verbs keep their outcome on the stack, a deferred call keeps it inside itself, and an awaiter posts two words, a function and its own address, into the caller’s scheduler, as Rust’s waker does. A server and a client hold their handles alone: the library hands each callback its server, and a blocking call takes its own completion out of the library’s queue.
  • No life of its own. The interface starts no threads, keeps no global state and needs no runtime, so it drops into any threading model.
PathRustC++
Blocking verb00
Each handler call00
Deferred reply or pull00, the deferred lives in the caller
Await00 in the binding
Route registration1 Box0
Client startcall tables0

API

Types

ownerOwns one handle of handle_type_, which free_ releases, moving it and never copying it.
types.hpp:240 ↗
template <typename handle_type_,
          void(*)(handle_type_) free_>
class owner