[libdispatch-dev] Some questions about source handling

cee1 fykcee1 at gmail.com
Wed Sep 8 20:42:56 PDT 2010


Hi all,

Questions:

1. How does a source's event handler accesses data returned by kevent?

Data returned by kevent will finally be recorded is ds_data field in
_dispatch_source_latch_and_call. The event handler will be called with
ds_handler_ctxt, which shoule be do_ctxt. "do_ctxt" can be set by
function dispatch_set_context. The problem is:

   - If a handler need to access ds_data, we have to set a proper do_ctxt
   (e.g. a do_ctxt of source). That's not convenient.
   - "ds_data" is a member of dispatch_source_t, and dispatch_source_t is
   an opaque struct to client code.

2. We have custom source of type DISPATCH_SOURCE_TYPE_DATA_ADD
and DISPATCH_SOURCE_TYPE_DATA_OR, and can use dispatch_source_merge_data
to fire custom sources. Why we don't have an 'is_level' source?

An "is_level" source may not make much sense, but can be attached with
cancel handler, this may be useful in some cases.



-- 
Regards,

- cee1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/libdispatch-dev/attachments/20100909/088d3277/attachment.html>


More information about the libdispatch-dev mailing list