-#define LOG_PREFIX { \
- auto _thread_ = this_thread::get_id(); \
- int _tid_ = thread_name_map[_thread_]; \
- if (_tid_==0) \
- _tid_ = thread_name_map[_thread_] = ++next_thread_num; \
- auto _utime_ = duration_cast<microseconds>(system_clock::now().time_since_epoch()).count() % 1000000000; \
- cerr << setfill('0') << dec << left << setw(9) << _utime_ << " "; \
- cerr << setfill(' ') << log_thread_prefix << left << setw(2) << _tid_; \
- cerr << " " << setw(20) << __FILE__ << " " << setw(18) << __func__; \
-}
-#define LOG_THIS_POINTER { \
- int _self_ = instance_name_map[this]; \
- if (_self_==0) \
- _self_ = instance_name_map[this] = ++next_instance_num; \
- cerr << "#" << left << setw(2) << _self_ << " "; \
-}
+struct locked_ostream {
+ std::ostream & s;
+ lock l;
+ locked_ostream(locked_ostream &&) = default;
+ ~locked_ostream() { s << std::endl; }
+ template <typename U>
+ locked_ostream & operator<<(U && u) { s << u; return *this; }
+};