codinghanya / workspace Goto Github PK
View Code? Open in Web Editor NEWworkspace是基于C++11的轻量级异步执行框架,支持:通用任务异步并发执行、优先级任务调度、自适应动态线程池、高效静态线程池、异常处理机制等。
License: Apache License 2.0
workspace是基于C++11的轻量级异步执行框架,支持:通用任务异步并发执行、优先级任务调度、自适应动态线程池、高效静态线程池、异常处理机制等。
License: Apache License 2.0
您好,我看到你的benchmark中提到了加速比,我主要是没感觉到这个指标的意义是在哪呢?
单线程4个task,200s
然后线程池4个task50s,这是很正常的。。
但是当任务达到8、16的时候,总耗时为啥会减少呢?我没有想到原因,能否解释一下啊
大佬我之前写过一个类似于ros的platform, 但感觉太糙了, 能给提点意见吗?
https://github.com/peitianyu/tt_3d_slam , 编译的话直接在lv_platform里边编译测试i就行, 可能需要安装一下eigen与lv_math
./${test_file_name}
let tmp1--
if [ $? -eq 0 ]
then
let success++
fi
$? 返回的应该是let tmp1--的状态码
workbranch br(2);
auto result = br.submit([](){
return xx;
});
if(result.wait_for(xx) == std::future::time_out){
// 请问一下 如过超时,如何杀掉执行当前超时任务的线程。
}else{
result.get();
}
请问一下 如过超时,如何杀掉执行当前超时任务的线程。
我的编译器是msvc,使用cmake链接你所有头文件重新编译,其中发现了一些问题,其中uint数据类型会报错,size_t数据转换会出现警告;我想说一下,这些数据类型可以换成基本数据类型。
假设原来有类似这样一个会产生很高递归栈的函数:
int fib(int n) {
if (n <= 1) {
return 1;
}
return fib(n-1) + fib(n-2);
}
把它改写用threadpool后,有类似这样的:
int fib(int n) {
if (n <= 1) {
return 1;
}
int a = pool.submit(fib(n-1));
int b = pool.submit(fib(n-2));
return a + b;
}
但是我有一个困惑是, 在计算fib(n-1)和fib(n-2)时 原来的fib(n)还是挂在线程池里的某一个worker身上没法被销毁, 也不能被销毁. 这样的话递归不了几层, 所有的线程worker都卡住了.
当然如果超出了现有的线程数量可以去新开数量, 但是面对高递归任务时, 开出来大几百个线程worker会很快使得系统性能下降.
请问有什么能保存当前的context但是又不卡住一个线程资源的使用方法吗
编译时打开clang-tidy和-fsanitize=检测选项
安装库到系统路径,用户可以直接include
整合doxygen,自动生成文档,打包和安装文档,之后用户可以通过man命令查看这个库的文档
您好,追随您在b站的视频找到这里。
想咨询一下,是否有测试结果,来对比使用 a batch of 的方式,将 task 从写入队列,转移到执行队列中,
比直接写入一个线程安全的队列,然后消费的效果会好。
如果好的话,会好多少?
类似于
class scoped_thread
{
private:
thread thread_;
public:
template <typename... Arg>
scoped_thread(Arg&&... arg)
: thread_(std::forward<Arg>(arg)...)
{}
scoped_thread(scoped_thread&& other)
: thread_(std::move(other.thread_))
{}
scoped_thread(const scoped_thread&) = delete;
~scoped_thread()
{
if (thread_.joinable())
{
thread_.join();
}
}
};
把workspace提交到xmake-repo了
xmake-io/xmake-repo#2104
future/promise的异步实现:
when_all/when_any/then
是否支持?
如题,我在submit的时候在里面起了个进程,结果关不掉了
有解么
在include/workspace/workbranch.h:232里:
while (true) {
if (decline <= 0 && tq.try_pop(task)) { // 访问decline但是没有锁
decline应该是待删除的线程数吧,这里读它不用加锁吗,是为什么?
代码中有多处在使用条件变量的 .notify_all()
或 .notify_one()
前用了锁保护. 但是根据:
来看, 似乎不需要加锁?
在代码中的位置:
如果能执行到worker中的 if (enable_steal_tasks) 的代码块,意味着waiting=false,但这又意味着全部任务执行完了,这个时候从其他线程的工作队列拿任务的意义何在?不是全部任务已经没了吗?求懂哥解释
用户的业务逻辑代码可能是千奇百怪、十分复杂的。有可能出现以下两种情况:
两个外部线程调用同一个线程池的waitForTasks()函数,此时会造成数据竞争,程序崩溃。
用户业务逻辑复杂的时候,我认为有可能需要这种用法。
用户向线程池提交了一个函数,这个函数中又去调用线程池的waitForTasks(),此时程序会永远阻塞。
这种用法或许有点儿愚蠢,,但至少您应该在文档中写明waitForTasks()不能提交给线程池执行。
用户代码量大的时候可能难以发现这个错误。线程池应该能检测出这种错误并提示用户。
#include "../hipe.h"
using namespace hipe;
void multithread_wait_task()
{
DynamicThreadPond pond (8);
pond.submit([](){std::cout << "hello world!" << std::endl;});
std::thread trd { [&pond](){ pond.waitForTasks(); } };
pond.waitForTasks();
}
void poolthread_wait_task()
{
DynamicThreadPond pond (8);
pond.submit([&pond](){pond.waitForTasks(); });
pond.waitForTasks();
}
int main()
{
multithread_wait_task();
poolthread_wait_task();
}
线程池支持自动扩容和收缩吗?
设置一个最小线程数量和最大线程数量,请求多的时候自动扩容(但小于最大线程数量),请求少的时候可以释放掉多余资源(但不能过度优化,至少保留最少线程数量)
不知道这个框架支不支持扩展这个功能?
在 C++14 中,命名空间的嵌套声明需要使用单独的语句,而不能像您提供的头文件中那样直接进行嵌套声明。
即需:
namespace wsp::details {
xxx
}
---更改为---
namespace wsp{
namespace details {
xxx
}
}
请问一下,这个仓库为什么要从hipe重构为workspace,以前的是有什么问题,现在的有什么优势吗?谢谢
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.