Boost logo

Boost :

From: Martin Wille (mw8329_at_[hidden])
Date: 2003-11-18 07:34:09


Hi,

while implementing the alternative_thread_specific_ptr I stumbled
across this:

// in file tss.hpp:
class tss
{
     bool set(void *);
};

template <typename T>
class thread_specific_ptr
{
    void reset(T* p=0)
     {
         T* cur = get();
         if (cur == p) return;
         delete cur;
         m_tss.set(p);
     }
};

// in file tss.cpp (POSIX branch):
bool tss::set(void* value)
{
     return pthread_setspecific(m_key, value) == 0;
}

and in the POSIX standard:

  No errors are returned from pthread_getspecific().

  The pthread_setspecific() function shall fail if:
  [ENOMEM]
    Insufficient memory exists to associate the value with the key.

It seems to me that the result of m_tss.set() should
be checked and an exception should be thrown in case
of a failure.

Regards,
m


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