Skip to content

Commit eb62ea1

Browse files
committed
port pthreads example
1 parent 353bd1e commit eb62ea1

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

examples/thread.lisp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
(eval-when (:compile-toplevel :load-toplevel :execute)
2+
(ql:quickload '("iup" "bordeaux-threads")))
3+
4+
(defpackage #:iup-examples.thread
5+
(:use #:common-lisp)
6+
(:export #:thread))
7+
8+
(in-package #:iup-examples.thread)
9+
10+
(defun worker-function ()
11+
(loop for i from 0 below 100
12+
do (progn
13+
(sleep 5)
14+
(format t "worker function~%"))))
15+
16+
(defun button-callback (handle)
17+
(declare (ignore handle))
18+
(bt:make-thread 'worker-function)
19+
iup:+default+)
20+
21+
(defun thread ()
22+
(iup:with-iup ()
23+
(let* ((label (iup:label :title "Start second thread:"))
24+
(button (iup:button :title "Start" :action 'button-callback))
25+
(vbox (iup:vbox (list label button) :alignment "ACENTER" :gap "10" :margin "10x10"))
26+
(dialog (iup:dialog vbox :title "thread test" :title "thread test")))
27+
(iup:show dialog)
28+
(iup:main-loop))))
29+
30+
#-sbcl (thread)
31+
32+
#+sbcl
33+
(sb-int:with-float-traps-masked
34+
(:divide-by-zero :invalid)
35+
(thread))

0 commit comments

Comments
 (0)