aboutsummaryrefslogtreecommitdiff
path: root/plugins/Fourchan.hpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-06-01 21:36:58 +0200
committerdec05eba <dec05eba@protonmail.com>2020-06-01 21:36:58 +0200
commit4b97ef51562df8d606cb8fe21cf9b4464767febb (patch)
tree4a574191ba6c5575cac00f499cbd534ab6196c5d /plugins/Fourchan.hpp
parent83e7fac934fd33bc264ff88fa2459cade9749ceb (diff)
Improve 4chan thread list performance by asynchronous update and caching
Diffstat (limited to 'plugins/Fourchan.hpp')
-rw-r--r--plugins/Fourchan.hpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/plugins/Fourchan.hpp b/plugins/Fourchan.hpp
index 6534cfd..7b76f83 100644
--- a/plugins/Fourchan.hpp
+++ b/plugins/Fourchan.hpp
@@ -1,11 +1,15 @@
#pragma once
#include "ImageBoard.hpp"
+#include <thread>
+#include <mutex>
+#include <condition_variable>
namespace QuickMedia {
class Fourchan : public ImageBoard {
public:
- Fourchan() : ImageBoard("4chan") {}
+ Fourchan();
+ ~Fourchan() override;
PluginResult get_front_page(BodyItems &result_items) override;
SearchResult search(const std::string &url, BodyItems &result_items) override;
SuggestionResult update_search_suggestions(const std::string &text, BodyItems &result_items) override;
@@ -17,5 +21,22 @@ namespace QuickMedia {
int get_search_delay() const override { return 150; }
Page get_page_after_search() const override { return Page::IMAGE_BOARD_THREAD_LIST; }
bool search_is_filter() override { return true; }
+ private:
+ PluginResult get_threads_internal(const std::string &url, BodyItems &result_items);
+ void set_board_url(const std::string &new_url);
+ std::string get_board_url();
+ void set_board_thread_list(BodyItems body_items);
+ BodyItems get_board_thread_list();
+ private:
+ std::string current_board_url;
+ std::thread thread_list_update_thread;
+ BodyItems cached_thread_list_items;
+ std::mutex board_url_mutex;
+ std::mutex board_list_mutex;
+ std::condition_variable thread_list_cached_cv;
+ std::mutex thread_list_cache_mutex;
+ std::condition_variable thread_list_update_cv;
+ bool thread_list_cached = false;
+ bool running = true;
};
} \ No newline at end of file