essentia icon indicating copy to clipboard operation
essentia copied to clipboard

Make Logger objects thread safe using a mutex.

Open svenoaks opened this issue 10 years ago • 4 comments

svenoaks avatar May 10 '14 20:05 svenoaks

unfortunately, std::mutex comes only with C++11 and Essentia still needs to support older compilers, so it won't be possible to merge that... However you could replace it with an essentia::MutexLocker (https://github.com/MTG/essentia/blob/master/src/essentia/threading.h#L43) and then I would merge it. (an example here: https://github.com/MTG/essentia/blob/master/src/essentia/streaming/phantombuffer.h#L169)

It is better to use the mutexlocker rather that mutex.lock() and mutex.unlock() directly for this reason: http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization

You will also note that at the moment, the implementations for Mutex and MutexLocker are empty, due to the fact that essentia 2.0 only supports running a network in a single-thread. If you wanted to run them multithreaded, you would need to add an #ifdef to threading.h and provide a real implementation for Mutex and MutexLocker (the same as ForcedMutex and ForcedMutexLocker, actually). But the benefits of doing that are unclear, see my comments in your other issue.

wackou avatar May 13 '14 20:05 wackou

Reopening this, as we are C++11 by now.

dbogdanov avatar Feb 02 '21 02:02 dbogdanov

There is any update here? I'm having the same issues reported on #798 .

LarissaGuder avatar Apr 06 '23 02:04 LarissaGuder

Would this fix the annoying [ WARNING ] No network created, or last created network has been deleted... message?

mijohansen avatar Jun 05 '24 11:06 mijohansen