factor/extra/tools/threads/threads.factor

24 lines
688 B
Factor
Raw Normal View History

2008-02-18 06:07:40 -05:00
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
IN: tools.threads
2008-02-18 08:30:16 -05:00
USING: threads kernel prettyprint prettyprint.config
io io.styles sequences assocs namespaces sorting boxes ;
2008-02-18 06:07:40 -05:00
: thread. ( thread -- )
dup thread-id pprint-cell
dup thread-name pprint-cell
thread-state [ "Waiting for " swap append ] [ "Running" ] if*
[ write ] with-cell ;
2008-02-18 06:07:40 -05:00
: threads. ( -- )
standard-table-style [
[
{ "ID" "Name" "State" }
[ [ write ] with-cell ] each
] with-row
threads >alist sort-keys values [
2008-02-18 06:07:40 -05:00
[ thread. ] with-row
] each
] tabular-output ;