pthread_cancel行为不同于手臂和ppc?
题
我目前正在多线程的应用程序,将部署在手臂和ppc架构。我有一些问题pthread_cancel上臂。
pthread_cancel上臂不行为相同的与ppc。该线被取消,但析构的线的地方变量不是所谓的上臂。我还试图明确界定一个取消的清理程序通过安装pthread_cleanup_push.但它不是被称为时,线被取消。
代码作品的现有ppc。当一个线程被取消,当地的变量析构正在呼吁。当我明确定义的一个清理的处理程序,它被称为及时执行pthread_cancel被称为。
我失去了一些东西?一些编译器的选择也许?
- 编程语言:C++
- 编译器:手臂-linux-g++/支持-linux-g++
- 操作系统:Linux
编辑:
我已经找到一种类似的问题记录在此 libc错误.
使用的海湾合作委员会,而不是g++和加fno-异常编译器的选择做的伎俩。但是我真的想要了解的东西在后面这个问题。此外,-fno-异常意味着我不能够执行例外处理在我的应用程序,不,我现在使用它,但我可能会在未来。
谢谢。
解决方案
线的取消没有帮助从应用程序是一个糟糕的想法。只是 谷歌.最好是告诉线程的结束本身通过设置标志变量的定期检查螺纹。
实际上是取消所以难,它已经略去了最新C++0x草案。你可以搜索 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html 并不会找到任何提及取消。这里的定义的拟议线类(你不会找到取消有):
class thread
{
public:
// types:
class id;
typedef implementation-defined native_handle_type; // See [thread.native]
// construct/copy/destroy:
thread();
template <class F> explicit thread(F f);
template <class F, class ...Args> thread(F&& f, Args&&... args);
~thread();
thread(const thread&) = delete;
thread(thread&&);
thread& operator=(const thread&) = delete;
thread& operator=(thread&&);
// members:
void swap(thread&&);
bool joinable() const;
void join();
void detach();
id get_id() const;
native_handle_type native_handle(); // See [thread.native]
// static members:
static unsigned hardware_concurrency();
};
不隶属于 StackOverflow