English 中文(简体)
模拟Glib:Dispatcher 是否有一些促进功能?
原标题:Is there some Boost functionality for simulating a Glib::Dispatcher?

我目前正在重新构思一个中等软件工程。 它包含一个由多个线条使用的类似核心内核的类。 目前, 此类使用 < code> Glib:: Dispatcher 来处理由多个线条释放的信号。 由于重构程序的一个目标是完全清除 < code> glibmm (因为 < code@ t 应用作新框架), 我正尝试用 < code> Boost 来找出如何“ 模拟” 调度器功能的方法。 我已经查看了 < code> Boost. Signals 和 < code> Boost.Signals2 , 但这两个图书馆似乎都没有为调度器提供替代方案。

为澄清调度员应做什么,请从中的“不跟随”:

Glib::Dispatcher works similar to sigc::signal. But unlike normal signals, the notification happens asynchronously through a pipe. This is a simple and efficient way of communicating between threads, and especially useful in a thread model with a single GUI thread.

No mutex locking is involved, apart from the operating system s internal I/O locking. That implies some usage rules:

  • Only one thread may connect to the signal and receive notification, but multiple senders are allowed even without locking.
  • The GLib main loop must run in the receiving thread (this will be the GUI thread usually).
  • The Dispatcher object must be instantiated by the receiver thread.
  • The Dispatcher object should be instantiated before creating any of the sender threads, if you want to avoid extra locking.
  • The Dispatcher object must be deleted by the receiver thread.
  • All Dispatcher objects instantiated by the same receiver thread must use the same main context.

您能否给我一些正确方向的指针? 这是使用 Boost.Signals boost.Signals2 实现的功能吗?

编辑: 正如一位评论家正确指出的, 使用 < codet 也许是个选项。 但是, 我所重订的类别非常低, 我不想添加此额外依赖性 。

最佳回答

我现在选择了该类的全部重写。 结果,我确实“ 强” 不 Glib 提供的方式。 相反, 只需使用普通的 < code > boost: signals2 信号, 加上来自 < empact < /em > 图形互动的 < code > 的信号。

问题回答




相关问题
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?

热门标签