Sponsored Content
Full Discussion: Thread Safe and Rentrancy
Top Forums Programming Thread Safe and Rentrancy Post 302722149 by expl on Friday 26th of October 2012 11:43:47 AM
Old 10-26-2012
Quote:
Originally Posted by rupeshkp728
But will anybody explain with example how can a threadsafe function be always reentrant?
Emm, don't think there is need for example. Thread safe function means it can be ran safely in same context by many threads so logically thinking its automatically safe to rerun many times this function in a single thread as well...

Function can not be thread safe if its not reentrant.
This User Gave Thanks to expl For This Post:
 

We Also Found This Discussion For You

1. Programming

compiling thread safe c on aix

Hi, I'm trying to compile a Perl module for AIX 5.3. Now, Perl by default wants to use cc_r as compiler but I only have gcc installed on this system. How can I get gcc to be thread safe? Or can I use gcc without any options and expect it to behave the same as cc_r? (0 Replies)
Discussion started by: rein
0 Replies
Thread::Queue(3pm)					 Perl Programmers Reference Guide					Thread::Queue(3pm)

NAME
Thread::Queue - thread-safe queues SYNOPSIS
use Thread::Queue; my $q = new Thread::Queue; $q->enqueue("foo", "bar"); my $foo = $q->dequeue; # The "bar" is still in the queue. my $foo = $q->dequeue_nb; # returns "bar", or undef if the queue was empty my $left = $q->pending; # returns the number of items still in the queue DESCRIPTION
A queue, as implemented by "Thread::Queue" is a thread-safe data structure much like a list. Any number of threads can safely add elements to the end of the list, or remove elements from the head of the list. (Queues don't permit adding or removing elements from the middle of the list). FUNCTIONS AND METHODS
new The "new" function creates a new empty queue. enqueue LIST The "enqueue" method adds a list of scalars on to the end of the queue. The queue will grow as needed to accommodate the list. dequeue The "dequeue" method removes a scalar from the head of the queue and returns it. If the queue is currently empty, "dequeue" will block the thread until another thread "enqueue"s a scalar. dequeue_nb The "dequeue_nb" method, like the "dequeue" method, removes a scalar from the head of the queue and returns it. Unlike "dequeue", though, "dequeue_nb" won't block if the queue is empty, instead returning "undef". pending The "pending" method returns the number of items still in the queue. SEE ALSO
threads, threads::shared perl v5.8.0 2002-06-01 Thread::Queue(3pm)
All times are GMT -4. The time now is 08:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy