-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfarm.h
More file actions
33 lines (23 loc) · 666 Bytes
/
Copy pathfarm.h
File metadata and controls
33 lines (23 loc) · 666 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
#ifndef FARM_H
#define FARM_H
#include "task.h"
#include <queue>
#include <mutex>
/** A collection of tasks that should be performed in parallel. */
class Farm {
public:
// DO NOT CHANGE the public interface of this class.
// You only need to implement the existing methods.
/** Add a task to the farm.
The task will be deleted once it has been run. */
void add_task(Task *task);
/** Run all the tasks in the farm.
This method only returns once all the tasks in the farm
have been completed. */
void run();
int size();
private:
std::queue<Task *> queue_of_tasks;
std::mutex queue_lock;
};
#endif