Similar Threads:
1.Sharing socket handles accross processes or threads
Friends
I have been using Net::SMTP::Server::Net
I want to pass client handles (Net::SMTP::Server::Net::Client) to
another process or thread.
I naivly expected to use threads and global memory but in Perl (as it
turns out) I can only share scalars, hashes and arrays. The
Net::SMTP::Server::Client->new($conn) is a glob. I am not 100% sure I
know exactly what this means!
Is there any way that I can pass the connection for the
SMTP::Server->accept accross processes or threads or do I have to spawn
a new process for each instance?
Worik
2.share semaphore across threads
3.threads & threads::shared & Threads::Semaphore
Hi, All,
Hope everyone's new year is starting out very well.
I'm having to adjust a perl program I wrote to manipulate some
genetics data. Originally, the program had no memory problems but now
that I've added a couple more hashes, I'm having memory issues. It
now runs out of memory when it's about half way through processing the
data. Unfortunately, the data is very interconnected and the
statistics I need to execute involves data from several of the
hashes. I'm thinking of using threads & threads::shared in order to
be able to process, store and access the data among several of 8
processors on a Sun Spark system. Of course, I'll need to install the
threads and threads::shared modules and possible even re-compile perl
on this machine but before I go and do all this fun stuff, I wanted to
ask your opinion about whether or not I'm going down the right rabbit
hole or if I'm just digging myself a shallow grave. Would this be the
way you might do it? I've also heard of Semaphores. Might this be a
better way to go about spreading the data in hash form among several
processors on one machine and still be able to access the data in each
hash from the main program?
Thanks in advance for the excellent input I always get from this
group! :-)
Aimee Cardenas
4.shared variables in threaded tk not being shared
Hi,
Wonder can someone help. I've been trying a few things with perl/tk and
threads with some success but cant understand a particular problem.
I've read various posts on the subject and have altered my script
accordingly but still no go! Basically the script creates some shared
variables, a sleeping thread first, then the tk window and widgets.
The thread essentially starts to update a shared variable every second
once the start button is pressed. I can see this by printing to STDOUT.
A label in the GUI points to this shared variable and is instructed to
update it.
However if i put in some debug print statements i can see that in
effect this variable is not shared as it retains the initial value only
hence the label may be updated but with the same value.
Here is the code:
use Tk;
use threads;
use threads::shared;
use strict;
my $go : shared = 0;
my $myValue : shared = 0;
my $anotherThread = threads->new(\&ticker);
sub ticker {
while (1) {
if ($go == 0) {sleep 1;}
else {
$myValue++;
print "$myValue\n";
sleep 1;
}
}
}
my $mw = MainWindow->new();
$mw->title('UDP Sniffer');
my $f1 = $mw->Frame(-borderwidth => 2, -relief => 'groove')->pack(-side
=> 'top', -fill => 'x');
my $label2 = $f1->Label(-textvariable => \$myValue, -width =>
15)->pack(-side => 'left');
$f1->Button(-text => 'Start', -command => \&start)->pack(-side =>
'left');
$f1->Button(-text => 'Stop', -command => \&stop)->pack(-side =>
'left');
$f1->Button(-text => 'Reset', -command => \&resetme)->pack(-side =>
'left');
MainLoop();
sub start {
$go = 1;
print "In the main window - $myValue\n";
##$mw->repeat(1, sub {$mw->update;});
}
sub stop {
$go = 0;
}
sub resetme {
$myValue = 0;
}
Threads are quickly becoming annoying to use as it seems they present
more problems than solutions with tk so could someone tell me what
other options i have for something similar to the above?
Thanks in advance
5.how to share variable across multi-processes
On 1/30/06, Jeff Pang < XXXX@XXXXX.COM > wrote:
> hello,lists,
>
> I have a hash var in my script,and I want to get it be shared across multi-processes.Fox example:
>
> my %hash;
>
> while(1)
> {
> die "can't fork:$!" unless defined (my $child = fork());
>
> if ($child==0)
> {
> do_something_to_hash(); # here I need to do some operations to the %hash,which is defined globally.These operations include add something to %hash,or do modification or 'delete' to %hash.
> }
> }
>
> Is there any suggestion or document can help me to do that?thanks.
snip
You might consider using a dbm to store the hash in the file system.
Look at dbmopen and DBM::Any.
6. mod_perl: sharing data across httpd childs ?
7. sharing a variable across two scripts.
8. Sharing variables across scripts.