< prev index next >

src/share/vm/utilities/ostream.hpp

Print this page
rev 9831 : 8146905 - cleanup ostream, staticBufferStream
Summary: get rid of staticBufferStream and implement the use-caller-provided-scratch-buffer feature in a simpler way.

*** 47,63 **** --- 47,72 ---- int _width; // width of the page int _position; // position on the current line int _newlines; // number of '\n' output so far julong _precount; // number of chars output, less _position TimeStamp _stamp; // for time stamps + char* _scratch; // internal scratch buffer for printf + size_t _scratch_len; // size of internal scratch buffer void update_position(const char* s, size_t len); static const char* do_vsnprintf(char* buffer, size_t buflen, const char* format, va_list ap, bool add_cr, size_t& result_len) ATTRIBUTE_PRINTF(3, 0); + // calls do_vsnprintf and writes output to stream; uses an on-stack buffer. + void do_vsnprintf_and_write_with_automatic_buffer(const char* format, va_list ap, bool add_cr) ATTRIBUTE_PRINTF(2, 0); + // calls do_vsnprintf and writes output to stream; uses the user-provided buffer; + void do_vsnprintf_and_write_with_scratch_buffer(const char* format, va_list ap, bool add_cr) ATTRIBUTE_PRINTF(2, 0); + // calls do_vsnprintf, then writes output to stream. + void do_vsnprintf_and_write(const char* format, va_list ap, bool add_cr) ATTRIBUTE_PRINTF(2, 0); + public: // creation outputStream(int width = 80); outputStream(int width, bool has_time_stamps);
*** 117,126 **** --- 126,139 ---- virtual void flush() {} virtual void write(const char* str, size_t len) = 0; virtual void rotate_log(bool force, outputStream* out = NULL) {} // GC log rotation virtual ~outputStream() {} // close properly on deletion + // Caller may specify an own scratch buffer to use for printing; otherwise, + // an automatic buffer on the stack (with O_BUFLEN len) is used. + void set_scratch_buffer(char* p, size_t len) { _scratch = p; _scratch_len = len; } + void dec_cr() { dec(); cr(); } void inc_cr() { inc(); cr(); } }; // standard output
*** 248,277 **** void ostream_init(); void ostream_init_log(); void ostream_exit(); void ostream_abort(); - // staticBufferStream uses a user-supplied buffer for all formatting. - // Used for safe formatting during fatal error handling. Not MT safe. - // Do not share the stream between multiple threads. - class staticBufferStream : public outputStream { - private: - char* _buffer; - size_t _buflen; - outputStream* _outer_stream; - public: - staticBufferStream(char* buffer, size_t buflen, - outputStream *outer_stream); - ~staticBufferStream() {}; - virtual void write(const char* c, size_t len); - void flush(); - void print(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); - void print_cr(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); - void vprint(const char *format, va_list argptr) ATTRIBUTE_PRINTF(2, 0); - void vprint_cr(const char* format, va_list argptr) ATTRIBUTE_PRINTF(2, 0); - }; - // In the non-fixed buffer case an underlying buffer will be created and // managed in C heap. Not MT-safe. class bufferedStream : public outputStream { protected: char* buffer; --- 261,270 ----
< prev index next >