[FFmpeg-devel] parse_date using localtime etc.
Fri Feb 6 15:13:43 CET 2009
On Fri, Feb 06, 2009 at 02:47:05PM +0100, Michael Niedermayer wrote:
> On Fri, Feb 06, 2009 at 12:49:20PM +0100, Reimar D?ffinger wrote:
> > That does not solve anything (actually it creates even _more_ issues)
> > since you could pass the pointer to a different thread.
> and why would this be a problem?
> I definitly meant a non broken implementation of thread
> local storage, that is each thread stores its copy at a distinct address
> and thus a pointer to it would be valid in any thread.
The thread exits and then? Either you have a memleak or an invalid
pointer (that is the additional issue, and it means such an "improved"
version would not be 100% compatible).
There is also my argument that it would not work with custom cooperative
userspace-threading implementation, since the libc will not know of that
threading implementation (or to put it different, thread-local storage
means you can only use "the one approved" threading model you libc
Also when the same thread calls localtime it will change the contents of
all localtime() results it passed to other threads.
Also, independent of threading, the localtime API is using a global variable
(even if it is thread-local) with all the issues that has.
That's basically why I don't consider an improved but backwards-compatible
localtime anything but a time-wasting hack that's not going to work
right anyway but confuse people and give them a false sense of security.
More information about the ffmpeg-devel