1#ifndef FORKIT_H 2#define FORKIT_H 3 4#ifndef OS2 5#include <poll.h> 6#endif 7 8#include "port.h" 9 10class Fork; 11 12typedef void *PVOID; 13 14typedef void(* FUNCTION)(Fork *, PVOID, int); 15 16typedef struct 17{ 18 FILE_TYPE child_read, child_write; 19 Fork *f; 20 PVOID param; 21 FUNCTION func; 22 int threadNum; 23} THREAD_DATA; 24 25class Fork 26{ 27public: 28 Fork(); 29 void go(FUNCTION func, PVOID param, int num); 30 31 32 int Read(PVOID buf, int size, int timeout = 60); 33 int Write(PVOID buf, int size, int timeout = 60); 34 35 void startit(THREAD_DATA *td); // free td when finished 36 37 int wait(); 38 39 int getNumThreads() const { return m_numThreads; } 40 41private: 42#ifndef OS2 43 pollfd m_readPoll; 44 pollfd m_writePoll; 45#endif 46 FILE_TYPE m_read; 47 FILE_TYPE m_write; 48 int m_numThreads; 49}; 50 51#endif 52 53