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