How do you share an object(Telnet Sesion) between threads?

--001a113433725213c80520e63e31
Content-Type: text/plain; charset=UTF-8

How do you share an object(Telnet Sesion) between threads?

I need the Telnet session below available to 3 threads(connect, disconnect,
& scan). $telnetsession is of type Net::Telnet per
print(ref($telnetsession)).

This is part of a larger wxPerl script. All of the display and interlocking
between the GUI and threads seems to working corectly.

Crossposted to wxperl-users.

Thanks,
James

<code>
# Define the Thread shared data area - All threads access this scaler data
fine
my  %common : shared;
    $common{ip} = "127.0.0.1";        # Localhost
    $common{port} = "7356";        # Local Port as defined in gqrx
    $common{telnetsession} = 0;        # Object Pointer ??? Problem ???
    $common{tnerror} = 0;        # Status
    $common{connect} = 0;        # Command
    $common{connected} = 0;        # Status
    $common{disconnect} = 0;        # Command
    $common{scanstart} = 0;        # Command
    $common{scanstarted} = 0;        # Status
    $common{beginf} = 0;        # Scan - Beginning Frequency
    $common{endf} = 0;            # Scan - Ending Frequency
    $common{step} = 0;            # Scan - Frequency Step
    $common{squelch} = 0;        # Scan - Minimum RSSI(Recieved Signal
Strength Indicator)
    $common{rssi} = 0;            # Scan - Latest RSSI
    $common{pause} = 0;            # Scan - Time between scans - msec
    $common{listen} = 0;        # Scan - Time to Listen to a strong signal
- msec
    $common{mode} = 0;            # Scan - Demodulator Type
    $common{stopthreads} = 0;        # Command


# Connect the Telnet Session - #1
sub Connect {
    while(1) {
        if($common{stopthreads}) {print "\nConnect Thread Terminated\n";
return};
        if($common{connect}) {
            if(!$common{connected}) {
               print "Open Telnet Connection to gqrx\n";
               my $telnetsession = Net::Telnet->new(Timeout => 2, port =>
$common{port},
                                        Errmode => sub {$common{tnerror} =
1;});
               $telnetsession->open($common{ip});
               $common{telnetsession} = shared_clone($telnetsession);
# Line 92 Errors
               $common{connected} = 1;
               $common{connect} = 0;
            }
        }
        threads->yield();
    }
}
</code>

<code>
Error message:
Thread 1 terminated abnormally: Unsupported ref type: GLOB at
../threadedgqrxLite.pl line 92 thread 1
</code>

--001a113433725213c80520e63e31
Content-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.wxperl.users 3070 articles. 0 followers. Follow

3 Replies
238 Views

Similar Articles

[PageSpeed] 1

Hi James,

I'm not sure what you already know, but any OO-style module should be of 
the form $obj=Foo::Bar->new();
$obj is a pointer that holds the class and the object as the first two 
variables and you should be able to access anything from it.

     use  Net::Telnet  ();
     $obj  =  Net::Telnet->new(Timeout=>  20);

Maybe you could take the while(1) out of the connect() sub routine and then

     return $telnetsession;

As the last line of the routine.

Here is an example of how it can work:

http://www.perlfect.com/articles/telnet.shtml

I also suggest that while(1), is a bit uncompromising, 
while(!$common{connected}) would be more controlled and using a for loop 
to try a limited number of times, even more so.

Good luck,

Regards

Steve.

On 29/09/15 18:35, James Lynes wrote:
> How do you share an object(Telnet Sesion) between threads?
>
> I need the Telnet session below available to 3 threads(connect, 
> disconnect, & scan). $telnetsession is of type Net::Telnet per 
> print(ref($telnetsession)).
>
> This is part of a larger wxPerl script. All of the display and 
> interlocking between the GUI and threads seems to working corectly.
>
> Crossposted to wxperl-users.
>
> Thanks,
> James
>
> <code>
> # Define the Thread shared data area - All threads access this scaler 
> data fine
> my  %common : shared;
>     $common{ip} = "127.0.0.1";        # Localhost
>     $common{port} = "7356";        # Local Port as defined in gqrx
>     $common{telnetsession} = 0;        # Object Pointer ??? Problem ???
>     $common{tnerror} = 0;        # Status
>     $common{connect} = 0;        # Command
>     $common{connected} = 0;        # Status
>     $common{disconnect} = 0;        # Command
>     $common{scanstart} = 0;        # Command
>     $common{scanstarted} = 0;        # Status
>     $common{beginf} = 0;        # Scan - Beginning Frequency
>     $common{endf} = 0;            # Scan - Ending Frequency
>     $common{step} = 0;            # Scan - Frequency Step
>     $common{squelch} = 0;        # Scan - Minimum RSSI(Recieved Signal 
> Strength Indicator)
>     $common{rssi} = 0;            # Scan - Latest RSSI
>     $common{pause} = 0;            # Scan - Time between scans - msec
>     $common{listen} = 0;        # Scan - Time to Listen to a strong 
> signal - msec
>     $common{mode} = 0;            # Scan - Demodulator Type
>     $common{stopthreads} = 0;        # Command
>
>
> # Connect the Telnet Session - #1
> sub Connect {
>     while(1) {
>         if($common{stopthreads}) {print "\nConnect Thread 
> Terminated\n"; return};
>         if($common{connect}) {
>             if(!$common{connected}) {
>                print "Open Telnet Connection to gqrx\n";
>                my $telnetsession = Net::Telnet->new(Timeout => 2, port 
> => $common{port},
>                                         Errmode => sub 
> {$common{tnerror} = 1;});
>                $telnetsession->open($common{ip});
>                $common{telnetsession} = 
> shared_clone($telnetsession);      # Line 92 Errors
>                $common{connected} = 1;
>                $common{connect} = 0;
>             }
>         }
>         threads->yield();
>     }
> }
> </code>
>
> <code>
> Error message:
> Thread 1 terminated abnormally: Unsupported ref type: GLOB at 
> ./threadedgqrxLite.pl line 92 thread 1
> </code>
>
>

0
steveco
9/30/2015 11:44:28 AM
--089e0158c00e9911260520fa14dd
Content-Type: text/plain; charset=UTF-8

Hi Steve:

The Monks said basically you can't do that. Not supported by
threads::shared. Only references to shared scalers are supported. Possibly
a convoluted way to manipulate object internals. Several have tried in the
past with limited success.

It was suggested to refactor as a server process that handles all Telnet
interactions. I'm working on that now. Having a subtle compiler error that
I am working at figuring out.

I appreciate your responses.

James



On Wed, Sep 30, 2015 at 7:44 AM, Steve Cookson - gmail <
steveco.1959@gmail.com> wrote:

> Hi James,
>
> I'm not sure what you already know, but any OO-style module should be of
> the form $obj=Foo::Bar->new();
> $obj is a pointer that holds the class and the object as the first two
> variables and you should be able to access anything from it.
>
>     use  Net::Telnet  ();
>     $obj  =  Net::Telnet->new(Timeout=>  20);
>
> Maybe you could take the while(1) out of the connect() sub routine and then
>
>     return $telnetsession;
>
> As the last line of the routine.
>
> Here is an example of how it can work:
>
> http://www.perlfect.com/articles/telnet.shtml
>
> I also suggest that while(1), is a bit uncompromising,
> while(!$common{connected}) would be more controlled and using a for loop to
> try a limited number of times, even more so.
>
> Good luck,
>
> Regards
>
> Steve.
>
>
> On 29/09/15 18:35, James Lynes wrote:
>
>> How do you share an object(Telnet Sesion) between threads?
>>
>> I need the Telnet session below available to 3 threads(connect,
>> disconnect, & scan). $telnetsession is of type Net::Telnet per
>> print(ref($telnetsession)).
>>
>> This is part of a larger wxPerl script. All of the display and
>> interlocking between the GUI and threads seems to working corectly.
>>
>> Crossposted to wxperl-users.
>>
>> Thanks,
>> James
>>
>> <code>
>> # Define the Thread shared data area - All threads access this scaler
>> data fine
>> my  %common : shared;
>>     $common{ip} = "127.0.0.1";        # Localhost
>>     $common{port} = "7356";        # Local Port as defined in gqrx
>>     $common{telnetsession} = 0;        # Object Pointer ??? Problem ???
>>     $common{tnerror} = 0;        # Status
>>     $common{connect} = 0;        # Command
>>     $common{connected} = 0;        # Status
>>     $common{disconnect} = 0;        # Command
>>     $common{scanstart} = 0;        # Command
>>     $common{scanstarted} = 0;        # Status
>>     $common{beginf} = 0;        # Scan - Beginning Frequency
>>     $common{endf} = 0;            # Scan - Ending Frequency
>>     $common{step} = 0;            # Scan - Frequency Step
>>     $common{squelch} = 0;        # Scan - Minimum RSSI(Recieved Signal
>> Strength Indicator)
>>     $common{rssi} = 0;            # Scan - Latest RSSI
>>     $common{pause} = 0;            # Scan - Time between scans - msec
>>     $common{listen} = 0;        # Scan - Time to Listen to a strong
>> signal - msec
>>     $common{mode} = 0;            # Scan - Demodulator Type
>>     $common{stopthreads} = 0;        # Command
>>
>>
>> # Connect the Telnet Session - #1
>> sub Connect {
>>     while(1) {
>>         if($common{stopthreads}) {print "\nConnect Thread Terminated\n";
>> return};
>>         if($common{connect}) {
>>             if(!$common{connected}) {
>>                print "Open Telnet Connection to gqrx\n";
>>                my $telnetsession = Net::Telnet->new(Timeout => 2, port =>
>> $common{port},
>>                                         Errmode => sub {$common{tnerror}
>> = 1;});
>>                $telnetsession->open($common{ip});
>>                $common{telnetsession} = shared_clone($telnetsession);
>>   # Line 92 Errors
>>                $common{connected} = 1;
>>                $common{connect} = 0;
>>             }
>>         }
>>         threads->yield();
>>     }
>> }
>> </code>
>>
>> <code>
>> Error message:
>> Thread 1 terminated abnormally: Unsupported ref type: GLOB at
>> ./threadedgqrxLite.pl line 92 thread 1
>> </code>
>>
>>
>>
>

--089e0158c00e9911260520fa14dd
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div><div><div>Hi Steve:<br><br></div>The Monks said =
basically you can&#39;t do that. Not supported by threads::shared. Only ref=
erences to shared scalers are supported. Possibly a convoluted way to manip=
ulate object internals. Several have tried in the past with limited success=
..<br><br></div>It was suggested to refactor as a server process that handle=
s all Telnet interactions. I&#39;m working on that now. Having a subtle com=
piler error that I am working at figuring out.<br><br></div>I appreciate yo=
ur responses.<br><br></div>James<br><br><div><div><div>=C2=A0</div></div></=
div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Wed,=
 Sep 30, 2015 at 7:44 AM, Steve Cookson - gmail <span dir=3D"ltr">&lt;<a hr=
ef=3D"mailto:steveco.1959@gmail.com" target=3D"_blank">steveco.1959@gmail.c=
om</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"marg=
in:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi James,<br>
<br>
I&#39;m not sure what you already know, but any OO-style module should be o=
f the form $obj=3DFoo::Bar-&gt;new();<br>
$obj is a pointer that holds the class and the object as the first two vari=
ables and you should be able to access anything from it.<br>
<br>
=C2=A0 =C2=A0 use=C2=A0 Net::Telnet=C2=A0 ();<br>
=C2=A0 =C2=A0 $obj=C2=A0 =3D=C2=A0 Net::Telnet-&gt;new(Timeout=3D&gt;=C2=A0=
 20);<br>
<br>
Maybe you could take the while(1) out of the connect() sub routine and then=
<br>
<br>
=C2=A0 =C2=A0 return $telnetsession;<br>
<br>
As the last line of the routine.<br>
<br>
Here is an example of how it can work:<br>
<br>
<a href=3D"http://www.perlfect.com/articles/telnet.shtml" rel=3D"noreferrer=
" target=3D"_blank">http://www.perlfect.com/articles/telnet.shtml</a><br>
<br>
I also suggest that while(1), is a bit uncompromising, while(!$common{conne=
cted}) would be more controlled and using a for loop to try a limited numbe=
r of times, even more so.<br>
<br>
Good luck,<br>
<br>
Regards<span class=3D"HOEnZb"><font color=3D"#888888"><br>
<br>
Steve.</font></span><div class=3D"HOEnZb"><div class=3D"h5"><br>
<br>
On 29/09/15 18:35, James Lynes wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
How do you share an object(Telnet Sesion) between threads?<br>
<br>
I need the Telnet session below available to 3 threads(connect, disconnect,=
 &amp; scan). $telnetsession is of type Net::Telnet per print(ref($telnetse=
ssion)).<br>
<br>
This is part of a larger wxPerl script. All of the display and interlocking=
 between the GUI and threads seems to working corectly.<br>
<br>
Crossposted to wxperl-users.<br>
<br>
Thanks,<br>
James<br>
<br>
&lt;code&gt;<br>
# Define the Thread shared data area - All threads access this scaler data =
fine<br>
my=C2=A0 %common : shared;<br>
=C2=A0 =C2=A0 $common{ip} =3D &quot;127.0.0.1&quot;;=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 # Localhost<br>
=C2=A0 =C2=A0 $common{port} =3D &quot;7356&quot;;=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 # Local Port as defined in gqrx<br>
=C2=A0 =C2=A0 $common{telnetsession} =3D 0;=C2=A0 =C2=A0 =C2=A0 =C2=A0 # Ob=
ject Pointer ??? Problem ???<br>
=C2=A0 =C2=A0 $common{tnerror} =3D 0;=C2=A0 =C2=A0 =C2=A0 =C2=A0 # Status<b=
r>
=C2=A0 =C2=A0 $common{connect} =3D 0;=C2=A0 =C2=A0 =C2=A0 =C2=A0 # Command<=
br>
=C2=A0 =C2=A0 $common{connected} =3D 0;=C2=A0 =C2=A0 =C2=A0 =C2=A0 # Status=
<br>
=C2=A0 =C2=A0 $common{disconnect} =3D 0;=C2=A0 =C2=A0 =C2=A0 =C2=A0 # Comma=
nd<br>
=C2=A0 =C2=A0 $common{scanstart} =3D 0;=C2=A0 =C2=A0 =C2=A0 =C2=A0 # Comman=
d<br>
=C2=A0 =C2=A0 $common{scanstarted} =3D 0;=C2=A0 =C2=A0 =C2=A0 =C2=A0 # Stat=
us<br>
=C2=A0 =C2=A0 $common{beginf} =3D 0;=C2=A0 =C2=A0 =C2=A0 =C2=A0 # Scan - Be=
ginning Frequency<br>
=C2=A0 =C2=A0 $common{endf} =3D 0;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 # Scan - Ending Frequency<br>
=C2=A0 =C2=A0 $common{step} =3D 0;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 # Scan - Frequency Step<br>
=C2=A0 =C2=A0 $common{squelch} =3D 0;=C2=A0 =C2=A0 =C2=A0 =C2=A0 # Scan - M=
inimum RSSI(Recieved Signal Strength Indicator)<br>
=C2=A0 =C2=A0 $common{rssi} =3D 0;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 # Scan - Latest RSSI<br>
=C2=A0 =C2=A0 $common{pause} =3D 0;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 # Scan - Time between scans - msec<br>
=C2=A0 =C2=A0 $common{listen} =3D 0;=C2=A0 =C2=A0 =C2=A0 =C2=A0 # Scan - Ti=
me to Listen to a strong signal - msec<br>
=C2=A0 =C2=A0 $common{mode} =3D 0;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 # Scan - Demodulator Type<br>
=C2=A0 =C2=A0 $common{stopthreads} =3D 0;=C2=A0 =C2=A0 =C2=A0 =C2=A0 # Comm=
and<br>
<br>
<br>
# Connect the Telnet Session - #1<br>
sub Connect {<br>
=C2=A0 =C2=A0 while(1) {<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if($common{stopthreads}) {print &quot;\nConnect=
 Thread Terminated\n&quot;; return};<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if($common{connect}) {<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if(!$common{connected}) {<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0print &quot;Open Tel=
net Connection to gqrx\n&quot;;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0my $telnetsession =
=3D Net::Telnet-&gt;new(Timeout =3D&gt; 2, port =3D&gt; $common{port},<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Errmode =
=3D&gt; sub {$common{tnerror} =3D 1;});<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$telnetsession-&gt;o=
pen($common{ip});<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$common{telnetsessio=
n} =3D shared_clone($telnetsession);=C2=A0 =C2=A0 =C2=A0 # Line 92 Errors<b=
r>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$common{connected} =
=3D 1;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$common{connect} =3D=
 0;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 threads-&gt;yield();<br>
=C2=A0 =C2=A0 }<br>
}<br>
&lt;/code&gt;<br>
<br>
&lt;code&gt;<br>
Error message:<br>
Thread 1 terminated abnormally: Unsupported ref type: GLOB at ./threadedgqr=
xLite.pl line 92 thread 1<br>
&lt;/code&gt;<br>
<br>
<br>
</blockquote>
<br>
</div></div></blockquote></div><br></div>

--089e0158c00e9911260520fa14dd--
0
jmlynesjr
9/30/2015 5:15:42 PM
Sorry, I forgot you were talking about communicating between threads.

On 30/09/15 18:15, James Lynes wrote:
> The Monks said basically you can't do that. Not supported by 
> threads::shared. Only references to shared scalers are supported. 
> Possibly a convoluted way to manipulate object internals. Several have 
> tried in the past with limited success.

Why do you need multiple threads?  I did have that at one stage, but in 
the end I found that the computer just kept starting threads until the 
cpu was running at 100%.

If the threads are:

Connect
Scan
Disconnect,

Maybe you could design it differently.  I guess you only want to run one 
at a time, eg if you are not connected you can connect, but if you are 
already connected, you don't want to connect again, and the same for 
disconnect.  You can only scan if you are connected.

In which case you have only one or zero threads starting and stopping, 
but no communication between threads.

Whenever I've had multiple threads, they have been completely 
independent from one another, like go process a video snapshot and tell 
me when you are done (ie pass a status back).

If you really must have communication between threads, you can use a 
file or a database.

Regards

Steve.
0
steveco
10/1/2015 8:51:57 AM
Reply: