Hi BrowserUK, This is my first try at threads so you are right that my understanding is currently limited.
Inside the method I am trying to call, I am creating a new FosDataCapture Object. During the _init phase of this object it gathers a bunch of data via telnet from the swObject (this is a fibre channel switch). This process can take 60 seconds for switch and I will have over 30 switches when running in production. Without threading, this portion of the code will take too long to run. I think that answers the first two questions.
You stated that threads->create() requires a code reference. According to the threads link you posed it states the following:
--------- $thr = threads->create(FUNCTION, ARGS) This will create a new thread that will begin execution with the specified entry point function, and give it the ARGS list as parameters. It will return the corresponding threads object, or undef if thread creation failed. FUNCTION may either be the name of a function, an anonymous subroutine, or a code ref -------------With this definition, my first thought my call should be like this:
$thread = threads->create($self->_openFDCObject,$swObject,$switch);
When I called it like this, $swObject and $switch do not get passed into the function. So I tried a few other structures to see what might work since I could find no examples of how to use threads inside an object when calling a function inside the object.
Any further help would be greatly appreciated. ThanksIn reply to Re^2: How do I used a threaded subroutine inside a perl object
by adamcpfeiffer
in thread How do I used a threaded subroutine inside a perl object
by adamcpfeiffer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |