On Jun 23, 2009, at 2:35 PM, Helmut Eller wrote:
- Terje Norderhaug [2009-06-23 22:07+0200] writes:
Another possibility is to have the list-threads response include a declaration of the structure of the items in the list. For example, the first item could be a list of symbols labeling the data, as in this amended response from swank:list-threads:
((id name status description) (18 "worker" "Active" "") (16 "repl-thread" "Semaphore timed wait" "") (15 "auto-flush-thread" "Sleep" "") (12 "reader-thread" "Active" "") (11 "control-thread" "Semaphore timed wait" "") (2 "Swank 0" "Active" "") (1 "listener" "Active" "") (0 "Initial" "Sleep" ""))
Benefits of heading with such a declaration vs using a detailed property list for each item includes less redundancy and that a swank client can make decisions about how to present the items in the list before processing the rest of the response.
Implementations can then add process attributes like priority, creation-time, total-run-time, last-run-time, idle-time etc, preferably using consistent labels.
-- Terje Norderhaug
Yet another possibility would be to pass the interesting attributes as input to swank:list-threads. E.g.
(list-threads '(:id :name :status :description :priority :total- runtime)) => ((18 "worker" "Active" "" 10 0.2) (16 "repl-thread" "Semaphore timed wait" "" 5 0.3))
Perhaps complemented with a function to find out all possible attribute names.
Having the client explicitly requesting which attributes it wants is a possibility worth consideration. A variation is to have the list- threads function declare the response and return as many attributes is available, but have a public function that can filter responses on the server before the result is passed back to the client, as in this request:
(filter '(id name status description priority total-runtime) (list- threads))
Sample demo:
(defun list-threads () '((id name status description) (18 "worker" "Active" "") (16 "repl-thread" "Semaphore timed wait" "") (15 "auto-flush-thread" "Sleep" "") (12 "reader-thread" "Active" "") (11 "control-thread" "Semaphore timed wait" "") (2 "Swank 0" "Active" "") (1 "listener" "Active" "") (0 "Initial" "Sleep" "")))
(defun filter (wanted items) (loop with given = (first items) for item in (rest items) collect (loop for w in wanted for p = (position w given) collect (when p (nth p item)))))
(filter '(id status) (list-threads)) => ((18 "Active") (16 "Semaphore timed wait") (15 "Sleep") (12 "Active") (11 "Semaphore timed wait") (2 "Active") (1 "Active") (0 "Sleep"))
(filter '(id name status description priority total-runtime) (list- threads)) => ((18 "worker" "Active" "" NIL NIL) (16 "repl-thread" "Semaphore timed wait" "" NIL NIL) (15 "auto-flush-thread" "Sleep" "" NIL NIL) (12 "reader-thread" "Active" "" NIL NIL) (11 "control-thread" "Semaphore timed wait" "" NIL NIL) (2 "Swank 0" "Active" "" NIL NIL) (1 "listener" "Active" "" NIL NIL) (0 "Initial" "Sleep" "" NIL NIL))
Where do we go from here?
-- Terje Norderhaug