View Single Post
  #2 (permalink)  
Old 05-30-2003
bernard's Avatar
bernard bernard is online now
ZeroC Staff
 
Name: Bernard Normier
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Palm Beach Gardens, FL
Posts: 834
Hi Craig,

This code should use a conditional for each platform: pthread_t is an opaque type, and any "automatic" convertion to an integer is somewhat dangerous, as it could yield the same id for different threads on some platform.

On FreeBSD since pthread_t is a pointer to a per-thread structure, you can safely use reinterpret_cast<unsigned long>(pthread_self()).

On Tru64, for example, the correct code would be pthread_getsequence_np(pthread_self()).

Cheers,
Bernard
Reply With Quote