[vlc-devel] commit: Asynchronous timer API ( R??mi Denis-Courmont )

jpd at videolan.org jpd at videolan.org
Wed Jun 3 16:37:25 CEST 2009

On Wed, Jun 03, 2009 at 03:00:10PM +0200, R??mi Denis-Courmont wrote:
> The layout of VLC threading structures is supposed to be opaque to source
> code, and OS-dependent. The only reason it's exposed in vlc_threads.h is so
> that we don't need a pair of dedicated malloc()/free() for each and every
> thread, mutex, variable, spin, key and timer.

Providing an accessor would take care of that.

> In the first case, the compiler can be clever enough to alias realdata to
> data. In the second case, it cannot. Hence, the stack consumption should be
> the same. That is not to mention that the calling convention might well put
> both parameters in registers.

None of that is guaranteed, nor knowable without exhaustive survey,
and no more than clever clean up after avoidable action. I don't see
significant difference in cache line use whether that deref happens
before or after the calling branch.

> You're not supposed to change the data across calls. I put the opaque data
> in the structure instead of giving it up to the system because neither
> POSIX nor Win32 timers are compatible with void(*)(void *). As such, one
> level of indirection is required. Again, this is an implementation detail.

And so is whether to pass a vlc_timer_t * to the function. If there's
nothing in there for the callee to look at, it shouldn't be there. If
there's merely nothing to touch, it should be const.

More information about the vlc-devel mailing list