浏览代码

LibThreading: Add Thread formatter

Printing a thread for debugging is used quite often.
kleines Filmröllchen 2 年之前
父节点
当前提交
fe004d3389
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      Userland/Libraries/LibThreading/Thread.h

+ 8 - 0
Userland/Libraries/LibThreading/Thread.h

@@ -63,3 +63,11 @@ Result<T, ThreadError> Thread::join()
 }
 
 }
+
+template<>
+struct AK::Formatter<Threading::Thread> : AK::Formatter<FormatString> {
+    ErrorOr<void> format(FormatBuilder& builder, Threading::Thread const& thread)
+    {
+        return Formatter<FormatString>::format(builder, "Thread \"{}\"({})"sv, thread.thread_name(), thread.tid());
+    }
+};