Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > PRDSL > PRDSL__Test_App
diff main.c @ 0:1cb25216938b
Initial add -- working
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Thu, 19 Sep 2013 18:08:07 -0700 |
| parents | |
| children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/main.c Thu Sep 19 18:08:07 2013 -0700 1.3 @@ -0,0 +1,50 @@ 1.4 +/* 1.5 + * Copyright 2012 OpenSourceResearchInstitute.org 1.6 + * Licensed under GNU General Public License version 2 1.7 + * 1.8 + * author seanhalle@yahoo.com 1.9 + */ 1.10 + 1.11 +#include <malloc.h> 1.12 +#include <stdlib.h> 1.13 + 1.14 +#include "PRDSL__Test_App/PRDSL__Test_App.h" 1.15 +#include <PR__include/PR__WL.h> //declares PR__create_process 1.16 + 1.17 + 1.18 +/*This demonstrates the use of the proto-runtime system. It allows multiple 1.19 + * languages to be mixed within a single sub-program. It also allows multiple 1.20 + * sub-programs to be started, where each uses its own set of languages. The 1.21 + * running sub-programs can then communicate with each other. 1.22 + * 1.23 + */ 1.24 +int main( int argc, char **argv ) 1.25 + { PRProcess *testProcess1, *testProcess2; 1.26 + 1.27 + DEBUG__printf(TRUE, "arguments: %s | %s", argv[0], argv[1] ); 1.28 + 1.29 + //A proto-runtime based language sits on top of the proto-runtime. So, 1.30 + // first start the proto-runtime system, then create processes (which 1.31 + // start languages inside themselves) 1.32 + PR__start(); 1.33 + 1.34 + //Now that PR is started, create processes. 1.35 + //Each process creates a seedVP and starts it running -- that then starts 1.36 + // the languages used inside the process.. 1.37 + //To get results from a process, it gets complicated.. simple soln is 1.38 + // just use PR's malloc and free, in the main thread, between PR__start 1.39 + // and PR__shutdown 1.40 + //The call returns a process struct (which has access to the seedVP) 1.41 + int32 *result = PR__malloc( 2 * sizeof(int32) ); 1.42 + testProcess1 = PR__create_process( &test_app_seed_Fn, result ); 1.43 + 1.44 + PR__wait_for_process_to_end( testProcess1 ); 1.45 + printf("\n\nresults: %d, %d\n\n", result[0], result[1] ); 1.46 + 1.47 + PR__free(result); 1.48 + 1.49 + PR__wait_for_all_activity_to_end(); //equivalent of detecting shutdown 1.50 + PR__shutdown(); 1.51 + 1.52 + exit(0); //cleans up 1.53 + }
