c ++多线程任务队列用于计划任务 [英] c++ multithreaded task queue for scheduled tasks

查看:59
本文介绍了c ++多线程任务队列用于计划任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要开发一个模块来执行计划任务.
每个任务都被安排在 X 毫秒内执行.

I need to develop a module which will execute scheduled tasks.
Each task is scheduled to be executed within X milliseconds.

该模块将执行任务的工作线程数量作为参数.

The module takes as a parameter an amount of worker threads to execute the tasks.

任务被堆积在一个队列中,该队列可能是一个优先级队列,因此线程会检查队列中的下一个任务(具有最低赎回"时间的任务),因此无需迭代每次都完成所有任务.

The tasks are piled up in a queue which will probably be a priority queue, so a thread checks for the next-in-queue task (the one with the lowest "redemption" time), thus there's no need to iterate through all tasks each time.

是否有任何公共图书馆可以这样做,或者我应该自己动手?

Is there any public library that does that or shall I roll my own?

注意:我在 Windows 上使用 VC2008.

Note: I'm using VC2008 on Windows.

推荐答案

如果你不介意 Boost 依赖,threadpool 可能适合您的需求.

If you don't mind a Boost dependency, threadpool might fit your needs.

这篇关于c ++多线程任务队列用于计划任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆