11 2023 档案

摘要:1、数组操作 #include <iostream> #include <winsock2.h> #include <windows.h> #include <xmlrpc-c/base.hpp> #include <xmlrpc-c/registry.hpp> #include <xmlrpc-c 阅读全文
posted @ 2023-11-30 17:16 左边的翼 阅读(32) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <winsock2.h> #include <windows.h> #include <xmlrpc-c/base.hpp> #include <xmlrpc-c/registry.hpp> #include <xmlrpc-c/server 阅读全文
posted @ 2023-11-30 15:37 左边的翼 阅读(36) 评论(0) 推荐(0) 编辑
摘要:形参类型的定义略 The string looks something like this example: i:iii,s: . It is a list of signature strings, separated by commas. In the example, there are tw 阅读全文
posted @ 2023-11-30 10:45 左边的翼 阅读(9) 评论(0) 推荐(0) 编辑
摘要:std::packaged_task是C++11引入的标准库类,用于封装可调用对象,如函数等,并将封装对象作为异步任务进行管理,通过与std::future结合使用,完成异步任务结果的获取。 #include <iostream> #include <thread> #include <future 阅读全文
posted @ 2023-11-28 09:54 左边的翼 阅读(293) 评论(0) 推荐(0) 编辑
摘要:std::shared_future是C++11的标准库类,其与std::future的不同是允许多个线程使用,多个线程可以同步共享,同时其又不会阻塞等待异步任务的完成。std::shared_future同样也提供get()方法用于获取异步执行的结果。 #include <iostream> #i 阅读全文
posted @ 2023-11-27 17:21 左边的翼 阅读(348) 评论(0) 推荐(0) 编辑
摘要:1、std::async std::async是C++11的标准库函数,用于创建执行异步任务并返回std::future对象来获取异步执行的结果状态。该函数最简单的用法如下所示: #include <iostream> #include <thread> #include <future> std: 阅读全文
posted @ 2023-11-27 14:43 左边的翼 阅读(448) 评论(0) 推荐(0) 编辑
摘要:1、std::promise与std::future std::promise与std::future通过配合使用完成数据的同步与共享,两者均是模板类;std::promise存储异步执行的值或异常;std::future提供可供访问的异步执行结果。二者配合使用伪码如下: std::promise< 阅读全文
posted @ 2023-11-27 13:48 左边的翼 阅读(117) 评论(0) 推荐(0) 编辑
摘要:1、std::join std::join是std::thread类的成员函数之一,用于等待线程的执行完成。 #include <iostream> #include <utility> #include <thread> #include <chrono> #include <atomic> vo 阅读全文
posted @ 2023-11-24 15:11 左边的翼 阅读(652) 评论(0) 推荐(0) 编辑
摘要:1、std::function std::function是一个模板类,其可对C++可调用的对象进行封装,比如,成员函数、静态函数等;它的基本作用是简化调用的复杂程度,归一化调用方式。 std::function<int(int, int)> int_function:声明方式为<返回值类型(参数类 阅读全文
posted @ 2023-11-24 10:24 左边的翼 阅读(988) 评论(0) 推荐(0) 编辑
摘要:1、类静态成员函数作为回调函数 1)类定义 CommonFunctions.h class CommonFunctions { public: CommonFunctions(); static int add_test(int a, int b); }; CommonFunctions.cpp # 阅读全文
posted @ 2023-11-23 16:19 左边的翼 阅读(299) 评论(0) 推荐(0) 编辑
摘要:1、定义 1)声明函数指针类型 typedef int(*CallBackFunction)(int a, int b); 2)定义函数指针对象 CallBackFunction CallBackFunction_PTR; 3)初始化函数指针对象 void set_call_back(CallBac 阅读全文
posted @ 2023-11-23 15:09 左边的翼 阅读(15) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示