]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/threads/threads.factor
core, basis, extra: Remove DOS line endings from files.
[factor.git] / basis / tools / threads / threads.factor
1 ! Copyright (C) 2008, 2010 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs io io.styles kernel math.order
4 math.parser prettyprint sequences sorting system threads ;
5 IN: tools.threads
6
7 : thread. ( thread -- )
8     dup id>> pprint-cell
9     dup name>> [
10         over write-object
11     ] with-cell
12     dup state>> [
13         [ dup self eq? "running" "yield" ? ] unless*
14         write
15     ] with-cell
16     [
17         sleep-entry>> [
18             key>> nano-count [-] number>string write
19             " nanos" write
20         ] when*
21     ] with-cell ;
22
23 : threads. ( -- )
24     standard-table-style [
25         [
26             { "ID:" "Name:" "Waiting on:" "Remaining sleep:" }
27             [ [ write ] with-cell ] each
28         ] with-row
29
30         threads sort-keys values [
31             [ thread. ] with-row
32         ] each
33     ] tabular-output nl ;