-
Notifications
You must be signed in to change notification settings - Fork 39
/
SelectScheduler.h
executable file
·54 lines (39 loc) · 1.23 KB
/
SelectScheduler.h
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
49
50
51
52
53
54
/**************************************************************
* Copyright (c) 2010-2013, Dynamic Network Services, Inc.
* Jake Montgomery ([email protected]) & Tom Daly ([email protected])
* Distributed under the FreeBSD License - see LICENSE
***************************************************************/
/**
Scheduler implementation for system with select, but without kevent..
*/
#pragma once
#include "config.h"
#ifndef USE_KEVENT_SCHEDULER
#include "SchedulerBase.h"
#include <vector>
#include <set>
class SelectScheduler : public SchedulerBase
{
public:
public:
/**
* Constructor
* The thread that calls this is considered the "main thread". See
* Scheduler::IsMainThread().
*/
SelectScheduler();
virtual ~SelectScheduler();
protected:
/** Overrides from SchedulerBase */
virtual bool watchSocket(int fd);
virtual void unWatchSocket(int fd);
virtual bool waitForEvents(const struct timespec &timeout);
virtual int getNextSocketEvent();
private:
void resizeFoundSockets();
int m_foundEvents; // from last waitForEvents()
std::vector<int> m_foundSockets; // from last waitForEvents().
int m_nextCheckEvent; // for getNextSocketEvent
std::set<int> m_watchSockets;
};
#endif // !USE_KEVENT_SCHEDULER