source: CIVL/examples/concurrency/sendClosure.cvl

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 847 bytes
Line 
1#include <stdio.h>
2#include <comm.cvh>
3
4void testStream($gcomm gc){
5 $comm comm = $comm_create($here, gc, 1);
6 $message message = $comm_dequeue(comm, 0, $COMM_ANY_TAG);
7 printf("New kernel message received\n");
8 void (*kernel)();
9 $message_unpack(message, (void*)&kernel, sizeof(kernel));
10 kernel();
11 $comm_destroy(comm);
12}
13
14void print(int num){
15 printf("Inside kernel function with number %d!\n", num);
16}
17
18void main(){
19 $gcomm gcomm = $gcomm_create($here, 2);
20 $comm comm = $comm_create($here, gcomm, 0);
21 $proc otherProc = $spawn testStream(gcomm);
22 int x;
23 void capturedPrint() {
24 print(x);
25 }
26 void (*printFunc)() = &capturedPrint;
27 $message message = $message_pack(0, 1, 0, &printFunc, sizeof(printFunc));
28 $comm_enqueue(comm, message);
29 x = 25;
30 $wait(otherProc);
31 $comm_destroy(comm);
32 $gcomm_destroy(gcomm, NULL);
33}
Note: See TracBrowser for help on using the repository browser.