boundedbuffer.h

来自「nachos下线程与同步的实验」· C头文件 代码 · 共 26 行

H
26
字号
#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')
                void Read(void *data, int size);
                
                // write 'size' bytes from 'data' into the bounded buffer.
                // ('size' may be greater than 'maxsize')
                void Write(char *data, int size);
                
         private:
                 char *Buffer;
                 int *element;
                 int BufferSize;
                 Lock *lock;
                 Condition *BufferEmpty;
                 Condition *BufferFull;   
};

⌨️ 快捷键说明

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