[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain -->
- <!--x-date: Wed Apr 27 20:23:56 2005 -->
- <!--x-from-r13: psbjyre ng bhgcbfgfragvary.pbz (Quevfgbcure Tbjyre) -->
- <!--x-message-id: [email protected] -->
- <!--x-reference: [email protected] -->
- <!--x-reference: [email protected] -->
- <!--x-reference: [email protected] --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-subject: [ale] Perl threads -->
- <li><em>date</em>: Wed Apr 27 20:23:56 2005</li>
- <li><em>from</em>: cfowler at outpostsentinel.com (Christopher Fowler)</li>
- <li><em>in-reply-to</em>: <<a href="msg00725.html">[email protected]</a>></li>
- <li><em>references</em>: <<a href="msg00700.html">[email protected]</a>> <<a href="msg00701.html">[email protected]</a>> <<a href="msg00725.html">[email protected]</a>></li>
- <li><em>subject</em>: [ale] Perl threads</li>
I took a hint from connect(3) man page:
EINPROGRESS
The socket is non-blocking and the connection cannot be completed
immediately. It is possible to select(2)
or poll(2) for completion by selecting the socket for writing. After
select indicates writability, use get?
sockopt(2) to read the SO_ERROR option at level SOL_SOCKET to
determine whether connect completed success?
fully (SO_ERROR is zero) or unsuccessfully (SO_ERROR is one of the usual
error codes listed here, explaining
the reason for the failure).
Now a list of 10 would attempt the connect in the background. I add the
socket to the write selector then when it is okay to write I try to see
if getpeername succeeds. If it does I then commence to log into the
remote device and when I'm done with that I remove it from the write
selector to the read selector. Now the program can try to re connect to
dead hosts with causing huge delays.
On Wed, 2005-04-27 at 14:22, Fletch wrote:
> >>>>> "Christopher" == Christopher Fowler <cfowler at outpostsentinel.com> writes:
>
> Christopher> I looked at perthrtut and there seems to be a lock()
> Christopher> function but no unlock. I want to lock a variable in
> Christopher> the main program as well as a thread.
>
> If I remember correctly, locks are only active for the enclosing
> lexical scope (similar to the lifetime of a lexical variable declared
> with my). The way to lock a smaller chunk of code is to wrap it in
> its own block with a lock($whoozits) at the top.
>
>
> What you might want to do is use a higher level exclusion mechanism
> like Thread::Semaphore instead of the low level lock().
>
>
> Having said that, unless things have really changed conventional
> wisdom has been "don't use threads in Perl". In general you'll be
> better served by forking coprocesses, or using POE and letting it hide
> the nastyness.
</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00700" href="msg00700.html">[ale] Perl threads</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Christopher Fowler)</li></ul></li>
<li><strong><a name="00701" href="msg00701.html">[ale] Perl threads</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Christopher Fowler)</li></ul></li>
<li><strong><a name="00725" href="msg00725.html">[ale] Perl threads</a></strong>
<ul><li><em>From:</em> fletch at phydeaux.org (Fletch)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00735.html">[ale] Re: FAX service recommendation?</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00737.html">[ale] I'm laughing on the floor!</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00725.html">[ale] Perl threads</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00713.html">[ale] Another Perl + Threads question</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00736"><strong>Date</strong></a></li>
<li><a href="threads.html#00736"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>