Browse Source

LibThreading: Add Thread formatter

Printing a thread for debugging is used quite often.
kleines Filmröllchen 2 years ago
parent
commit
fe004d3389
1 changed files with 8 additions and 0 deletions
  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());
+    }
+};