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. |
||
---|---|---|
ci/win | ||
common | ||
compressed_archive | ||
custom_widgets | ||
dependencies | ||
files | ||
images | ||
release | ||
shortcuts_management | ||
tests/compressed_archive_test | ||
third_party | ||
YACReader | ||
YACReaderLibrary | ||
YACReaderLibraryServer | ||
.clang-format | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
azure-pipelines-build-number.yml | ||
azure-pipelines-windows-template.yml | ||
azure-pipelines.yml | ||
background.png | ||
background@2x.png | ||
CHANGELOG.md | ||
cleanOSX.sh | ||
compileOSX.sh | ||
config.pri | ||
COPYING.txt | ||
dmg.json | ||
icon.icns | ||
INSTALL.md | ||
mktarball.sh | ||
README.md | ||
signapps.sh | ||
YACReader.1 | ||
YACReader.desktop | ||
YACReader.pro | ||
YACReader.svg | ||
YACReaderLibrary.1 | ||
YACReaderLibrary.desktop | ||
YACReaderLibrary.svg |
Build | Master | Develop |
---|---|---|
Code Validation | ||
Linux | ||
Windows x86 | ||
Windows x64 | ||
MacOS | ||
Publish Build |
YACReader
"Yet another comic reader"
License
This software has been developed by Luis Ángel San Martín Rodríguez (luisangelsm@gmail.com) under GPL v3 license (see COPYING.txt).
Getting YACReader
Official releases:
https://github.com/YACReader/yacreader/releases
As a package:
From OBS build service:
Building from source:
See INSTALL.md
Contact
- Project home page : www.yacreader.com
- e-mail:
- Social:
- Facebook - http://www.facebook.com/YACReader
- Twitter - https://twitter.com/yacreader
- YouTube - https://www.youtube.com/user/yacreader
- Instagram - https://www.instagram.com/yacreader/
If you need help or have any suggestion, please, send me an e-mail.
Contributing
If you are interested in contributing to the project the first step should be to contact me so we can plan together the best approach, you can send an e-mail or just open an issue in this repo. For small bug fixes it is usually ok to open a PR directly.
Contributions are not restricted to code, you can help the project by bringing new UI/UX ideas, designing new assets, writing manuals or tutorials, translating the apps, etc. If you are interested in DevOps, YACReader uses Azure Pipelines for CI/CD, any improvements in that area are welcome. Testing pre-releases is also really appreciated.
Code
YACReader uses clang-format
to ensure a common style and avoid deviances from it. CI checks this and will fail if the correct format is not used. clang-format
needs to be called recursively in all the folders because some of them have the own .clang-format
file, mainly to exclude changing the format in third-party libraries which are included in the source code. I recommend to configure your development tools to use clang-format
, you can try to use it manually, but please, do it always before committing changes. I recommend using QtCreator configured properly, you can find a tutorial here.
CI/CD
Any PR will be validated through CI, and it will not be merged if CI fails.
Pull Requests
The base and target branch for any PR should always be develop
.
Donations
YACReader is free but it needs money to keep being alive, so please, if you like YACReader, visit the home page and make a donation.