in reply to Re: Perl/Tk Multithreading
in thread Perl/Tk Multithreading

sorry I missed the opening parentheses for @Arguments first I declared a hash where functions are stored which I call them in thread, like: %FunctionsToLaunchThread = ( "run_script" => \&run_script ); and then I created a thread: $Thread = threads->create( \&WorkThread ); Now I created a subroutine sub runtk where i assigned
$FunctionName = "run_script"; @ArgumentsThread = ($new);
so now the following $FunctionsToLaunchThread{$FunctionName}->(@ArgumentsThread); becomes $FunctionsToLaunchThread{run_script}->($new) which is \&run_script->($new); The above function is expected to call the function in the thread. The run_script subroutine I already shared in previous post. As you said its true I am facing a blocking problem on the device I/O. The thread is created and is loading the do "add.pl" but now in the add.pl I am using network modules, this modules are blocked for the thread to work completely. I am getting following errors: 1. "unable call method purge_all() in the Modem.pm on undentified variable" 2. "undefined value for a shared variable at line.... in Modem.pm" So is there any way to work around this. I wanted to share the working code but it is too big.

Replies are listed 'Best First'.
Re^3: Perl/Tk Multithreading
by zentara (Cardinal) on Jul 18, 2011 at 11:55 UTC
    I am getting following errors: 1. "unable call method purge_all() in the Modem.pm on undentified variable" 2. "undefined value for a shared variable at line.... in Modem.pm" So is there any way to work around this.

    You probably should work on getting the network code functioning on it's own, before putting it into a thread. Some tricks are to wrap the network code in an eval with an alarm. See Thread Safe alarms?.

    You are not showing a complete code for this, so as a guess, one of the other mistakes may be that you are declaring your GSM network module globally in the main thread.... try to confine all network code, including the use statement, to the worker thread. Many modules are still not thread safe.


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh