native-thread-test: clean up
parent
5700d94e2b
commit
6367c8ec85
|
@ -1,4 +1,4 @@
|
|||
! Copyright (C) 2008, 2009 Slava Pestov.
|
||||
! Copyright (C) 2008, 2010 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: arrays sequences kernel kernel.private accessors math
|
||||
alien.accessors byte-arrays io io.encodings io.encodings.utf8
|
||||
|
@ -37,17 +37,16 @@ M: string string>alien
|
|||
|
||||
M: tuple string>alien drop underlying>> ;
|
||||
|
||||
HOOK: alien>native-string os ( alien -- string )
|
||||
HOOK: native-string-encoding os ( -- encoding ) foldable
|
||||
|
||||
M: windows alien>native-string utf16n alien>string ;
|
||||
M: unix native-string-encoding utf8 ;
|
||||
M: windows native-string-encoding utf16n ;
|
||||
|
||||
M: unix alien>native-string utf8 alien>string ;
|
||||
: alien>native-string ( alien -- string )
|
||||
native-string-encoding alien>string ; inline
|
||||
|
||||
HOOK: native-string>alien os ( string -- alien )
|
||||
|
||||
M: windows native-string>alien utf16n string>alien ;
|
||||
|
||||
M: unix native-string>alien utf8 string>alien ;
|
||||
: native-string>alien ( string -- alien )
|
||||
native-string-encoding string>alien ; inline
|
||||
|
||||
: dll-path ( dll -- string )
|
||||
path>> alien>native-string ;
|
||||
|
|
|
@ -1,26 +1,24 @@
|
|||
USING: alien.c-types alien.syntax io io.encodings.utf16n
|
||||
io.encodings.utf8 io.files kernel namespaces sequences system threads
|
||||
! Copyright (C) 2009 Phil Dawes.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien.c-types alien.strings alien.syntax io
|
||||
io.encodings.utf8 io.files kernel sequences system threads
|
||||
unix.utilities ;
|
||||
IN: native-thread-test
|
||||
|
||||
FUNCTION: void* start_standalone_factor_in_new_thread ( int argc, char** argv ) ;
|
||||
|
||||
HOOK: native-string-encoding os ( -- encoding )
|
||||
M: windows native-string-encoding utf16n ;
|
||||
M: unix native-string-encoding utf8 ;
|
||||
|
||||
: start-vm-in-os-thread ( args -- threadhandle )
|
||||
\ vm get-global prefix
|
||||
vm prefix
|
||||
[ length ] [ native-string-encoding strings>alien ] bi
|
||||
start_standalone_factor_in_new_thread ;
|
||||
|
||||
: start-tetris-in-os-thread ( -- )
|
||||
{ "-run=tetris" } start-vm-in-os-thread drop ;
|
||||
|
||||
: start-testthread-in-os-thread ( -- )
|
||||
: start-test-thread-in-os-thread ( -- )
|
||||
{ "-run=native-thread-test" } start-vm-in-os-thread drop ;
|
||||
|
||||
: testthread ( -- )
|
||||
: test-thread ( -- )
|
||||
"/tmp/hello" utf8 [ "hello!\n" write ] with-file-appender 5000000 sleep ;
|
||||
|
||||
MAIN: testthread
|
||||
MAIN: test-thread
|
||||
|
|
Loading…
Reference in New Issue