adamcpfeiffer has asked for the wisdom of the Perl Monks concerning the following question:
What I don't know is how I format line 139 to call the subroutine that is part of the object. I have tried the following:120 sub _openFDCObject 121 { 122 my $self = shift; 123 my $swObject = shift; 124 my $switch = shift; 125 my $fdcObject = FosDataCapture->new($log, $swObject); 126 return ($fdcObject, $switch); 127 } 128 129 sub getFDCObjects 130 { 131 my $self = shift; 132 my %fdcObjectHash; 133 my @threadQueue; 134 my %switches = $self->getSwitches(); 135 for my $switch (keys %switches) 136 { 137 #my $fdcObject = $self->_openFDCObject($switches{$switch}, + $switch); 138 my $swObject = $switches{$switch}; 139 my $thread = threads->create(\$self->_openFDCObject($swObj +ect,$switch)); 140 push(@threadQueue, $thread); 141 #$fdcObjectHash{$switch} = $fdcObject; 142 } 143 foreach my $thread (@threadQueue) 144 { 145 my ($fdcObject, $switch); 146 ($fdcObject, $switch) = $thread->join(); 147 $fdcObjectHash{$switch} = $fdcObject; 148 } 149 return %fdcObjectHash;
The first one above does run, but I don't see any threading happening. The other invocations don't pass $swObject and $switch to the subroutine _openFDCObject. Please let me know if you need any further information. Thanksmy $thread = threads->create(\$self->_openFDCObject($swObject,$switch) +); my $thread = threads->create(\$self->_openFDCObject,$swObject,$switch) +; my $thread = threads->create($self->_openFDCObject,$swObject,$switch); my $thread = threads->create(&_openFDCObject,$swObject,$switch);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I used a threaded subroutine inside a perl object
by BrowserUk (Patriarch) on Jul 03, 2013 at 05:55 UTC | |
by adamcpfeiffer (Novice) on Jul 03, 2013 at 12:27 UTC | |
by BrowserUk (Patriarch) on Jul 03, 2013 at 13:45 UTC | |
by adamcpfeiffer (Novice) on Jul 03, 2013 at 16:37 UTC | |
by BrowserUk (Patriarch) on Jul 03, 2013 at 18:00 UTC | |
|
Re: How do I used a threaded subroutine inside a perl object
by roboticus (Chancellor) on Jul 03, 2013 at 01:23 UTC | |
by Anonymous Monk on Jul 03, 2013 at 01:55 UTC | |
by adamcpfeiffer (Novice) on Jul 03, 2013 at 12:34 UTC |