我需要在Linux下为C++编写Hoard分配器。虽然算法非常简单,但我不明白在哪里(以及如何)存储分配器数据(例如堆)
我是这么看的:分配器不是一个进程,而是一组任何应用程序都可以使用的函数。每个应用程序都有自己的堆。
让我举个例子.
class B : public QThread {
public:
void run() {
}
};
class A : public QThread {
public:
void run() {
b1.start(); b2.start();
}
protected:
B b1, b2;
};
Run Code Online (Sandbox Code Playgroud)
我希望A :: b1和A :: b2作为完全独立的线程运行,而不是共享父线程(A)的资源.有没有办法将主线程指定为b1和b2的父线程?
我也看过QThreadPool和QRunnable,我不明白,怎样才能管理所有runnables(例如,停止其中一个,然后再次运行)threadpool.