Live data from Hacker News

Mastering Threads on MacOS X

drdobbs.com

1–6 of 6 posts

Re: Mastering Threads on MacOS X

#3
This article is pretty terrifying:

      #import 
      #import 
      
      // Globals
      pthread_mutex_t *gLck;
      int gSum;

      int main (int argc, const char * argv[])
      {
          pthread_t *tFoo, *tBar;
          int tErr, tArgF, tArgB;
      
          // create the mutex construct
          tErr = pthread_mutex_init(gLck);

Re: Mastering Threads on MacOS X

#6

I recommend using boost.thread. It's cross-platform, and simpler than pthread.

I should mention that the current boost.thread (v.1.49.0) doesn't provide a simple way to change the priority or scheduling of a thread.

You have to do it thru the underlying system-specific handle obtained by boost::thread::native_handle().