summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_thread.h
blob: 892322b11c09980d4c7fd7987c0a8f3e376ecfae (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
#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_do(toxAv);
		}
		uint32_t interval = tox_iteration_interval(tox);
		Sleep(interval);
	}

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

#endif //_TOX_THREAD_H_