< prev index next >

src/hotspot/share/utilities/ostream.hpp

Print this page
rev 54032 : 8220394: bufferedStream does not honor size limit


 235  protected:
 236   int  _fd;
 237  public:
 238   fdStream(int fd = -1) : _fd(fd) { }
 239   bool is_open() const { return _fd != -1; }
 240   void set_fd(int fd) { _fd = fd; }
 241   int fd() const { return _fd; }
 242   virtual void write(const char* c, size_t len);
 243   void flush() {};
 244 };
 245 
 246 void ostream_init();
 247 void ostream_init_log();
 248 void ostream_exit();
 249 void ostream_abort();
 250 
 251 // In the non-fixed buffer case an underlying buffer will be created and
 252 // managed in C heap. Not MT-safe.
 253 class bufferedStream : public outputStream {
 254  protected:
 255   char*  buffer;
 256   size_t buffer_pos;
 257   size_t buffer_max;
 258   size_t buffer_length;
 259   bool   buffer_fixed;

 260  public:
 261   bufferedStream(size_t initial_bufsize = 256, size_t bufmax = 1024*1024*10);
 262   bufferedStream(char* fixed_buffer, size_t fixed_buffer_size, size_t bufmax = 1024*1024*10);


 263   ~bufferedStream();
 264   virtual void write(const char* c, size_t len);
 265   size_t      size() { return buffer_pos; }
 266   const char* base() { return buffer; }
 267   void  reset() { buffer_pos = 0; _precount = 0; _position = 0; }
 268   char* as_string();
 269 };
 270 
 271 #define O_BUFLEN 2000   // max size of output of individual print() methods
 272 
 273 #ifndef PRODUCT
 274 
 275 class networkStream : public bufferedStream {
 276 
 277   private:
 278     int _socket;
 279 
 280   public:
 281     networkStream();
 282     ~networkStream();
 283 
 284     bool connect(const char *host, short port);
 285     bool is_open() const { return _socket != -1; }
 286     int read(char *buf, size_t len);
 287     void close();


 235  protected:
 236   int  _fd;
 237  public:
 238   fdStream(int fd = -1) : _fd(fd) { }
 239   bool is_open() const { return _fd != -1; }
 240   void set_fd(int fd) { _fd = fd; }
 241   int fd() const { return _fd; }
 242   virtual void write(const char* c, size_t len);
 243   void flush() {};
 244 };
 245 
 246 void ostream_init();
 247 void ostream_init_log();
 248 void ostream_exit();
 249 void ostream_abort();
 250 
 251 // In the non-fixed buffer case an underlying buffer will be created and
 252 // managed in C heap. Not MT-safe.
 253 class bufferedStream : public outputStream {
 254  protected:
 255   char*  _buffer;
 256   size_t _pos;
 257   size_t _capacity;
 258   const bool   _owned;
 259   const size_t _max_capacity;
 260   const size_t _flush_threshold;
 261  public:
 262   // Construct a stream which allocates its buffer from C heap up to a maximum of max_bufsize
 263   bufferedStream(size_t initial_capacity = 256, size_t max_capacity = 10 * M, size_t flush_threshold = 10 * M);
 264   // Construct a stream which uses a caller provided buffer
 265   bufferedStream(char* fixed_buffer, size_t max_bufsize, size_t flush_threshold = 10 * M);
 266   ~bufferedStream();
 267   virtual void write(const char* c, size_t len);
 268   size_t      size() { return _pos; }
 269   const char* base() { return _buffer; }
 270   void  reset() { _pos = 0; _precount = 0; _position = 0; }
 271   char* as_string();
 272 };
 273 
 274 #define O_BUFLEN 2000   // max size of output of individual print() methods
 275 
 276 #ifndef PRODUCT
 277 
 278 class networkStream : public bufferedStream {
 279 
 280   private:
 281     int _socket;
 282 
 283   public:
 284     networkStream();
 285     ~networkStream();
 286 
 287     bool connect(const char *host, short port);
 288     bool is_open() const { return _socket != -1; }
 289     int read(char *buf, size_t len);
 290     void close();
< prev index next >