Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-09-25 09:41:38


From: "Alexander Terekhov" <terekhov_at_[hidden]>
> > Actually, fixing the limited number of "native" TSD slots isn't so
> > easy. The only way to actually fix it would mean that set_specific()
> > could fail with an out of memory error, which is problematic and
> > quite different from expected gaurantees of TSD implementations.
>
> Pg. 1554/System Interfaces Technical Standard (2001)
> (Draft June 14, 2001):
>
> "33564 NAME
> 33565 pthread_getspecific, pthread_setspecific
> - thread-specific data management
> .....
> 33593 ERRORS
> 33594 No errors are returned from pthread_getspecific().
> 33595 The pthread_setspecific() function **shall fail** if:
> 33596 [*ENOMEM*] **Insufficient memory exists to associate
> the value with the key**."

This aside, how can possibly the 'virtual' setspecific fail?

(pseudocode)

typedef std::deque<std::pair<void*, void (*) (void*)> > tsd_type;

typedef tsd_type::size_type pthread_key_t;

<thread-specific> tsd_type tsd;

int pthread_setspecific(pthread_key_t key, void * value)
{
    tsd[key].first = value;
    return 0;
}

--
Peter Dimov
Multi Media Ltd.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk