yacreader/common
Igor Kushnir d869e1230b ConcurrentQueue::enqueue: increment jobsLeft before adding a job
ConcurrentQueueTest::randomCalls() built in Debug mode often crashes
when concurrent_queue_test.cpp is modified and ConcurrentQueueTest is
launched from Qt Creator so that the test is built and immediately run.
The crash is an assertion failure that occurs most of the time under
the described circumstances at different test data rows:
void YACReader::ConcurrentQueue::finalizeJobs(int): Assertion `jobsLeft >= count' failed.

The assertion fails because ConcurrentQueue::enqueue() adds a job into
the queue first and then increments jobsLeft. If the job is immediately
picked up and executed very fast, ConcurrentQueue::nextJob() can try to
finalize it before enqueue() increments jobsLeft.

Simply reordering the modifications of jobsLeft and _queue in enqueue()
ensures that jobsLeft is always non-negative and eliminates the
assertion failures. Note that ConcurrentQueue::finalizeJobs() is the
only other function that modifies (decreases) jobsLeft. finalizeJobs()
is always called *after* the queue's size is reduced. So the following
invariant is now maintained at all times and documented:
jobsLeft >= _queue.size().
2021-12-29 09:36:44 +01:00
..
gl Fix QtOpenGL* includes in Qt6 2021-10-19 00:00:08 +02:00
bookmarks.cpp Replace QDateTime constructor 2021-10-19 00:00:08 +02:00
bookmarks.h clang-format 2021-10-18 21:56:52 +02:00
check_new_version.cpp Include QRegExp explicitly 2021-10-19 00:00:08 +02:00
check_new_version.h Format code using clang-format 2019-05-30 19:46:37 +02:00
comic_db.cpp clang-format 2021-10-18 21:56:52 +02:00
comic_db.h Tag ComicDB::operator== as const 2021-10-19 00:00:08 +02:00
comic.cpp Don't use helper function to avoid raising the Qt5 min version requeriment 2021-10-19 00:00:08 +02:00
comic.h Don't use virtual methods unnecessarily 2021-10-19 00:00:08 +02:00
concurrent_queue.h ConcurrentQueue::enqueue: increment jobsLeft before adding a job 2021-12-29 09:36:44 +01:00
custom_widgets.cpp Add .gitattributes rules for text and binary handling 2018-07-30 15:04:04 +02:00
custom_widgets.h Format code using clang-format 2019-05-30 19:46:37 +02:00
exit_check.cpp Format code using clang-format 2019-05-30 19:46:37 +02:00
exit_check.h Format code using clang-format 2019-05-30 19:46:37 +02:00
folder.cpp Get/set new manga field from/to the db 2021-01-16 18:30:25 +01:00
folder.h clang-format 2021-10-18 21:56:52 +02:00
http_worker.cpp Clazy: Add second batch of SIGNAL/SLOT removal 2021-06-29 13:53:12 +02:00
http_worker.h Format code using clang-format 2019-05-30 19:46:37 +02:00
library_item.cpp Add .gitattributes rules for text and binary handling 2018-07-30 15:04:04 +02:00
library_item.h Format code using clang-format 2019-05-30 19:46:37 +02:00
onstart_flow_selection_dialog.cpp clang-format 2021-10-18 21:56:52 +02:00
onstart_flow_selection_dialog.h Format code using clang-format 2019-05-30 19:46:37 +02:00
opengl_checker.cpp clang-format 2021-10-18 21:56:52 +02:00
opengl_checker.h Format code using clang-format 2019-05-30 19:46:37 +02:00
pdf_comic.cpp clang-format 2021-10-18 21:56:52 +02:00
pdf_comic.h clang-format 2021-10-18 21:56:52 +02:00
pdf_comic.mm clang-format 2021-10-18 21:56:52 +02:00
pictureflow.cpp Use QElapsedTimer instead of QTime 2021-10-19 00:00:08 +02:00
pictureflow.h Use fully qualified names 2021-10-19 00:00:08 +02:00
qnaturalsorting.cpp Format code using clang-format 2019-05-30 19:46:37 +02:00
qnaturalsorting.h Exract struct to reuse it 2021-04-30 09:52:31 +02:00
release_acquire_atomic.h Format 2020-08-31 16:19:42 +02:00
scroll_management.cpp Use angleDelta instead of delta 2021-10-19 00:00:08 +02:00
scroll_management.h Use QElapsedTimer instead of QTime 2021-10-19 00:00:08 +02:00
worker_thread.h Format 2020-08-31 16:04:26 +02:00
yacreader_global_gui.cpp clang-format 2021-10-18 21:56:52 +02:00
yacreader_global_gui.h clang-format 2021-10-18 21:56:52 +02:00
yacreader_global.cpp Use non deprecated QStandardPaths and remove Qt4 alternative 2021-10-19 00:00:08 +02:00
yacreader_global.h Include QMetaType explicitly 2021-10-19 00:00:08 +02:00