Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualCornstalks

Posted 18 May 2013 - 09:39 AM

You can yield the thread's time slice. This will reduce CPU usage while still being higher "precision" than sleep(). There are several ways to do it:

 

C++11 threads: std::this_thread::yield()

C11 threads: thrd_yield()

Boost threads: boost::this_thread::yield()

Pthreads: pthread_yield()

Win32 threads: Sleep(0)

Java: Thread.yield()

C#: Thread.Yield()

 

If you're using another language, you'll have to look up how to do it in that language.


#2Cornstalks

Posted 18 May 2013 - 09:24 AM

You can yield the thread's time slice. This will reduce CPU usage while still being higher "precision" than sleep(). There are several ways to do it:

 

C++11 threads: std::this_thread::yield()

C11 threads: thrd_yield()

Boost threads: boost::this_thread::yield()

Pthreads: pthread_yield()

Win32 Threads: Sleep(0)

Java: Thread.yield()

 

If you're using another language, you'll have to look up how to do it in that language.


#1Cornstalks

Posted 18 May 2013 - 09:22 AM

You can yield the thread's time slice. This will reduce CPU usage while still being higher "precision" than sleep(). There are several ways to do it:

 

C++11 threads: std::this_thread::yield()

Boost threads: boost::this_thread::yield()

Pthreads: pthread_yield()

Win32 Threads: Sleep(0)


PARTNERS