我必须编写一个执行高度计算密集型计算的程序.该程序可能会运行几天.可以在不同的线程中轻松分离计算,而无需共享数据.我想要一个GUI或一个Web服务,告诉我当前的状态.
我目前的设计使用BOOST :: signals2和BOOST :: thread.它编译并到目前为止按预期工作.如果一个线程完成一次迭代并且有新数据可用,则它会调用一个连接到GUI类中的插槽的信号.
我的问题:
以下代码编译
g++ -Wall -o main -lboost_thread-mt <filename>.cpp
Run Code Online (Sandbox Code Playgroud)
代码如下:
#include <boost/signals2.hpp>
#include <boost/thread.hpp>
#include <boost/bind.hpp>
#include <iostream>
#include <iterator>
#include <string>
using std::cout;
using std::cerr;
using std::string;
/**
* Called when a CalcThread finished a new bunch of data.
*/
boost::signals2::signal<void(string)> signal_new_data;
/**
* The whole data will be stored here.
*/
class DataCollector
{
typedef boost::mutex::scoped_lock scoped_lock;
boost::mutex mutex;
public:
/**
* Called by CalcThreads call the …Run Code Online (Sandbox Code Playgroud)