Thread: [pthread] cancellable sleep in win32?

  1. #1
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229

    [pthread] cancellable sleep in win32?

    Hi,
    Is there a pthread-cancellable sleep function in win32 like sleep() and usleep() on Linux? The Sleep() in Windows API is apparently not cancellable. I am using pthreads-win32 (http://sourceware.org/pthreads-win32/) and it doesn't seem to define any "sleep" function. I want my program to be cross-platform (developing it under Linux), but don't mind a bit of conditional compilation.

    Thank you very much

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Look up SleepEx() in the win32 API. That will probably give you a starting point for what you seek.

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    Thank you for your suggestion

    I looked up SleepEx() on MSDN (http://msdn2.microsoft.com/en-us/library/ms686307.aspx). According to that page, it is stated that one of the conditions that will make the function return is "An asynchronous procedure call (APC) is queued to the thread," which, I assume, is what I am looking for. However, as I am using pthread and not win32 native threads, does it work in this case? (I currently do not have access to a Windows machine to test it out)

    Your help is much appreciated.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sleep works with just one thread, but not 2
    By finkus in forum C++ Programming
    Replies: 5
    Last Post: 12-01-2005, 09:17 PM
  2. Win32 API or Win32 SDK?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 07-20-2005, 03:26 PM
  3. Problem with Sleep() #$@^#$%^
    By intruder in forum C++ Programming
    Replies: 8
    Last Post: 10-11-2004, 06:46 AM
  4. Sleep is overrated...
    By Polymorphic OOP in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 01-24-2003, 12:40 PM
  5. OLE Clipboard :: Win32 API vs. MFC
    By kuphryn in forum Windows Programming
    Replies: 3
    Last Post: 08-11-2002, 05:57 PM