Hello, fellow monks.
I am aware that the 5.8 threads model differs from system to system and compiling options so after reading the POD over and over, super-searching PM and reading up on several thread-threads, and actual code testing, I am still left with some doubt, and would greatly appreciate any experts here for their $0.02!
First, I assume that the Linux, FreeBSD and most other Unix or Unix-like systems, except perhaps for Solaris, must have very similar threads implementations with the vanilla Perl 5.8.x offered in these platforms. I would assume that for example in most Linux systems, a vanilla Perl threads implementation will use, or compiled by default to use LWP aka Kernel Threads. Any in-depth comments for *nix OSs here very welcome.
Second, and my actual question is that if using threads->yield _plus_ a millisecond delay with Time::HiRes is redundant, and if the snippet below is doing what I want: to yield at least 250 milliseconds of time to other threads before checking for the queue again. I am thinking that the yield is actually issuing a single no-op and really isn't doing much... but is the usleep() accomplishing what I need?
Thridly, I would like to know if using Time::HiRes is thread safe, especially if I'm using Perl GTK2 which make everything a lot more fragile (not because of Perl but because of GTK-intrinsic threading flaws, which I have already learned to tame for the most part).
REPEAT:
[...]
# gomr note ready yet...
if($imgaq->pending){
# yield CPU...
threads->yield;
# 250 milisecond delay
usleep(250000);
warn "GOMR NOT READY...";
goto REPEAT;
}
Thanks a bunch in advance,
Alejandro Imass
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.