-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoad.cpp
More file actions
28 lines (24 loc) · 711 Bytes
/
Load.cpp
File metadata and controls
28 lines (24 loc) · 711 Bytes
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
#include "Load.hpp"
#include <array>
#include <list>
#include <cassert>
namespace {
std::array< std::list< std::function< void() > >, LoadTagCount > &get_load_lists() {
static std::array< std::list< std::function< void() > >, LoadTagCount > load_lists;
return load_lists;
}
}
void add_load_function(LoadTag tag, std::function< void() > const &fn) {
auto &load_lists = get_load_lists();
assert(tag < load_lists.size());
load_lists[tag].emplace_back(fn);
}
void call_load_functions() {
auto &load_lists = get_load_lists();
for (auto &fn_list : load_lists) {
while (!fn_list.empty()) {
(*fn_list.begin())(); //call first function in the list
fn_list.pop_front(); //remove from list
}
}
}