Mercurial > minori
view include/gui/widgets/anime_info.h @ 390:2d3e10319112
http: optimize HTTP request thread
we don't need a mutex at all, in fact all we need is an atomic
boolean to signify whether the thread is cancelled.
curl options are now for the most part handled by a separate
function to keep them in sync between non-threaded and threaded
implementations
| author | Paper <paper@tflc.us> |
|---|---|
| date | Fri, 07 Nov 2025 07:08:57 -0500 |
| parents | 1e5d922fe82b |
| children |
line wrap: on
line source
#ifndef MINORI_GUI_WIDGETS_ANIME_INFO_H_ #define MINORI_GUI_WIDGETS_ANIME_INFO_H_ #include <QWidget> #include <QThread> #include "gui/widgets/text.h" #include <mutex> #include <queue> namespace Anime { class Anime; } class AnimeInfoWidgetGetMetadataThread final : public QThread { Q_OBJECT public: AnimeInfoWidgetGetMetadataThread(QObject* parent = nullptr); void AddToQueue(int id); signals: void NeedRefresh(int id); protected: void run() override; private: std::mutex queue_mutex_; std::queue<int> queue_; }; class AnimeInfoWidget final : public QWidget { Q_OBJECT public: AnimeInfoWidget(QWidget* parent = nullptr); AnimeInfoWidget(const Anime::Anime& anime, QWidget* parent = nullptr); ~AnimeInfoWidget(); void SetAnime(const Anime::Anime& anime); protected: void RefreshGenres(const Anime::Anime& anime); private: TextWidgets::OneLineSection _title; TextWidgets::LabelledSection _details; TextWidgets::SelectableSection _synopsis; int id_ = 0; }; #endif // MINORI_GUI_WIDGETS_ANIME_INFO_H_
