lab4, producer/consumer fixed output
This commit is contained in:
@@ -5,18 +5,17 @@
|
||||
#ifndef PRODUCER_H
|
||||
#define PRODUCER_H
|
||||
|
||||
#include "buffer.h"
|
||||
#include <semaphore>
|
||||
|
||||
class Producer {
|
||||
public:
|
||||
Producer(int id, Buffer& buffer, std::counting_semaphore<3>& sem);
|
||||
void run() const;
|
||||
Producer(int id, int write_fd, std::counting_semaphore<3>& producerSem);
|
||||
void run(std::atomic<int>& itemsProduced, const std::atomic<bool>& stopFlag) const;
|
||||
|
||||
private:
|
||||
int id;
|
||||
Buffer& buffer;
|
||||
std::counting_semaphore<3>& producerSem;
|
||||
int producerId;
|
||||
int writeFd;
|
||||
std::counting_semaphore<3>& producerSemaphore;
|
||||
};
|
||||
|
||||
#endif //PRODUCER_H
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user