boundedbuffer.h

来自「linux的例子,就是下载后到自己的机子上去运行」· C头文件 代码 · 共 23 行

H
23
字号
#include "synch-sleep.h"

class BoundedBuffer {
   public:
     // create a bounded buffer with a limit of 'maxsize' bytes
     BoundedBuffer(int maxsize);
     ~BoundedBuffer();
     // read 'size' bytes from the bounded buffer, storing into 'data'.
     // ('size' may be greater than 'maxsize')
     int Read(void *data, int size);     
     // write 'size' bytes from 'data' into the bounded buffer.
     // ('size' may be greater than 'maxsize')
     int Write(void *data, int size);
     void printbuffer();
   private:
     int n,MaxSize,in,out;
     char *buffer;
     Lock *lock;
     Condition *notEmpty;
     Condition *notFull;
};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?