summaryrefslogtreecommitdiff
path: root/src/downloadthread.cpp
blob: b1321d589825aa1e68e24acf890970322b5cb5f0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <downloadthread.h>
#include <logger.h>

namespace newsbeuter
{

downloadthread::downloadthread(controller * c, std::vector<int> * idxs) : ctrl(c) {
	if (idxs)
		indexes = *idxs;
}

downloadthread::~downloadthread() {
}

void downloadthread::run() {
	/*
	 * the downloadthread class drives the reload-all process.
	 * A downloadthread is spawned whenever "reload all" is invoked, and whenever an auto-reload
	 * comes up.
	 */
	LOG(LOG_DEBUG, "downloadthread::run: inside downloadthread, reloading all feeds...");
	if (ctrl->trylock_reload_mutex()) {
		if (indexes.size() == 0) {
			ctrl->reload_all();
		} else {
			ctrl->reload_indexes(indexes);
		}
		ctrl->unlock_reload_mutex();
	}
	this->detach();
}

reloadrangethread::reloadrangethread(controller * c, unsigned int start, unsigned int end, unsigned int size, bool unattended) : ctrl(c), s(start), e(end), ss(size), u(unattended)
{
}

void reloadrangethread::run() {
	ctrl->reload_range(s, e, ss, u);
}

}