|
Þ briarpig » aelig |
|
Async event is here
written æ, but this glyph is
pronounced ash, and the html character entity is
written æ (note uppercase
Æ is
Æ).
abstract An intro to this page appears 25nov07 in the log. History appears in a treedragon archive page on events. Context for stacks on callstacks provides runtime background. This page overviews async event dispatching with heap-based spaghetti stacks for async function calls. Each event is just a call frame in such a stack, so the term frame means event. recipe Take a large chunk of address space, perhaps in shared memory, then (according to some config spec) statically divide it into fixed size pools of buffers, message queues, event frames, backtrace entries and maps, and producer/consumer allocation queues. Make populations in tens of thousands work, especially for queues. Be threadsafe given more than one thread or process. Manage memory with refcounting† and handles audited with backtraces to blame leaks on allocation contexts adding refs not later released. Include event stack call chains in backtrace context, not just C backtraces. Compose events by linking immutable refcounted frames in 'stack' lists sharing structure as trees living as long as refcounts say. Pass frames in hand to allocation methods for backtrace context. Allocate each queue with a plan of owning scope and names of callback handlers on frame entry and exit. (Wake threads in on-enter callbacks if they own queues.) Allocate each frame in an existing stack context (another frame) with a name denoting frame format, and a priority influencing dispatch, and a standard qid slot for the reply-to queue used in replies when requested. Let a null qid indicate one-way messages needing no reply. Let apps add more frame state at need to marshall parameters. Maintain hidden state like timestamps to track usage stats. Support standard frame requests like pings to test liveness, stops to cancel requests, and kills to terminate queues. |
menu
Choose one of these demos for sample code and related docs, developed together to motivate þ C++ code for this purpose. mu: toy, peg, imm, tag, box, symbol, token, number, bigint, class, method, reader, writer, eval, env, vm, gc, world, pcode, compiler, asm, lathe, lisp, smalltalk, design, weight, jar, card, harp, debug, profile thorn: todo, names, iovec, assert, log, run, hex, crc, buf, in, out, quote, escape, compare, file, deck, cow, arc, blob, tree, slice, rand, time, stat, heap, node, primes, page, book, pile, stack, atomic, lock, mutex, thread, map, meter, list, iter, ctype The new mu menu links future toy language pages. Many demos are stubs; see todo for a thorn demo guide, or toy for mu updates. Also see names for an overview of naming schemes. lambda ash thorn The official λþ codename for Lathe (Lisp atop the þ runtime) might also be written in form λæþ to note async event support as described on this page. While æ is just part of þ, it's a part that can be used by external systems to speak with þ, and can bridge other runtimes to þ as a layer. For example, native OS facilities would normally interact with þ via æ events. interfaces I designed a similar async event system in my day job using namespace ae, also using terms for programming language call stacks, with a C interface quite different from the C++ interface used in þ. I'll cover neither interface here beyond basic jargon applying to any API. A real spec needs orders of magnitude more detail. Here I give only a view from ten thousand feet. A single conceptual scheme is common to both: it's really just generic message queueing, with events as messages. terms An async message sent to a queue is an event, which is an activation record for a single async function: one frame in a call stack of such events. A qid (queue id) plays the role of function pointer, so the return address continuation in a frame is just the qid of the reply-to queue. A context breadcrumb per frame supports stack backtraces for blame auditing. (Comparing to email: a queue is a mailbox, an (event) frame is single email, a qid is an address, a breadcrumb is a message ID, and an event stack backtrace is an email thread of references.) pending Todo: this page needs a few hundred more words of summary (as of 25nov2007). |