[vlc-devel] [RFC 0/2] New executor API

Rémi Denis-Courmont remi at remlab.net
Fri Aug 28 15:51:35 CEST 2020


Le perjantaina 28. elokuuta 2020, 11.25.16 EEST Alexandre Janniaux a écrit :
> > > > Besides, timing out is an error that deserves logging. Interrupt is
> > > > not.
> > > > So using the same callback for both purpose looks dubious to me.
> > > 
> > > The goal is simplicity.
> > 
> > By making things more complicated. Yeah right...
> 
> I agree with Remi, if you want simplicity, the best thing
> would be to limit the asynchronous framework to the
> asynchronous execution and signalling like almost every other
> asynchronous framework.
> 
> Especially since youǘe talked about some `future` object, and
> thus a pro-actor model which doesn't have ways to do
> signalling from the outside of the asynchronous framework to
> the task by itself in almost all implementation, and instead
> have each layer of promise being able to return either a result
> or an error that the future will catch, and an internal
> composition rule for each layer's result.
> 
> In the case the vlc_executor is killed, the preparser client
> needs to be killed first since it is using the executor, and
> thus can cancel its tasks internally directly, which might be
> at the middle of the preprocessing, at the beginning or right
> before the end. It's much less convoluted than having the
> preparser client use the vlc_executor to cancel the taks, which
> will just really call the preparser specific cancellation code
> anyway.

Yes exactly. All the complexity comes from the very disagreeable decision to 
have the runner rather than the owner keep track of the tasks. If the owner 
keeps track of its tasks, it can interrupt them (due to stop or time-out) 
directly, and the tasks can notify their complexition directly as well. 

It's not the first time that somebody implements a background runner in open-
source C code, e.g. <linux/workqueue.h>. All you need is:
- allocate runner,
- queue runnable to the runner,
- dequeue (cancel) runnable,
- wait for quiescent state of runnable,
- wait for quiescent state of whole runner,
- destroy runner.

Only the first function can fail and needs error handling. A runnable is just a 
single callback and either a pointer to itself or an opaque data pointer.

-- 
雷米‧德尼-库尔蒙
http://www.remlab.net/





More information about the vlc-devel mailing list