home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c100 / 3.ddi / TASK.ZIP / PIPE.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-27  |  1.1 KB  |  38 lines

  1. // PIPE.HPP   Copyright 1989 by Dlugosz Software
  2. // Pipes for the C++ multitasking system
  3.  
  4. class pipe {
  5.    byte* buffer;
  6.    unsigned bufsize, room;
  7.    unsigned writepos, readpos;
  8.    semaphore reader, writer;
  9.    semaphore in_use, suspend;
  10.    bool dynamic;
  11.    // functions to manage a circular queue
  12.    void get (void*, unsigned);
  13.    void put (void*, unsigned);
  14. protected:
  15.    bool send (void* data, unsigned size);
  16.    bool receive (void* buffer, unsigned size);
  17. public:
  18.    pipe (void* buffer, unsigned size);  //use this buffer
  19.    pipe (unsigned size);  //allocate a buffer dynamically
  20.    ~pipe();
  21.    unsigned contents() { return bufsize - room; }  //how much is in there?
  22.    };
  23.  
  24. class pipe_reader : public pipe {
  25.    pipe_reader(unsigned size) : (size) {}  //never used, but keep the compiler happy
  26. public:
  27.    bool receive (void* buffer, unsigned size)
  28.                 { return pipe::receive(buffer, size); }
  29.    };
  30.  
  31.  
  32. class pipe_writer : public pipe {
  33.    pipe_writer(unsigned size) : (size) {}  //never used, but keep the compiler happy
  34. public:
  35.    bool send (void* data, unsigned size) { return pipe::send (data,size); }
  36.    };
  37.  
  38.