[PATCH] tevent and threads - infrastructure improvements.
Stefan (metze) Metzmacher
metze at samba.org
Wed Jul 22 22:52:15 UTC 2015
Hi Jeremy,
> The reason was that libev has the function:
>
> ev_async_send()
>
> which allows one thread to schedule a callback
> on the event loop of another thread.
>
> I knew this could be done in tevent, but didn't
> have an elegant (a matter of opinion of course :-)
> solution, so I coded one up. Here it is for your
> review.
>
> It has the advantage that if you don't need
> the functionality to schedule a callback
> on the event loop of another thread, you don't
> pay any costs in regular tevent usage.
>
> It adds 3 functions to tevent:
>
> int tevent_threaded_context_register(struct tevent_context *ev);
>
> which sets up the background data structures
> needed for the functionality.
>
> int tevent_threaded_context_unregister(struct tevent_context *ev);
>
> which tears them down again, and finally:
>
> int tevent_threaded_async_call(struct tevent_context *dest_ev_ctx,
> void (*callback_fn)(struct tevent_context *,
> void *),
> void **pp_private);
void ** is not valid in an argument list.
> which asynchronously schedules callback_fn to be invoked
> on the destination context under the thread that's running
> it's event loop.
This somehow feels unnatural in the tevent environment.
Something like this would be better:
struct tevent_context *tevent_thread_proxy_context(struct tevent_context
*main_ev);
The thread can then only schedule immediate events on the returned proxy
context, this will wakeup the main_ev and move the immediate events from
the proxy to the main_ev.
The immediate events can be preallocated in before starting the thread.
metze
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20150723/a96f81d8/signature.sig>
More information about the samba-technical
mailing list