Cross-platform way to get a stream in C / C ++?

In C and C ++, is there a cross-platform way to get the stream? Something like sched_yield () or Sleep (0)? Is SDL_Delay (0) always or is it immediately returned in some implementations?

+6
c ++ c multithreading cross-platform sdl
source share
2 answers

Given that neither C nor C ++ (before C ++ 98) has β€œthreads”, there is no complete cross-platform way for a thread to be available.

In C ++ 0x, there is a function std::this_thread::yield() that can be called for output. This will be a portable way to get a thread as soon as people start using the C ++ 0x thread library.

+9
source share

in the case of C ++, boost::thread::yield() does what you ask. On platforms with posix threads, pthread_yield() performs the same function for C and everything related to it. On platforms where it does not immediately stop the thread and starts another, this is due to the fact that the scheduler does not support this functionality. I do not think that many such platforms really exist in the wild.

+4
source share

All Articles