1 | ;;+----------------------------------------------------------------------------- |
---|
2 | ;;+ Isidorus |
---|
3 | ;;+ (c) 2008-2010 Marc Kuester, Christoph Ludwig, Lukas Georgieff |
---|
4 | ;;+ |
---|
5 | ;;+ Isidorus is freely distributable under the LLGPL license. |
---|
6 | ;;+ You can find a detailed description in trunk/docs/LLGPL-LICENSE.txt and |
---|
7 | ;;+ trunk/docs/LGPL-LICENSE.txt. |
---|
8 | ;;+----------------------------------------------------------------------------- |
---|
9 | |
---|
10 | |
---|
11 | (require :asdf) |
---|
12 | (asdf:operate 'asdf:load-op :isidorus) |
---|
13 | (xml-importer:setup-repository "textgrid.xtm" "data_base" |
---|
14 | :tm-id "http://ztt.fh-worms.de/textgrid.xtm" |
---|
15 | :xtm-id "textgrid.xtm") |
---|
16 | |
---|
17 | |
---|
18 | (defun return-all-tmcl-types-test-handler (&optional param) |
---|
19 | "similar to hunchentoot's corresponding handler - but without hunchentoot's |
---|
20 | variables, e.g. hunchentoot:content-type, ..." |
---|
21 | (declare (ignorable param)) |
---|
22 | (handler-case (let ((topic-types |
---|
23 | (isidorus-threading:with-reader-lock |
---|
24 | (json-tmcl::return-all-tmcl-types :revision 0)))) |
---|
25 | (json:encode-json-to-string |
---|
26 | (map 'list #'(lambda(y) |
---|
27 | (map 'list #'d:uri y)) |
---|
28 | (map 'list #'d:psis topic-types)))) |
---|
29 | (condition (err) (error (format nil "~a" err))))) |
---|
30 | |
---|
31 | |
---|
32 | (defun return-all-tmcl-instances-test-handler(&optional param) |
---|
33 | "similar to hunchentoot's corresponding handler - but without hunchentoot's |
---|
34 | variables, e.g. hunchentoot:content-type, ..." |
---|
35 | (declare (ignorable param)) |
---|
36 | (handler-case (let ((topic-instances |
---|
37 | (isidorus-threading:with-reader-lock |
---|
38 | (json-tmcl::return-all-tmcl-instances :revision 0)))) |
---|
39 | (json:encode-json-to-string |
---|
40 | (map 'list #'(lambda(y) |
---|
41 | (map 'list #'d:uri y)) |
---|
42 | (map 'list #'d:psis topic-instances)))) |
---|
43 | (condition (err) (error (format nil "~a" err))))) |
---|
44 | |
---|
45 | |
---|
46 | |
---|
47 | (defun return-all-topic-psis-test-handler (&optional param) |
---|
48 | "similar to hunchentoot's corresponding handler - but without hunchentoot's |
---|
49 | variables, e.g. hunchentoot:content-type, ..." |
---|
50 | (declare (ignorable param)) |
---|
51 | (handler-case (isidorus-threading:with-reader-lock |
---|
52 | (json-exporter::get-all-topic-psis :revision 0)) |
---|
53 | (condition (err) (error (format nil "~a" err))))) |
---|
54 | |
---|
55 | |
---|
56 | (defun my-thread-function-1 () |
---|
57 | (dotimes (i 100) |
---|
58 | (return-all-tmcl-types-test-handler))) |
---|
59 | |
---|
60 | |
---|
61 | (defun programm-1 (thread-fun) |
---|
62 | "bordeaux-threads" |
---|
63 | (defvar *thread-1* (bordeaux-threads:make-thread thread-fun)) |
---|
64 | (defvar *thread-2* (bordeaux-threads:make-thread thread-fun))) |
---|
65 | |
---|
66 | |
---|
67 | (defun programm-2 (thread-fun) |
---|
68 | "bordeaux-threads" |
---|
69 | (let ((thread-1 nil) |
---|
70 | (thread-2 nil) |
---|
71 | (max-iterations 150)) |
---|
72 | (do ((c1 0 (+ c1 0)) |
---|
73 | (c2 0 (+ c2 0))) |
---|
74 | ((and (>= c1 max-iterations) (>= c2 max-iterations))) |
---|
75 | (when (or (not thread-1) (not (bordeaux-threads:thread-alive-p thread-1))) |
---|
76 | (setf thread-1 (bordeaux-threads:make-thread thread-fun)) |
---|
77 | (incf c1) |
---|
78 | (format t "c1: ~a c2: ~a~%" c1 c2)) |
---|
79 | (when (or (not thread-2) (not (bordeaux-threads:thread-alive-p thread-2))) |
---|
80 | (setf thread-2 (bordeaux-threads:make-thread thread-fun)) |
---|
81 | (incf c2) |
---|
82 | (format t "c1: ~a c2: ~a~%" c1 c2))))) |
---|
83 | |
---|
84 | |
---|
85 | (defun programm-3 (thread-fun) |
---|
86 | "sb-thread" |
---|
87 | (defvar *thread-3* (sb-thread:make-thread thread-fun)) |
---|
88 | (defvar *thread-4* (sb-thread:make-thread thread-fun))) |
---|
89 | |
---|
90 | |
---|
91 | (defun programm-4 (thread-fun) |
---|
92 | "sb-thread" |
---|
93 | (let ((thread-1 nil) |
---|
94 | (thread-2 nil) |
---|
95 | (max-iterations 150)) |
---|
96 | (do ((c1 0 (+ c1 0)) |
---|
97 | (c2 0 (+ c2 0))) |
---|
98 | ((and (>= c1 max-iterations) (>= c2 max-iterations))) |
---|
99 | (when (or (not thread-1) (not (sb-thread:thread-alive-p thread-1))) |
---|
100 | (setf thread-1 (sb-thread:make-thread thread-fun)) |
---|
101 | (incf c1) |
---|
102 | (format t "c1: ~a c2: ~a~%" c1 c2)) |
---|
103 | (when (or (not thread-2) (not (sb-thread:thread-alive-p thread-2))) |
---|
104 | (setf thread-2 (sb-thread:make-thread thread-fun)) |
---|
105 | (incf c2) |
---|
106 | (format t "c1: ~a c2: ~a~%" c1 c2))))) |
---|
107 | |
---|
108 | |
---|
109 | |
---|
110 | |
---|
111 | |
---|
112 | (defun main() |
---|
113 | (programm-4 #'return-all-tmcl-types-test-handler)) |
---|
114 | |
---|
115 | |
---|
116 | (main) |
---|