@@ -14,7 +14,7 @@ using std::to_string;
1414using FullHistoryWithThreads = std::vector<std::pair<
1515 int , std::variant<std::reference_wrapper<Task>, CoroutineStatus>>>;
1616struct PrettyPrinter {
17- PrettyPrinter (size_t threads_num) ;
17+ explicit PrettyPrinter () = default ;
1818
1919 /*
2020 Prints like this:
@@ -31,7 +31,7 @@ struct PrettyPrinter {
3131 */
3232 template <typename Out_t>
3333 void PrettyPrint (const std::vector<std::variant<Invoke, Response>>& result,
34- Out_t& out) {
34+ int threads_num, Out_t& out) {
3535 auto get_thread_num = [](const std::variant<Invoke, Response>& v) {
3636 // Crutch.
3737 if (v.index () == 0 ) {
@@ -42,7 +42,7 @@ struct PrettyPrinter {
4242
4343 int cell_width = 50 ; // Up it if necessary. Enough for now.
4444
45- auto print_separator = [&out, this , cell_width]() {
45+ auto print_separator = [threads_num, &out, this , cell_width]() {
4646 out << " *" ;
4747 for (int i = 0 ; i < threads_num; ++i) {
4848 for (int j = 0 ; j < cell_width; ++j) {
@@ -121,10 +121,11 @@ struct PrettyPrinter {
121121
122122 // Helps to debug full histories.
123123 template <typename Out_t>
124- void PrettyPrint (FullHistoryWithThreads& result, Out_t& out) {
124+ void PrettyPrint (FullHistoryWithThreads& result, int threads_num,
125+ Out_t& out) {
125126 int cell_width = 20 ; // Up it if necessary. Enough for now.
126127
127- auto print_separator = [&out, this , cell_width]() {
128+ auto print_separator = [threads_num, &out, this , cell_width]() {
128129 out << " *" ;
129130 for (int i = 0 ; i < threads_num; ++i) {
130131 for (int j = 0 ; j < cell_width; ++j) {
@@ -178,7 +179,7 @@ struct PrettyPrinter {
178179 index[base] = sz;
179180 }
180181 int length = std::to_string (index[base]).size ();
181- std::cout << index[base];
182+ out << index[base];
182183 assert (spaces - length >= 0 );
183184 print_spaces (7 - length);
184185 out << " |" ;
@@ -247,5 +248,4 @@ struct PrettyPrinter {
247248 out << msg;
248249 }
249250 };
250- size_t threads_num;
251251};
0 commit comments