TagLib::String::null considered harmful
wheeler at kde.org
Fri Mar 7 16:30:46 CET 2008
Peter Hartley wrote:
> TagLib (1.4 and 1.5) is nearly, but not quite, thread-safe, in the sense
> of being able to read the metadata from two different files in two
> different threads at the same time without them interfering. (With a
> multi-core CPU or with good disk queueing, this should be faster than
> the single-threaded solution when scanning a large library.)
> AFAICS, the only thing stopping it being thread-safe (in that sense) [...]
That's not the only thing that's not thread safe in TagLib; all of the
singletons would have to be protected too.
I'll probably try to do a thread safety review for the next release,
there are two notable points:
- As Jeff said, this won't actually make things faster. On my Core Duo,
even only using one core, TagLib needs 1.3 seconds of CPU time to scan
my collection with over 30 GB of MP3s. If you're actually hitting the
disk using two threads would probably slow things down since you'd just
make the read head jump around a lot.
- As Jeff also hit at one point, all sorts of badness happens if you
happen to be writing to the same file from multiple places (doesn't
matter if they're forks or threads or processes), so having TagLib
operations in their own (or the GUI) thread is probably a good thing.
More information about the taglib-devel