We have an application with multiple threads. In the current implementation, at start, thread1 is created and wakes up periodically (every second or so, it is configured) to check the disk for potentially saved files. These files are saved by another thread, thread2 . This launch of thread1 and its periodic awakening can slow down the application.
Now we have the opportunity to use the boost :: condition variable to put thread1 in the lock until thread2 notifies it. In doing so, you must create a flag to avoid unnecessary notification from thread2 , and this flag must be synchronized and checked with high frequency (hundreds in a few seconds) on thread2 . Or thread1 will be notified every time a recording occurs.
My questions are here:
In the implementation of boost :: condition, thread1 you still need to wake up often to check the flag, and the difference is that the implementation is hidden from us, but it actually does. I'm right? Does a similar API in Windows and Java do the same?
What happens if a thread is notified often many times, even if it is not in a wait state?
In my case, will this improve overall performance by switching to boost :: condition implementation? My opinion is no.
source
share