| rev |
line source |
|
seanhalle@0
|
1 /*
|
|
seanhalle@0
|
2 * Copyright 2012 OpenSourceResearchInstitute.org
|
|
seanhalle@0
|
3 * Licensed under GNU General Public License version 2
|
|
seanhalle@0
|
4 *
|
|
seanhalle@0
|
5 * author seanhalle@yahoo.com
|
|
seanhalle@0
|
6 */
|
|
seanhalle@0
|
7
|
|
seanhalle@0
|
8 #include <malloc.h>
|
|
seanhalle@0
|
9 #include <stdlib.h>
|
|
seanhalle@0
|
10
|
|
seanhalle@0
|
11 #include "PRDSL__Test_App/PRDSL__Test_App.h"
|
|
seanhalle@0
|
12 #include <PR__include/PR__WL.h> //declares PR__create_process
|
|
seanhalle@0
|
13
|
|
seanhalle@0
|
14
|
|
seanhalle@0
|
15 /*This demonstrates the use of the proto-runtime system. It allows multiple
|
|
seanhalle@0
|
16 * languages to be mixed within a single sub-program. It also allows multiple
|
|
seanhalle@0
|
17 * sub-programs to be started, where each uses its own set of languages. The
|
|
seanhalle@0
|
18 * running sub-programs can then communicate with each other.
|
|
seanhalle@0
|
19 *
|
|
seanhalle@0
|
20 */
|
|
seanhalle@0
|
21 int main( int argc, char **argv )
|
|
seanhalle@0
|
22 { PRProcess *testProcess1, *testProcess2;
|
|
seanhalle@0
|
23
|
|
seanhalle@0
|
24 DEBUG__printf(TRUE, "arguments: %s | %s", argv[0], argv[1] );
|
|
seanhalle@0
|
25
|
|
seanhalle@0
|
26 //A proto-runtime based language sits on top of the proto-runtime. So,
|
|
seanhalle@0
|
27 // first start the proto-runtime system, then create processes (which
|
|
seanhalle@0
|
28 // start languages inside themselves)
|
|
seanhalle@0
|
29 PR__start();
|
|
seanhalle@0
|
30
|
|
seanhalle@0
|
31 //Now that PR is started, create processes.
|
|
seanhalle@0
|
32 //Each process creates a seedVP and starts it running -- that then starts
|
|
seanhalle@0
|
33 // the languages used inside the process..
|
|
seanhalle@0
|
34 //To get results from a process, it gets complicated.. simple soln is
|
|
seanhalle@0
|
35 // just use PR's malloc and free, in the main thread, between PR__start
|
|
seanhalle@0
|
36 // and PR__shutdown
|
|
seanhalle@0
|
37 //The call returns a process struct (which has access to the seedVP)
|
|
seanhalle@0
|
38 int32 *result = PR__malloc( 2 * sizeof(int32) );
|
|
seanhalle@0
|
39 testProcess1 = PR__create_process( &test_app_seed_Fn, result );
|
|
seanhalle@0
|
40
|
|
seanhalle@0
|
41 PR__wait_for_process_to_end( testProcess1 );
|
|
seanhalle@0
|
42 printf("\n\nresults: %d, %d\n\n", result[0], result[1] );
|
|
seanhalle@0
|
43
|
|
seanhalle@0
|
44 PR__free(result);
|
|
seanhalle@0
|
45
|
|
seanhalle@0
|
46 PR__wait_for_all_activity_to_end(); //equivalent of detecting shutdown
|
|
seanhalle@0
|
47 PR__shutdown();
|
|
seanhalle@0
|
48
|
|
seanhalle@0
|
49 exit(0); //cleans up
|
|
seanhalle@0
|
50 }
|