]> gitweb.factorcode.org Git - factor.git/blob - extra/native-thread-test/native-thread-test.factor
Switch to https urls
[factor.git] / extra / native-thread-test / native-thread-test.factor
1 ! Copyright (C) 2009 Phil Dawes.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: alien.c-types alien.strings alien.syntax alien.utilities
4 io io.encodings.utf8 io.files kernel sequences system threads ;
5 IN: native-thread-test
6
7 FUNCTION: void* start_standalone_factor_in_new_thread ( int argc, c-string* argv )
8
9 : start-vm-in-os-thread ( args -- threadhandle )
10     vm-path prefix
11     [ length ] [ native-string-encoding strings>alien ] bi
12     start_standalone_factor_in_new_thread ;
13
14 : start-tetris-in-os-thread ( -- )
15     { "-run=tetris" } start-vm-in-os-thread drop ;
16
17 : start-test-thread-in-os-thread ( -- )
18     { "-run=native-thread-test" } start-vm-in-os-thread drop ;
19
20 : test-thread ( -- )
21     "/tmp/hello" utf8 [ "hello!\n" write ] with-file-appender 5000000 sleep ;
22
23 MAIN: test-thread