コード例 #1
0
TYPE* VThreadVariable<TYPE>::CheckForAllocation () const
{
  // Retrieve a data pointer for the current thread
#ifdef _VISION_POSIX
  TYPE* lpvData = (TYPE*)pthread_getspecific(m_key);
#elif defined(_VISION_WIIU)
  TYPE* lpvData = (TYPE*)VWiiUTLSGet(m_uiTLSIndex);
#else
  TYPE* lpvData = (TYPE*)TlsGetValue(m_TLSindex); 
#endif
  // If NULL, allocate memory for the TLS slot for this thread
  if (lpvData == NULL)
  {
    lpvData = new TYPE; 
    if (lpvData == NULL)
      return NULL;
#ifdef _VISION_POSIX
    int result = pthread_setspecific(m_key, lpvData);
    if (result != 0)
      return NULL;
#elif defined(_VISION_WIIU)
    VWiiUTLSSet(m_uiTLSIndex, lpvData);
#else
    if (!TlsSetValue(m_TLSindex, lpvData))
      return NULL;
#endif

    // Set the initialisation value (not a 'criticalsection locked' action) 
    *lpvData = m_default_value;
  }

  return lpvData;
}
コード例 #2
0
void VThreadVariable<TYPE>::FreeThreadData ()
{
  // Retrieve a data pointer for the current thread
#ifdef _VISION_POSIX
  TYPE* lpvData = (TYPE*)pthread_getspecific(m_key);
#elif defined(_VISION_WIIU)
  TYPE* lpvData = (TYPE*)VWiiUTLSGet(m_uiTLSIndex);
#else
  TYPE* lpvData = (TYPE*)TlsGetValue(m_TLSindex); 
#endif

  // If NULL, allocate memory for the TLS slot for this thread
  if (lpvData)
  {
    delete lpvData; 
    lpvData = NULL;
#ifdef _VISION_POSIX
    pthread_setspecific(m_key, lpvData);
#elif defined(_VISION_WIIU)
    VWiiUTLSSet(m_uiTLSIndex, NULL);
#else
    TlsSetValue(m_TLSindex, lpvData);
#endif
  }
}
コード例 #3
0
TYPE* VThreadVariable<TYPE>::CheckForAllocation () const
{
  // Retrieve a data pointer for the current thread
#ifdef _VISION_POSIX
  TYPE* lpvData = (TYPE*)pthread_getspecific(m_key);
#elif defined(_VISION_WIIU)
  TYPE* lpvData = (TYPE*)VWiiUTLSGet(m_uiTLSIndex);
#else
  TYPE* lpvData = (TYPE*)TlsGetValue(m_TLSindex); 
#endif
  // If NULL, allocate memory for the TLS slot for this thread
  if (lpvData == NULL)
  {
    lpvData = new TYPE; 
    if (lpvData == NULL)
      return NULL;
#ifdef _VISION_POSIX
    int result = pthread_setspecific(m_key, lpvData);
    if (result != 0)
      return NULL;
#elif defined(_VISION_WIIU)
    VWiiUTLSSet(m_uiTLSIndex, lpvData);
#else

#pragma warning(push)
#pragma warning(disable : 6001) // Using uninitialized data (TlsGetValue apparently triggers the static code analysis here, but our code does everything right much earlier)
    if (!TlsSetValue(m_TLSindex, lpvData))
      return NULL;
#pragma warning(pop)
#endif

    // Set the initialisation value (not a 'criticalsection locked' action) 
    *lpvData = m_default_value;
  }

  return lpvData;
}
コード例 #4
0
 inline TYPE* TGetValue()             { return (TYPE*)VWiiUTLSGet(m_uiTLSIndex); }