forked from rmbianchi/concurrent_framework
-
Notifications
You must be signed in to change notification settings - Fork 1
/
EventLoopManager.cpp
36 lines (29 loc) · 887 Bytes
/
EventLoopManager.cpp
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
//
// EventLoopManager.cpp
//
//
// Created by Benedikt Hegner on 4/12/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#include "EventLoopManager.h"
#include "tbb/compat/thread"
EventLoopManager::EventLoopManager(const std::vector<AlgoBase*>& algos, Whiteboard& wb, const unsigned int n_parallel) :
algo_pool_(algos,std::vector<int>(algos.size(),1)),
scheduler_(wb, n_parallel, algo_pool_,algos, this),
in_flight_(), processed_()
{
}
void EventLoopManager::run(int events){
scheduler_.run_parallel(events);
// do {
// if (in_flight_ < max_concurrent_events_ && processed+in_flight < n) {
// scheduler_.start_event(processed+in_flight);
// ++in_flight_;
// }
/// std::this_thread::yield();
// } while (processed_ < events);
}
void EventLoopManager::event_done(){
++processed_;
--in_flight_;
}