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