我想用无限缓冲区模拟生产者消费者问题,该缓冲区从生产者那里获取数据并按优先级存储它们:高,中,低。
然后,消费者提取它们并进行处理,每次仅请求一次。缓冲区将给优先级最高的缓冲区。我该如何使用?我对此建模:
model producerconsumer
class Productor
attributes
datos : String
` prioridad: Prioridad
end
class priority < Productor
attributes
High: String
Medium: String
Low: String
end
class buffer
attributes
data : String
time: int
operations
count(time):int
end
class consumer
attributes
data: String
operations:
extract(data)
process():data
end
-- associations
association send between
Productor [1] role input
buffer [1] role output
end
association send between
buffer [1] role input
consumer [1] role output
end