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 "VSs__Test_App/VSs__Test_App.h" seanhalle@0: seanhalle@6: /*This demonstrates the use of the proto-runtime system. It allows multiple seanhalle@6: * languages to be mixed within a single sub-program. It also allows multiple seanhalle@6: * sub-programs to be started, where each uses its own set of languages. The seanhalle@6: * running sub-programs can then communicate with each other. seanhalle@0: * seanhalle@0: */ seanhalle@0: int main( int argc, char **argv ) seanhalle@6: { PRProcess *testProcess1, *testProcess2; seanhalle@6: seanhalle@0: DEBUG__printf2(TRUE, "arguments: %s | %s", argv[0], argv[1] ); seanhalle@0: seanhalle@6: //A proto-runtime based language sits on top of the proto-runtime. So, seanhalle@6: // first start the proto-runtime system, then create processes (which seanhalle@6: // start languages inside themselves) seanhalle@6: PR__start(); seanhalle@6: seanhalle@6: //This info shows up in the header of output files holding measurements seanhalle@6: //These calls MUST be made after PR__start and before creating a process seanhalle@6: PR__set_app_info("test of multi-lang functionality"); seanhalle@6: PR__set_input_info("no input"); seanhalle@6: seanhalle@6: seanhalle@6: //Now that PR is started, create processes. seanhalle@6: //Each process creates a seedVP and starts it running -- that then starts seanhalle@6: // the languages used inside the process.. seanhalle@6: //To get results from a process, it gets complicated.. simple soln is seanhalle@6: // just use PR's malloc and free, in the main thread, between PR__start seanhalle@6: // and PR__shutdown seanhalle@6: //The call returns a process struct (which has access to the seedVP) seanhalle@6: int32 *result = PR__malloc( 2 * sizeof(int32) ); seanhalle@6: testProcess1 = PR__create_process( &test_app_seed_Fn, result ); seanhalle@6: seanhalle@6: //testProcessor2 = PR__create_processor( &test_app2, NULL ); seanhalle@6: //PR__connect_processors(testProcess1, OUT, testProcess2, IN); seanhalle@6: //PR__connect_processors(testProcess2, OUT, testProcess1, IN); seanhalle@6: seanhalle@6: PR__wait_for_process_to_end( testProcess1 ); seanhalle@6: printf("results: %d, %d\n", result[0], result[1] ); seanhalle@6: seanhalle@6: PR__free(result); seanhalle@6: seanhalle@7: PR__wait_for_all_activity_to_end(); //equivalent of detecting shutdown seanhalle@6: PR__shutdown(); seanhalle@0: seanhalle@0: exit(0); //cleans up seanhalle@0: }