-
Notifications
You must be signed in to change notification settings - Fork 1
/
EventLoopManager.h
42 lines (36 loc) · 971 Bytes
/
EventLoopManager.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
//
// EventLoopManager.h
//
//
// Created by Benedikt Hegner on 4/12/12.
// Copyright (c) 2012 CERN. All rights reserved.
//
#ifndef _EventLoopManager_h
#define _EventLoopManager_h
// include tbb
#include "tbb/atomic.h"
// include fwk
#include "Algo.h"
#include "Scheduler.h"
#include "Whiteboard.h"
class EventLoopManager{
public:
EventLoopManager(const unsigned int n_parallel);
void initialise(int events, Scheduler* scheduler);
void operator()();
void finished_event();
private:
Scheduler* scheduler_;
tbb::atomic<unsigned int> in_flight_;
tbb::atomic<unsigned int> processed_;
unsigned int max_concurrent_events_;
unsigned int events_;
};
class EventLoopManagerTask : public tbb::task {
public:
EventLoopManagerTask(EventLoopManager* manager): manager_(manager){};
tbb::task* execute() { (*manager_)();return NULL; };
private:
EventLoopManager* manager_;
};
#endif