summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_thread.h
blob: b476f546864224ed6fb01d14e39c72f9e1acc886 (plain)
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
#ifndef _TOX_THREAD_H_
#define _TOX_THREAD_H_

class CToxThread
{
public:
	Tox *tox;
	ToxAV *toxAV;
	bool isConnected;
	bool isTerminated;

	mir_cs toxLock;

	CToxThread() : tox(NULL), toxAV(NULL),
		isConnected(false), isTerminated(false) { }

	void Do()
	{
		{
			mir_cslock lock(toxLock);
			tox_iterate(tox);
			//if (toxAV)
			//	toxav_iterate(toxAV);
		}
		uint32_t interval = tox_iteration_interval(tox);
		interval ++; /* Prevent zero sleep interval. */
		Sleep(interval);
	}

	void Stop() { isTerminated = true; }
};

#endif //_TOX_THREAD_H_