yacreader/YACReaderLibrary
Igor Kushnir cb7c967252 Add WorkerThread class and use it in ComicFlow
In a later commit WorkerThread should also replace classes similar to
ImageLoader: PageLoader, ImageLoaderGL and ImageLoaderByteArrayGL.

Bugs fixed:
  1. Eliminated a data race between ImageLoader::run() and
ComicFlow::updateImageData()->ImageLoader::result(). Specifically when
ImageLoader::busy() returns false, then ImageLoader::run() sets
ImageLoader::working to true, loads the image and starts assigning it to
ImageLoader::img, while ImageLoader::result() is accessed without
locking from updateImageData().
Making ImageLoader::working atomic is clearly insufficient to eliminate
this data race. The fix is to set 'working' to true immediately and
synchronously as soon as a new task is assigned to the worker.
  2. Replaced thread termination with graceful thread exit. ComicFlow
destructor called QThread::terminate(), using which is discouraged by Qt
documentation. The application exited without errors in Release mode.
In Debug mode, however, it received the SIG32 signal on exit and printed
the following warning - "QWaitCondition: mutex destroy failure:
Device or resource busy".
The loop in WorkerThread::run() is no longer endless. The worker thread
properly ends and is joined in WorkerThread destructor.

Design decisions:
 1. WorkerThread could emit a signal when it completes a task.
Thus updateTimer could be removed from ComicFlow and GoToFlow. However,
there is no obvious way to use this new signal in the two GL classes.
Also I don't know whether updateTimer is just an inefficient polling
substitute for notification or an intentional animation mechanism.
 2. The index variable is no longer stored in the worker class, but in
ComicFlow directly. Thing is, this data member was never actually
accessed by the worker, but ComicFlow went so far as to lock worker's
mutex to "protect" access to the index.
 3. The common ImageLoader implementation turned out to be very general.
So I converted it into the WorkerThread class template that is not
restricted to producing QImage results and can be reused elsewhere.
 4. I used standard classes (such as std::thread) instead of their Qt
equivalents (e.g. QThread) because they are more thoroughly documented.
The standard classes should also be more efficient as they were more
carefully designed and provide much fewer unnecessary features.
 5. Release-Acquire ordering is safe for the WorkerThread::working
use case and is more efficient than the std::atomic-default
Sequentially-consistent ordering.
 6. condition.notify_one() is called while the mutex is unlocked
to improve performance. This is safe in both cases:
  a) if the worker thread exits due to a spurious wakeup just before
the condition.notify_one() call in WorkerThread destructor, so much the
better;
  b) if a spurious wakeup lets the worker thread finish the task and
start waiting on the condition again just before the
condition.notify_one() call in WorkerThread::performTask(), the second
waking will be ignored by the worker thread as 'working' and 'abort'
will be false then.
2020-08-31 15:45:12 +02:00
..
comic_vine Fix object leaks in database code 2020-08-25 17:34:46 +02:00
db Use an invalid QVariant to set to NULL a value in the DB 2020-08-25 19:45:05 +02:00
qml Fix Potential fix for GridComicsView in Qt 13 2019-08-11 10:15:44 +02:00
server Headless server: Add support for setting a port from commandline 2020-08-29 18:21:06 +02:00
add_label_dialog.cpp Use auto to avoid duplicating the type name 2019-06-01 16:04:48 +02:00
add_label_dialog.h Annotate overridden methods 2019-06-01 16:04:48 +02:00
add_library_dialog.cpp Use auto to avoid duplicating the type name 2019-06-01 16:04:48 +02:00
add_library_dialog.h Use nullptr instead of 0 2019-06-01 16:04:48 +02:00
bundle_creator.cpp Format code using clang-format 2019-05-30 19:46:37 +02:00
bundle_creator.h Annotate overridden methods 2019-06-01 16:04:48 +02:00
classic_comics_view.cpp Use auto to avoid duplicating the type name 2019-06-01 16:04:48 +02:00
classic_comics_view.h Annotate overridden methods 2019-06-01 16:04:48 +02:00
comic_files_manager.cpp Format code using clang-format 2019-05-30 19:46:37 +02:00
comic_files_manager.h Use nullptr instead of 0 2019-06-01 16:04:48 +02:00
comic_flow_widget.cpp Use auto to avoid duplicating the type name 2019-06-01 16:04:48 +02:00
comic_flow_widget.h Annotate overridden methods 2019-06-01 16:04:48 +02:00
comic_flow.cpp Add WorkerThread class and use it in ComicFlow 2020-08-31 15:45:12 +02:00
comic_flow.h Add WorkerThread class and use it in ComicFlow 2020-08-31 15:45:12 +02:00
comics_remover.cpp Format code using clang-format 2019-05-30 19:46:37 +02:00
comics_remover.h Use nullptr instead of 0 2019-06-01 16:04:48 +02:00
comics_view_transition.cpp Format code using clang-format 2019-05-30 19:46:37 +02:00
comics_view_transition.h Annotate overridden methods 2019-06-01 16:04:48 +02:00
comics_view.cpp Use nullptr instead of 0 2019-06-01 16:04:48 +02:00
comics_view.h Annotate overridden methods 2019-06-01 16:04:48 +02:00
create_library_dialog.cpp Use auto to avoid duplicating the type name 2019-06-01 16:04:48 +02:00
create_library_dialog.h Use nullptr instead of 0 2019-06-01 16:04:48 +02:00
current_comic_view_helper.cpp Format code using clang-format 2019-05-30 19:46:37 +02:00
current_comic_view_helper.h Add .gitattributes rules for text and binary handling 2018-07-30 15:04:04 +02:00
db_helper.cpp Make updateFromRemoteClient return more updated comics 2020-08-25 19:01:43 +02:00
db_helper.h Make updateFromRemoteClient return more updated comics 2020-08-25 19:01:43 +02:00
empty_container_info.cpp Use auto to avoid duplicating the type name 2019-06-01 16:04:48 +02:00
empty_container_info.h Annotate overridden methods 2019-06-01 16:04:48 +02:00
empty_folder_widget.cpp Fix code format errors due to changes in default coding style. (#150) 2020-07-24 21:17:49 +02:00
empty_folder_widget.h Annotate overridden methods 2019-06-01 16:04:48 +02:00
empty_label_widget.cpp Format code using clang-format 2019-05-30 19:46:37 +02:00
empty_label_widget.h Use nullptr instead of 0 2019-06-01 16:04:48 +02:00
empty_reading_list_widget.cpp Format code using clang-format 2019-05-30 19:46:37 +02:00
empty_reading_list_widget.h Use nullptr instead of 0 2019-06-01 16:04:48 +02:00
empty_special_list.cpp Format code using clang-format 2019-05-30 19:46:37 +02:00
empty_special_list.h Use nullptr instead of 0 2019-06-01 16:04:48 +02:00
export_comics_info_dialog.cpp Use auto to avoid duplicating the type name 2019-06-01 16:04:48 +02:00
export_comics_info_dialog.h Annotate overridden methods 2019-06-01 16:04:48 +02:00
export_library_dialog.cpp Use auto to avoid duplicating the type name 2019-06-01 16:04:48 +02:00
export_library_dialog.h Use nullptr instead of 0 2019-06-01 16:04:48 +02:00
files.qrc Normalize line endings 2018-08-07 11:09:02 +02:00
grid_comics_view.cpp Add setting to disable the continue reading banner in the grid view 2019-08-11 11:47:14 +02:00
grid_comics_view.h Annotate overridden methods 2019-06-01 16:04:48 +02:00
icon2.ico yacreaderlibrary_ru.ts 2018-02-24 18:15:09 +00:00
icon3.ico yacreaderlibrary_ru.ts 2018-02-24 18:15:09 +00:00
icon.ico yacreaderlibrary_ru.ts 2018-02-24 18:15:09 +00:00
icon.rc yacreaderlibrary_ru.ts 2018-02-24 18:15:09 +00:00
images_osx.qrc A new trayicon is needed for macos 2019-09-20 13:41:26 +02:00
images_win.qrc Add better icons for the system tray in macos and windows 2019-09-20 10:07:20 +02:00
images.qrc yacreaderlibrary_ru.ts 2018-02-24 18:15:09 +00:00
import_comics_info_dialog.cpp Use auto to avoid duplicating the type name 2019-06-01 16:04:48 +02:00
import_comics_info_dialog.h Annotate overridden methods 2019-06-01 16:04:48 +02:00
import_library_dialog.cpp Use auto to avoid duplicating the type name 2019-06-01 16:04:48 +02:00
import_library_dialog.h Annotate overridden methods 2019-06-01 16:04:48 +02:00
import_widget.cpp Use auto to avoid duplicating the type name 2019-06-01 16:04:48 +02:00
import_widget.h Annotate overridden methods 2019-06-01 16:04:48 +02:00
info_comics_view.cpp Use auto to avoid duplicating the type name 2019-06-01 16:04:48 +02:00
info_comics_view.h Annotate overridden methods 2019-06-01 16:04:48 +02:00
Info.plist Disable darkmode for now 2019-08-31 09:35:32 +02:00
library_creator.cpp Fix object leaks in database code 2020-08-25 17:34:46 +02:00
library_creator.h Fix object leaks in database code 2020-08-25 17:34:46 +02:00
library_window.cpp Fix full screen mode in windows with qt 5.12.4+ 2019-09-28 10:11:44 +02:00
library_window.h Make closeApp work with no event 2019-09-21 12:11:03 +02:00
macostrayicon.svg Better macos tray icon 2019-09-20 16:38:11 +02:00
main.cpp Fix QsLog setup in Library and LibraryServer 2020-08-20 17:41:56 +02:00
no_libraries_widget.cpp Use auto to avoid duplicating the type name 2019-06-01 16:04:48 +02:00
no_libraries_widget.h Use nullptr instead of 0 2019-06-01 16:04:48 +02:00
no_search_results_widget.cpp Use auto to avoid duplicating the type name 2019-06-01 16:04:48 +02:00
no_search_results_widget.h Annotate overridden methods 2019-06-01 16:04:48 +02:00
options_dialog.cpp Update the UI string about system tray support 2019-09-21 10:45:34 +02:00
options_dialog.h Fixed more merge problems 2019-09-19 22:49:00 +02:00
package_manager.cpp Use nullptr instead of 0 2019-06-01 16:04:48 +02:00
package_manager.h Format code using clang-format 2019-05-30 19:46:37 +02:00
properties_dialog.cpp Fix object leaks in database code 2020-08-25 17:34:46 +02:00
properties_dialog.h Annotate overridden methods 2019-06-01 16:04:48 +02:00
qml_osx.qrc Fix qml qrc files 2018-08-15 14:43:14 +02:00
qml_win.qrc Fix qml qrc files 2018-08-15 14:43:14 +02:00
qml.qrc Add current/next comic view to GridView. 2018-04-23 19:22:51 +02:00
rename_library_dialog.cpp Use auto to avoid duplicating the type name 2019-06-01 16:04:48 +02:00
rename_library_dialog.h Use nullptr instead of 0 2019-06-01 16:04:48 +02:00
server_config_dialog.cpp Explicitly include <sys/socket.h> 2019-11-26 19:03:34 +00:00
server_config_dialog.h Format code using clang-format 2019-05-30 19:46:37 +02:00
trayhandler.h Add support for minimize and start to tray. 2019-09-19 20:22:14 +02:00
trayhandler.mm Add support for minimize and start to tray. 2019-09-19 20:22:14 +02:00
trayicon_controller.cpp Fix restoring the window from a minimized state 2019-09-22 15:04:54 +02:00
trayicon_controller.h Pass a more specific instance of our main window 2019-09-21 12:11:39 +02:00
yacreader_comic_info_helper.cpp Format code using clang-format 2019-05-30 19:46:37 +02:00
yacreader_comic_info_helper.h Use nullptr instead of 0 2019-06-01 16:04:48 +02:00
yacreader_comics_selection_helper.cpp Use nullptr instead of 0 2019-06-01 16:04:48 +02:00
yacreader_comics_selection_helper.h Use nullptr instead of 0 2019-06-01 16:04:48 +02:00
yacreader_comics_views_manager.cpp Format code using clang-format 2019-05-30 19:46:37 +02:00
yacreader_comics_views_manager.h Use nullptr instead of 0 2019-06-01 16:04:48 +02:00
yacreader_folders_view.cpp Format code using clang-format 2019-05-30 19:46:37 +02:00
yacreader_folders_view.h Annotate overridden methods 2019-06-01 16:04:48 +02:00
yacreader_history_controller.cpp Format code using clang-format 2019-05-30 19:46:37 +02:00
yacreader_history_controller.h Use nullptr instead of 0 2019-06-01 16:04:48 +02:00
yacreader_libraries.cpp Format code using clang-format 2019-05-30 19:46:37 +02:00
yacreader_libraries.h Format code using clang-format 2019-05-30 19:46:37 +02:00
yacreader_local_server.cpp Use auto to avoid duplicating the type name 2019-06-01 16:04:48 +02:00
yacreader_local_server.h Annotate overridden methods 2019-06-01 16:04:48 +02:00
yacreader_main_toolbar.cpp Format code using clang-format 2019-05-30 19:46:37 +02:00
yacreader_main_toolbar.h Annotate overridden methods 2019-06-01 16:04:48 +02:00
yacreader_navigation_controller.cpp Use nullptr instead of 0 2019-06-01 16:04:48 +02:00
yacreader_navigation_controller.h Format code using clang-format 2019-05-30 19:46:37 +02:00
yacreader_reading_lists_view.cpp Format code using clang-format 2019-05-30 19:46:37 +02:00
yacreader_reading_lists_view.h Annotate overridden methods 2019-06-01 16:04:48 +02:00
yacreaderlibrary_de.ts Update translations. 2018-06-16 08:28:50 +02:00
yacreaderlibrary_es.ts Update translations. 2018-06-16 08:28:50 +02:00
yacreaderlibrary_fr.ts Update translations. 2018-06-16 08:28:50 +02:00
yacreaderlibrary_nl.ts Update translations. 2018-06-16 08:28:50 +02:00
yacreaderlibrary_pt.ts Update translations. 2018-06-16 08:28:50 +02:00
yacreaderlibrary_ru.ts Update yacreaderlibrary_ru.ts 2018-08-25 07:49:51 +03:00
yacreaderlibrary_source.ts Update translations. 2018-06-16 08:28:50 +02:00
yacreaderlibrary_tr.ts Update translations. 2018-06-16 08:28:50 +02:00
YACReaderLibrary.icns yacreaderlibrary_ru.ts 2018-02-24 18:15:09 +00:00
YACReaderLibrary.pro Add WorkerThread class and use it in ComicFlow 2020-08-31 15:45:12 +02:00