Debian Codegraph @

test/win-noconsole-threads.scm

raw
1 ;;
2 ;; This manually test AllocConsole() opeartion of gosh-noconsole.exe
3 ;; on MinGW. This can't be automated easily, so it's not run by
4 ;; make check.
5 ;;
6
7 ;; How to test:
8 ;; Run this script with gosh-noconsole, compiled with --enable-threads=win32.
9 ;; A few seconds after startup, the console should pop up,
10 ;; containing messages from 10 individual threads.
11
12
13 (cond-expand
14 [(not gauche.sys.wthreads)
15 (exit 1 "This script needs to be run on MinGW version of gosh-noconsole compiled with --enable-threads=win32.")]
16 [else])
17
18 (use gauche.threads)
19 (use data.queue)
20
21 (define (main args)
22 (let1 q (make-mtqueue)
23 (define (make-thunk k)
24 (^[] (dequeue/wait! q) (display k) (flush)))
25 (dotimes [n 10] (thread-start! (make-thread (make-thunk n))))
26 (dotimes [n 10] (enqueue! q #t))
27 (sys-sleep 10)
28 0))