@@ -184,28 +184,40 @@ bool task_worker_pool::shared_same_worker_with_current_task(task *tsk) const
184184    }
185185}
186186
187- void  task_worker_pool::get_runtime_info (const  std::string &indent,
188-                                         const  std::vector<std::string> &args,
189-                                         /* out*/   std::stringstream &ss)
187+ std::string task_worker_pool::get_runtime_info (const  std::string &indent,
188+                                                const  std::vector<std::string> &args)
190189{
191-     std::string indent2 = indent + " \t "  ;
192-     ss << indent << " contains "   << _workers.size () << "  threads with "   << _queues.size ()
193-        << "  queues"   << std::endl;
194- 
195-     for  (auto  &q : _queues) {
196-         if  (q) {
197-             ss << indent2 << q->get_name () << "  now has "   << q->count () << "  pending tasks" 
198-                << std::endl;
190+     const  auto  indent2 = fmt::format (" {}\t "  , indent);
191+ 
192+     auto  out = fmt::memory_buffer ();
193+     fmt::format_to (std::back_inserter (out),
194+                    " {}contains {} threads with {} queues"  ,
195+                    indent,
196+                    _workers.size (),
197+                    _queues.size ());
198+     for  (const  auto  &queue : _queues) {
199+         if  (queue) {
200+             fmt::format_to (std::back_inserter (out),
201+                            " {}{} now has {} pending tasks\n "  ,
202+                            indent2,
203+                            queue->get_name (),
204+                            queue->count ());
199205        }
200206    }
201207
202-     for  (auto  &wk : _workers) {
203-         if  (wk) {
204-             ss << indent2 << wk->index () << "  (TID = "   << wk->native_tid ()
205-                << " ) attached with queue "   << wk->queue ()->get_name () << std::endl;
208+     for  (const  auto  &worker : _workers) {
209+         if  (worker) {
210+             fmt::format_to (std::back_inserter (out),
211+                            " {}{}  (TID = {}) attached with queue {}\n "  ,
212+                            indent2,
213+                            worker->index (),
214+                            worker->native_tid (),
215+                            worker->queue ()->get_name ());
206216        }
207217    }
218+     return  fmt::to_string (out);
208219}
220+ 
209221void  task_worker_pool::get_queue_info (/* out*/   std::stringstream &ss)
210222{
211223    ss << " ["  ;
@@ -279,17 +291,23 @@ volatile int *task_engine::get_task_queue_virtual_length_ptr(dsn::task_code code
279291    return  pl->queues ()[idx]->get_virtual_length_ptr ();
280292}
281293
282- void  task_engine::get_runtime_info (const  std::string &indent,
283-                                    const  std::vector<std::string> &args,
284-                                    /* out*/   std::stringstream &ss)
294+ std::string task_engine::get_runtime_info (const  std::string &indent,
295+                                           const  std::vector<std::string> &args)
285296{
286-     std::string indent2 = indent + " \t "  ;
287-     for  (auto  &p : _pools) {
288-         if  (p) {
289-             ss << indent << p->spec ().pool_code .to_string () << std::endl;
290-             p->get_runtime_info (indent2, args, ss);
297+     const  auto  indent2 = fmt::format (" {}\t "  , indent);
298+ 
299+     auto  out = fmt::memory_buffer ();
300+     fmt::format_to (std::back_inserter (out), indent2);
301+     for  (const  auto  &pool : _pools) {
302+         if  (pool) {
303+             fmt::format_to (std::back_inserter (out),
304+                            " {}{}\n {}"  ,
305+                            indent,
306+                            pool->spec ().pool_code ,
307+                            pool->get_runtime_info (indent2, args));
291308        }
292309    }
310+     return  fmt::to_string (out);
293311}
294312
295313void  task_engine::get_queue_info (/* out*/   std::stringstream &ss)
0 commit comments