Scheduler
queue.h
Go to the documentation of this file.
1 
10 #ifndef QUEUE_H
11 #define QUEUE_H
12 
13 #include <iterator>
14 #include <list>
15 #include <string>
16 #include <memory>
17 
18 namespace Scheduler
19 {
20 
21 class Process;
22 
23 /*TODO put the queues in the system class*/
24 
28 class Queue
29 {
30 public:
33  static Queue *getReadyQueue();
36  static Queue *getWaitQueue();
37 private:
38  /*Cannot use a shared_ptr because the constructor is private (singleton)*/
39  static Queue *readyQueue;
40  static Queue *waitQueue;
41 public:
44  void add(std::shared_ptr<Process> p);
50  std::shared_ptr<Process> remove(std::shared_ptr<Process> p);
51 
52  typedef std::list<std::shared_ptr<Process> >::iterator iterator;
53  iterator begin();
54  iterator end();
55  size_t size() const;
56  bool isEmpty() const;
59  void print() const;
62  std::string getDisplay() const;
65  int getMaxSize() const;
66 private:
67  Queue(); //singleton
68  std::list<std::shared_ptr<Process> > queue;
69  std::string queueDisplay;
70 };
71 
72 }
73 
74 
75 #endif
This class implements the ready queue and the wait queue. Those queues contain processes ready to run...
Definition: queue.h:28
void print() const
print a summary of the queue&#39;s content
Definition: queue.cpp:86
int getMaxSize() const
get the maximum size of the queues
Definition: queue.cpp:116
size_t size() const
Definition: queue.cpp:75
std::string getDisplay() const
get the queue&#39;s content as a string, for command-line output
Definition: queue.cpp:95
static Queue * getReadyQueue()
get a pointer to the system&#39;s ready queue
Definition: queue.cpp:30
std::list< std::shared_ptr< Process > >::iterator iterator
Definition: queue.h:52
iterator begin()
Definition: queue.cpp:65
static Queue * getWaitQueue()
get a pointer to the system&#39;s wait queue
Definition: queue.cpp:37
iterator end()
Definition: queue.cpp:69
void add(std::shared_ptr< Process > p)
add a process to the queue
Definition: queue.cpp:23
bool isEmpty() const
Definition: queue.cpp:80