[getdns-api] PHP Language Bindings and Async Event Management
Hollenbeck, Scott
shollenbeck at verisign.com
Mon Apr 20 14:38:18 CEST 2015
> -----Original Message-----
> From: getdns-api [mailto:getdns-api-bounces at vpnc.org] On Behalf Of
> Melinda Shore
> Sent: Friday, April 17, 2015 3:05 PM
> To: getdns-api at vpnc.org
> Subject: Re: [getdns-api] PHP Language Bindings and Async Event
> Management
>
> On 4/17/15 10:27 AM, Hollenbeck, Scott wrote:
> > So, what's the best way to approach the event management operations
> > needed for asynchronous processing?
>
> I won't claim it's "best" (I'd like to see non-blocking callback
> processing, as well) but what I did in the Python bindings was
> to bind the event base to the context, and when the user issues
> a query I create a new event base only if there isn't one already.
> This allows <bignum> queries to be issued asynchronously against
> a given context. There's also a Context.run() method, which runs the
> event loop (and is blocking), and it's called at the user's pleasure.
> The run() method is the only place where the event loop is run.
So I did a little more reading of the getdns source code and I think I answered the question I sent a few minutes ago. It looks like getdns_context_destroy() will free any existing event base. So a basic flow of function calls could look like this:
When creating a context:
event_base_new()
getdns_extension_set_libevent_base()
Call async function like getdns_address() to enqueue calls
Call getdns_context_run() to process all enqueued calls.
Call getdns_context_destroy() when finished to free the context and the event base.
Does this sound right?
Scott
_______________________________________________
getdns-api mailing list
getdns-api at vpnc.org
More information about the spec
mailing list