English 中文(简体)
在返回之前,日程安排人能否打断路面?
原标题:Can a thread be interrupted by the scheduler just before it returns?

作为生产者、消费者,我有两条read。 在生产者读物时,我先穿以下代码:

{
    mediaQueue->PushEvent( boost::bind(/* params are not important */) );

    return 0;
}

媒体 询问是一个信息点,而PushEvent()称呼一个透镜,即有工作有待处理。 消费者的read子只是执行由捆绑产生的ctor子。

For me it s really important that the producer thread returns BEFORE the consumer thread executes the functor.

因此: 生产者在推动活动之后,是否有可能中断,但会返回?

我迄今为止的研究使我想到,是可能的,我应当执行锁定的,但你对此有何看法?

最佳回答

订票人可以在任何时候打断你的胎面。 它不了解或照料你在时间结束时所做的一切。 如果存在一种可能的种族条件,是,你必须花费时间和努力,实施正确的锁定。

就你而言,这非常容易。 仅等到被点名的物体从<代码>返回时。 PushEvent功能。

问题回答

是的,这是可能的。 校对时间可以大大缩短。

如果在声明<代码>return 0;执行时出现问题,那么它就象这样错了。 究竟是谁必须先执行?





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?