C++ Poco - 如何创建通知队列的向量?
C++ Poco - How to create a vector of NotificationQueue's?
我想创建一个通知中心,在那里我处理所有notifications
threads
。
我无法在软件启动时知道我需要多少notification
队列。在run-time
期间可能会有所不同。
所以我创建了这个(代码简化(:
#include <vector>
#include "Poco/Notification.h"
#include "Poco/NotificationQueue.h"
using Poco::Notification;
using Poco::NotificationQueue;
int main()
{
std::vector<NotificationQueue> notificationCenter;
NotificationQueue q1;
NotificationQueue q2;
notificationCenter.push_back(q1); //ERROR: error: use of deleted function ‘Poco::NotificationQueue::NotificationQueue(const Poco::NotificationQueue&)’
notificationCenter.push_back(q2);
return 0;
}
我得到了error: use of deleted function ‘Poco::NotificationQueue::NotificationQueue(const Poco::NotificationQueue&)’
我明白。我无法复制或分配NotificationQueue
.
问题:
有什么方法可以在不静态创建NotificationQueue
向量的情况下处理它们?
@arynaq
评论中,指针向量将使工作:
#include <memory>
#include <vector>
#include "Poco/Notification.h"
#include "Poco/NotificationQueue.h"
using Poco::Notification;
using Poco::NotificationQueue;
int main()
{
std::vector<std::shared_ptr<NotificationQueue>> notificationCenter;
std::shared_ptr<NotificationQueue> q1 = std::make_shared<NotificationQueue>();
std::shared_ptr<NotificationQueue> q2 = std::make_shared<NotificationQueue>();
notificationCenter.push_back(q1);
notificationCenter.push_back(q2);
return 0;
}
相关文章:
- boost::进程间消息队列引发错误
- 如果我只是不访问queue_front节点的子节点,而是将它们推到队列中呢?还是BFS吗
- Android NDK传感器向事件队列报告奇怪的间隔
- C++优先级队列,按对象的唯一指针的特定方法升序排列
- 按对象的特定方法按升序排列的C++优先级队列
- 使用2个键的cpp-stl::优先级队列排序不正确
- 我是否需要在下一次转移时将所有权*转移回转移队列
- 在一个读写器队列中,我可以用volatile替换原子吗
- 为什么我的多线程作业队列崩溃
- 尝试将lambda函数放在队列中时出现一般分配器错误(可能是与unique_ptr有关的错误)
- 使用"Task"函数指针队列定义作业管理器
- 在c++队列中使用pop和visit实现线程安全
- 为什么我需要C++中不同的排序格式来对这个USACO代码上的数组和优先级队列进行排序
- 打印优先级队列
- 函数如何通知用户它基于函数原型抛出异常?
- 共享队列的线程安全
- 带自定义比较器的最小优先级队列
- C++ Poco - 如何创建通知队列的向量?
- 视觉提升 条件变量中的同步队列C++不通知其他线程上的等待类方法
- 公平队列丢失通知