forked from dyninc/OpenBFDD
-
Notifications
You must be signed in to change notification settings - Fork 1
/
SelectScheduler.h
57 lines (42 loc) · 1.3 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
55
56
57
/**************************************************************
* 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>
namespace openbfdd
{
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