在C / C ++产生一个线程跨平台的方式? [英] Cross-platform way of yielding a thread in C/C++?

查看:94
本文介绍了在C / C ++产生一个线程跨平台的方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C和C ++有没有产生一个线程的一个跨平台的方式?
喜欢的东西SCHED_YIELD()或休眠(0)?
是否SDL_Delay(0)总是产生,还是会在一些实现立即返回?

In C and C++ is there a cross-platform way of yielding a thread? Something like sched_yield() or Sleep(0)? Does SDL_Delay(0) always yield or will it return immediately in some implementations?

推荐答案

鉴于无论C和C ++有线程,没有完全跨平台的方式一个线程产生。

Given that neither C nor C++ has "threads," there is no fully cross-platform way for a thread to yield.

C ++ 0x中,有一个函数的std :: this_thread ::收益率()可称为屈服。这将是一个线程来产生可移植的方法,一旦人们开始使用的C ++ 0x线程库。

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

这篇关于在C / C ++产生一个线程跨平台的方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆