File: cleaner.h

package info (click to toggle)
apt-cacher-ng 0.7.27-1~bpo70+1
  • links: PTS
  • area: main
  • in suites: wheezy-backports
  • size: 1,740 kB
  • sloc: cpp: 13,987; sh: 519; perl: 442; ansic: 414; makefile: 77
file content (48 lines) | stat: -rw-r--r-- 943 bytes parent folder | download | duplicates (7)
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
42
43
44
45
46
47
48
/*
 * cleaner.h
 *
 *  Created on: 05.02.2011
 *      Author: ed
 */

#ifndef CLEANER_H_
#define CLEANER_H_

#include "lockable.h"
#include <ctime>
#include <limits>

/**
 * @brief Primitive task scheduler for internal helper functions
 *
 * It's based on few assumptions: a) called methods are static,
 * b) called method return the next time they want to be called
 * c) called method can be run at any time without side-effects
 * (they have to check the need of their internal work by themselves)
 */
class cleaner : public condition
{
public:
	cleaner();
	void Init();
	virtual ~cleaner();

	void WorkLoop();
	void Stop();

	enum eType
	{
		TYPE_EXFILEITEM, TYPE_ACFGHOOKS, TYPE_EXDNS, TYPE_EXCONNS,
		TYPE_STOPSCHED, ETYPE_MAX
	};
	void ScheduleFor(time_t when, eType what);
	void dump_status();

private:
	pthread_t m_thr;
	time_t stamps[cleaner::ETYPE_MAX];
};

extern cleaner g_victor; // ... down to the nap

#endif /* CLEANER_H_ */