MAC OS X thread programming

Posted on

if the type is DEFERRED, you should call pthread_testcancel() in your thread function, so that the thread function will suspend at the line pthread_testcancel(), or if the other thread call pthread_cancel() will be useless.make sure the memories are freed. if the type is ASYNCHRONOUS, the thread function will be cancel when other thread calls pthread_cancel()

  • #define PTHREAD_CANCEL_ENABLE 0x01 /* Cancel takes place at next cancellation point */
  • #define PTHREAD_CANCEL_DISABLE 0x00 /* Cancel postponed */
  • #define PTHREAD_CANCEL_DEFERRED 0x02 /* Cancel waits until cancellation point */
  • #define PTHREAD_CANCEL_ASYNCHRONOUS 0x00 /* Cancel occurs immediately */

cancellaion point could be set by pthread_testcancel()
Reference :

廣告

One thought on “MAC OS X thread programming

    cotton5415 responded:
    十一月 7, 2006 at 10:07 上午

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

您的留言將使用 WordPress.com 帳號。 登出 / 變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 / 變更 )

Facebook照片

您的留言將使用 Facebook 帳號。 登出 / 變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 / 變更 )

連結到 %s