Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef PANGOLIN_THREADED_WRITE_H
00029 #define PANGOLIN_THREADED_WRITE_H
00030
00031 #include <iostream>
00032 #include <streambuf>
00033 #include <fstream>
00034
00035 #include <boost/thread.hpp>
00036 #include <boost/thread/mutex.hpp>
00037 #include <boost/thread/condition_variable.hpp>
00038
00039 namespace pangolin
00040 {
00041
00042 class threadedfilebuf : public std::streambuf
00043 {
00044 public:
00045 threadedfilebuf(const std::string& filename, unsigned int buffer_size_bytes);
00046 ~threadedfilebuf();
00047
00048 void operator()();
00049
00050 protected:
00052 std::streamsize xsputn(const char * s, std::streamsize n);
00053
00054 std::filebuf file;
00055 char* mem_buffer;
00056 int mem_size;
00057 int mem_max_size;
00058 int mem_start;
00059 int mem_end;
00060
00061 boost::mutex update_mutex;
00062 boost::condition_variable cond_queued;
00063 boost::condition_variable cond_dequeued;
00064 boost::thread write_thread;
00065 };
00066
00067 }
00068
00069
00070 #endif // PANGOLIN_THREADED_WRITE_H