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