I will listen on a port (simple server) when a request is passed parse the URL and start a thread.
The thread will insert an element in a queue which is shared, and it is locked while inserting.
I am not able to get element when I call peek on queue.
use Thread qw(async);
use Thread::Queue;
my $DataQueue:shared = new Thread::Queue;
$newElement = init($user,$param,$reqest); # init is method in ElementStructure.pm
#after creating the element it is passes to subroutine where thread is started
sub updateData
{
my $iElement=shift;
$thr = async
{
{
lock($DQueue);
print "---->locked\n";
$DQueue->enqueue($iElement);
insertdata();
}
print "lock released\n";
};
}
sub insertdata
{
my $count=0;
while ($DataElement = $DQueue->peek($count) )
{
print "-- position $count\n";
$count++;
}
}