public inbox for [email protected]
 help / color / mirror / Atom feed
From: Alviro Iskandar Setiawan <[email protected]>
To: Ammar Faizi <[email protected]>
Cc: Alviro Iskandar Setiawan <[email protected]>,
	GNU/Weeb Mailing List <[email protected]>
Subject: [PATCH] Scraper: don't make runScrapers() be class method
Date: Sat, 14 Aug 2021 13:40:42 +0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

Don't plug runScrapers() inside the class Scraper, this can be inlined
inside Scraper::run().

Cc: Ammar Faizi <[email protected]>
Cc: GNU/Weeb Mailing List <[email protected]>
Link: https://gwml.gnuweeb.org/pipermail/gwml/20210813/000068.html
Signed-off-by: Alviro Iskandar Setiawan <[email protected]>
---
 src/tgvisd/Scraper.cpp | 10 +++++-----
 src/tgvisd/Scraper.hpp |  4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/tgvisd/Scraper.cpp b/src/tgvisd/Scraper.cpp
index c8e5c92..b5dfedd 100644
--- a/src/tgvisd/Scraper.cpp
+++ b/src/tgvisd/Scraper.cpp
@@ -42,7 +42,7 @@ Scraper::~Scraper(void)
 }
 
 
-void Scraper::runScrapers(void)
+static void runScrapers(Scraper *sc)
 {
 	// auto st = db->prepare("SELECT eeee;");
 	// st->execute();
@@ -58,10 +58,10 @@ void Scraper::runScrapers(void)
 	// }
 	// sleep(1);
 
-	chatScraper_ = new tgvisd::Scrapers::ChatScraper(this);
+	sc->chatScraper_ = new tgvisd::Scrapers::ChatScraper(sc);
 
-	std::thread chatScraper([this]{
-		this->chatScraper_->run();
+	std::thread chatScraper([sc]{
+		sc->chatScraper_->run();
 	});
 	chatScraper.join();
 }
@@ -75,7 +75,7 @@ void Scraper::run(void)
 	}
 
 	try {
-		runScrapers();
+		runScrapers(this);
 	} catch (std::runtime_error &e) {
 		pr_err("std::runtime_error: %s", e.what());
 		main_->doStop();
diff --git a/src/tgvisd/Scraper.hpp b/src/tgvisd/Scraper.hpp
index a7308d0..1d019e2 100644
--- a/src/tgvisd/Scraper.hpp
+++ b/src/tgvisd/Scraper.hpp
@@ -30,10 +30,10 @@ public:
 		return main_;
 	}
 
+	tgvisd::Scrapers::ChatScraper *chatScraper_ = nullptr;
+
 private:
-	void runScrapers(void);
 	Main *main_ = nullptr;
-	tgvisd::Scrapers::ChatScraper *chatScraper_ = nullptr;
 };
 
 } /* namespace tgvisd */
-- 
2.30.2

-- 
GWML mailing list
[email protected]
https://gwml.gnuweeb.org/listinfo/gwml

  reply	other threads:[~2021-08-14  6:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13 14:37 [PATCH] generic scraper: add chat scraper Alviro Iskandar Setiawan
2021-08-13 14:37 ` Alviro Iskandar Setiawan
2021-08-13 16:45   ` Ammar Faizi
2021-08-14  6:40     ` [PATCH] Scraper: don't make runScrapers() be class method Alviro Iskandar Setiawan
2021-08-14  6:40       ` Alviro Iskandar Setiawan [this message]
2021-08-14  7:01         ` Ammar Faizi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox