-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfifo.py
More file actions
20 lines (17 loc) · 737 Bytes
/
fifo.py
File metadata and controls
20 lines (17 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from queue import Queue
from typing import Union
from task import GeneralTask, ExtendedTask
class Fifo():
def __init__(self, queue_max_len):
self.queues = {
3 : Queue(queue_max_len),
2 : Queue(queue_max_len),
1 : Queue(queue_max_len),
0 : Queue(queue_max_len)
}
def receive_task(self, task: Union[GeneralTask, ExtendedTask]):
if self.queues[task.priority].not_full:
self.queues[task.priority].put(task)
print(f'Задача с id {task.id} принята в очередь приоритета {task.priority}')
else:
print(f"Очередь приоритета {task.priority} заполнена")