From: Kartik Thakore Date: Thu, 5 Nov 2009 15:52:17 +0000 (-0500) Subject: MultiTheadPOC.pl added. It shows quickly how we can use Inline::C to do threading... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=15d93b1bd9524b30fa18143a99c5f7eb89ce28e5;p=sdlgit%2FSDL_perl.git MultiTheadPOC.pl added. It shows quickly how we can use Inline::C to do threading with SDL MultiThreading. You need to install Inline::C btw :) --- diff --git a/scripts/MultiThreadPOC.pl b/scripts/MultiThreadPOC.pl new file mode 100644 index 0000000..8c46eaa --- /dev/null +++ b/scripts/MultiThreadPOC.pl @@ -0,0 +1,37 @@ +use Inline C => DATA => + LIBS => `sdl-config --libs` => + INC => `sdl-config --cflags`; + +my $fp = get_function_pointer(); +print '[Perl] In perl we got :'.$fp."\n"; +print '[Perl] Making Thread.'; + +make_thread( $fp, 'I AM THE OVERLOARD XENU!!!'); + +__END__ +__C__ + +#include +#include + +char DoIt(char* c){ + int threadID = SDL_ThreadID(); + printf("[C-Thread] we are in %d \n", &threadID); + printf("[C-Thread] Called with %s \n", c); + return c; +} + +int get_function_pointer() { + printf("[C] Function Pointer is at %d!\n", &DoIt); + return PTR2IV(&DoIt); +} + + +int make_thread(IV pointer, char* c) +{ + void * fp = INT2PTR( void *, pointer); + void * data = c; + SDL_CreateThread( fp, data ); + printf("[C] Created thread: \n"); +} +