forked from dyninc/OpenBFDD
-
Notifications
You must be signed in to change notification settings - Fork 1
/
KeventScheduler.h
57 lines (42 loc) · 1.28 KB
/
KeventScheduler.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 kevent.
*/
#pragma once
#include "config.h"
#ifdef USE_KEVENT_SCHEDULER
#include "SchedulerBase.h"
#include <sys/event.h>
#include <vector>
namespace openbfdd
{
class KeventScheduler : public SchedulerBase
{
public:
/**
* Constructor
* The thread that calls this is considered the "main thread". See
* Scheduler::IsMainThread().
*/
KeventScheduler();
virtual ~KeventScheduler();
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 resizeEvents();
int m_totalEvents;
int m_kqueue;
int m_foundEvents; // from last waitForEvents()
int m_nextCheckEvent; // for getNextSocketEvent
std::vector<struct kevent> m_events; // from last waitForEvents()
};
}
#endif // USE_KEVENT_SCHEDULER