| 
									
										
										
										
											2010-02-20 23:40:19 -05:00
										 |  |  | ! 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 | 
					
						
							| 
									
										
										
										
											2009-09-27 16:11:21 -04:00
										 |  |  | unix.utilities ;
 | 
					
						
							| 
									
										
										
										
											2009-09-23 14:08:06 -04:00
										 |  |  | IN: native-thread-test | 
					
						
							| 
									
										
										
										
											2009-08-25 13:29:28 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-23 14:42:02 -05:00
										 |  |  | FUNCTION: void* start_standalone_factor_in_new_thread ( int argc, c-string* argv ) ;
 | 
					
						
							| 
									
										
										
										
											2009-08-25 13:29:28 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : start-vm-in-os-thread ( args -- threadhandle )
 | 
					
						
							| 
									
										
										
										
											2010-02-20 23:40:19 -05:00
										 |  |  |     vm prefix
 | 
					
						
							| 
									
										
										
										
											2009-08-25 13:29:28 -04:00
										 |  |  |     [ length ] [ native-string-encoding strings>alien ] bi  | 
					
						
							| 
									
										
										
										
											2010-02-20 23:40:19 -05:00
										 |  |  |     start_standalone_factor_in_new_thread ;
 | 
					
						
							| 
									
										
										
										
											2009-08-25 13:29:28 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : start-tetris-in-os-thread ( -- )
 | 
					
						
							| 
									
										
										
										
											2010-02-20 23:40:19 -05:00
										 |  |  |     { "-run=tetris" } start-vm-in-os-thread drop ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : start-test-thread-in-os-thread ( -- )
 | 
					
						
							|  |  |  |     { "-run=native-thread-test" } start-vm-in-os-thread drop ;
 | 
					
						
							| 
									
										
										
										
											2009-08-25 13:29:28 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-20 23:40:19 -05:00
										 |  |  | : test-thread ( -- )
 | 
					
						
							|  |  |  |     "/tmp/hello" utf8 [ "hello!\n" write ] with-file-appender 5000000 sleep ;
 | 
					
						
							| 
									
										
										
										
											2009-08-25 13:29:28 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-20 23:40:19 -05:00
										 |  |  | MAIN: test-thread |