Closed topilski closed 6 years ago
Good question! Practically there is one reason: boost::thread::interrupt usage, but it came really handy. And, there are other boost libraries used in the project as well.
Can you show in your code where you using boost::thread::interrupt mechanism? And describe why it helpful?
Here it is:
inline void Shutdown(const std::unique_ptr
Basically it is described here how it is helpful: http://www.boost.org/doc/libs/1_66_0/doc/html/thread/thread_management.html#thread.thread_management.tutorial.interruption
In two words, it greatly simplifies thread termination. Due to this, it turned out to be easier just to restart threads during movie rewinding.
Sorry, there is another place where interrupt is used: in bool FFmpegDecoder::resetDecoding(...)
In any way if you call interrupt function you don't know how to stop your working thread from another thread? but it is wrong way, you should know lifetime of your thread and should know how to stop thread properly (may be stop flag, may be condition_variable notification or something else), or i something misunderstand?
In this line you have infinite loop, https://github.com/aliakseis/FFmpegPlayer/blob/6e6daeffb32b8d44dada4180505026e7e0752a0f/video/videoparserunnable.cpp#L65 but may be better have stop flag, than interrupt functionality?
boost::thread::interrupt gives more than a flag functionality http://www.boost.org/doc/libs/1_66_0/doc/html/thread/thread_management.html#thread.thread_management.tutorial.interruption.predefined_interruption_points If a thread stays waiting on one of these points, it will be terminated automatically right away.
cool, thank you for description!
Hi @aliakseis , i don't understand why you using boost, if the same functionality exists in std C++11 or higher.