standard asynchronous deferred-to-result syntax RFP

[email protected] (David Nicol) Thu, 14 Jul 2005 12:16:01 -0500
Newsgroups perl.perl6.language.flow,perl.dbi.dev,perl.qpsmtpd
Message-ID <[email protected]>
I have uploaded asynchronous::universal::ready and
asynchronous::universal::set_callback
to CPAN.  They are both entirely trivial packages with a mess of
documentation.  The
idea behind them is to support asynchonous frameworks in which the
immediate result
of passing away a message is a placeholder object with a ready method
that will return
a false value until its result message comes back, at which time the
placeholder upgrades
itself to a result.

To avoid mandating true ready methods for all objects in the cosmos that mi=
ght=20
get returned as the result of an asynchronous function,
asynchronous::universal::ready
provides a true ready method in UNIVERSAL.

set_callback presumes two interfaces to an asynchronous framework,
"set_callback"
for declaring a coderef that is supposed to be run when the
asynchronous function
completes.  Synchronous objects have already completed, so
UNIVERSAL::set_callback
runs the coderef immediately.  The other interface is a method
"callback_queue" which
would give direct, framework-dependent access to the callback queue on
an object, should
such a thing exist in the given asynchronous framework.=20
UNIVERSAL::callback_queue
returns an empty arrayref.

The hubristic hope is that authors of asynchronous frameworks will
standardize on these
interfaces:  ready, set_callback, callback_queue.

Thanks for listening, and I'll take my answer off the air. :-)


--=20
David L Nicol
Aesop's fables, with text-sensitive advertising:
http://cronos.advenge.com/pc/aesop/start.html