00001 // --- T h r e a d s w i t h I O --- 00002 00003 00004 class thread_with_io; 00005 00006 struct ithreadstream : public std::istream 00007 { ithreadstream(thread_with_io&); }; 00008 struct othreadstream : public std::ostream 00009 { othreadstream(thread_with_io&); }; 00010 00011 class thread_with_io : public thread { 00012 friend class ithreadstream; 00013 friend class othreadstream; 00014 bool input_in_use, output_in_use; 00015 pipe_streambuf input_pipestreambuf; // very private! 00016 pipe_streambuf output_pipestreambuf; 00017 00018 protected: 00019 std::istream tin; 00020 std::ostream tout; 00021 00022 public: 00023 thread_with_io() 00024 : tin(&input_pipestreambuf), 00025 tout(&output_pipestreambuf) {} 00026 }; 00027 00028 00029 inline ithreadstream::ithreadstream(thread_with_io& th) 00030 : std::istream(&th.output_pipestreambuf) {} 00031 inline othreadstream::othreadstream(thread_with_io& th) 00032 : std::ostream(&th.input_pipestreambuf) {} 00033 00034