seanhalle@0: /* seanhalle@0: * Copyright 2012 OpenSourceResearchInstitute.org seanhalle@0: * Licensed under GNU General Public License version 2 seanhalle@0: * seanhalle@0: * author seanhalle@yahoo.com seanhalle@0: */ seanhalle@0: seanhalle@0: #include seanhalle@0: #include seanhalle@0: seanhalle@0: #include "PRDSL__Test_App/PRDSL__Test_App.h" seanhalle@0: #include //declares PR__create_process seanhalle@0: seanhalle@0: seanhalle@0: /*This demonstrates the use of the proto-runtime system. It allows multiple seanhalle@0: * languages to be mixed within a single sub-program. It also allows multiple seanhalle@0: * sub-programs to be started, where each uses its own set of languages. The seanhalle@0: * running sub-programs can then communicate with each other. seanhalle@0: * seanhalle@0: */ seanhalle@0: int main( int argc, char **argv ) seanhalle@0: { PRProcess *testProcess1, *testProcess2; seanhalle@0: seanhalle@0: DEBUG__printf(TRUE, "arguments: %s | %s", argv[0], argv[1] ); seanhalle@0: seanhalle@0: //A proto-runtime based language sits on top of the proto-runtime. So, seanhalle@0: // first start the proto-runtime system, then create processes (which seanhalle@0: // start languages inside themselves) seanhalle@0: PR__start(); seanhalle@0: seanhalle@0: //Now that PR is started, create processes. seanhalle@0: //Each process creates a seedVP and starts it running -- that then starts seanhalle@0: // the languages used inside the process.. seanhalle@0: //To get results from a process, it gets complicated.. simple soln is seanhalle@0: // just use PR's malloc and free, in the main thread, between PR__start seanhalle@0: // and PR__shutdown seanhalle@0: //The call returns a process struct (which has access to the seedVP) seanhalle@0: int32 *result = PR__malloc( 2 * sizeof(int32) ); seanhalle@0: testProcess1 = PR__create_process( &test_app_seed_Fn, result ); seanhalle@0: seanhalle@0: PR__wait_for_process_to_end( testProcess1 ); seanhalle@0: printf("\n\nresults: %d, %d\n\n", result[0], result[1] ); seanhalle@0: seanhalle@0: PR__free(result); seanhalle@0: seanhalle@0: PR__wait_for_all_activity_to_end(); //equivalent of detecting shutdown seanhalle@0: PR__shutdown(); seanhalle@0: seanhalle@0: exit(0); //cleans up seanhalle@0: }