Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > VSs > VSs__Test_App__LangDev
comparison main.c @ 6:1c9122bfd1c8
ML_dev -- Compiles and runs
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Sat, 02 Mar 2013 10:03:18 -0800 |
| parents | 7a85919442f2 |
| children | eecb8b6c092d |
comparison
equal
deleted
inserted
replaced
| 0:29e44962b4aa | 1:9b85b803d6e2 |
|---|---|
| 8 #include <malloc.h> | 8 #include <malloc.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 | 10 |
| 11 #include "VSs__Test_App/VSs__Test_App.h" | 11 #include "VSs__Test_App/VSs__Test_App.h" |
| 12 | 12 |
| 13 /* | 13 /*This demonstrates the use of the proto-runtime system. It allows multiple |
| 14 * languages to be mixed within a single sub-program. It also allows multiple | |
| 15 * sub-programs to be started, where each uses its own set of languages. The | |
| 16 * running sub-programs can then communicate with each other. | |
| 14 * | 17 * |
| 15 */ | 18 */ |
| 16 int main( int argc, char **argv ) | 19 int main( int argc, char **argv ) |
| 17 { | 20 { PRProcess *testProcess1, *testProcess2; |
| 18 | 21 |
| 19 DEBUG__printf2(TRUE, "arguments: %s | %s", argv[0], argv[1] ); | 22 DEBUG__printf2(TRUE, "arguments: %s | %s", argv[0], argv[1] ); |
| 20 | 23 |
| 21 VSs__Test_App( ); | 24 //A proto-runtime based language sits on top of the proto-runtime. So, |
| 25 // first start the proto-runtime system, then create processes (which | |
| 26 // start languages inside themselves) | |
| 27 PR__start(); | |
| 28 | |
| 29 //This info shows up in the header of output files holding measurements | |
| 30 //These calls MUST be made after PR__start and before creating a process | |
| 31 PR__set_app_info("test of multi-lang functionality"); | |
| 32 PR__set_input_info("no input"); | |
| 33 | |
| 34 | |
| 35 //Now that PR is started, create processes. | |
| 36 //Each process creates a seedVP and starts it running -- that then starts | |
| 37 // the languages used inside the process.. | |
| 38 //To get results from a process, it gets complicated.. simple soln is | |
| 39 // just use PR's malloc and free, in the main thread, between PR__start | |
| 40 // and PR__shutdown | |
| 41 //The call returns a process struct (which has access to the seedVP) | |
| 42 int32 *result = PR__malloc( 2 * sizeof(int32) ); | |
| 43 testProcess1 = PR__create_process( &test_app_seed_Fn, result ); | |
| 44 | |
| 45 //testProcessor2 = PR__create_processor( &test_app2, NULL ); | |
| 46 //PR__connect_processors(testProcess1, OUT, testProcess2, IN); | |
| 47 //PR__connect_processors(testProcess2, OUT, testProcess1, IN); | |
| 48 | |
| 49 PR__wait_for_process_to_end( testProcess1 ); | |
| 50 printf("results: %d, %d\n", result[0], result[1] ); | |
| 51 | |
| 52 PR__free(result); | |
| 53 | |
| 54 //PR__wait_for_all_activity_to_end(); //equivalent of detecting shutdown | |
| 55 PR__shutdown(); | |
| 22 | 56 |
| 23 exit(0); //cleans up | 57 exit(0); //cleans up |
| 24 } | 58 } |
