-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalender_queue.h
More file actions
executable file
·37 lines (30 loc) · 853 Bytes
/
calender_queue.h
File metadata and controls
executable file
·37 lines (30 loc) · 853 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
29
30
31
32
33
34
35
36
37
#pragma once
#include <vector>
#include <deque>
#include <chrono>
#include "priorities.h"
#include "task.h"
#ifdef SIMPLE_PRORITY_CALC
#define CALENDERQ_MIN_PRIORITY SCHED_INTERACT_THRESH
#define CALENDERQ_MAX_PRIORITY SCHED_INTERACT_MAX + MAX_NICENESS
#define CALENDERQ_NQUEUE (CALENDERQ_MAX_PRIORITY + 1 - CALENDERQ_MIN_PRIORITY)
#else
#define CALENDERQ_MIN_PRIORITY PRI_MIN_BATCH
#define CALENDERQ_MAX_PRIORITY PRI_MAX_BATCH
#define CALENDERQ_NQUEUE PRI_BATCH_RANGE
#endif
#define INSQ_UPDATE_INTERVAL 10
class CalenderQueue {
private:
std::vector<std::deque<Task*>> queue;
size_t size_;
int runq;
int insq;
std::chrono::steady_clock::time_point last_insq_update_time;
public:
CalenderQueue();
void addTask(Task* task, int priority);
Task* getNextTask();
bool empty();
size_t size();
};