摘要: 函数指针 函数返回值类型 (* 指针变量名) (参数列表) int (*p) (int, int) 指针函数 *类型标识符 函数名 (参数表) int *p (int, int) 区分方法 1. 函数名前面的指针*号有没有被括号()包含,如果被包含就是函数指针,反之则是指针函数。 2.()的优先级比 阅读全文
posted @ 2018-12-06 23:17 osbreak 阅读(333) 评论(0) 推荐(0)
摘要: 1.01 QObject:父子关系与内存自动管理 深刻理解 Qt 的父子对象内存管理机制。 当一个 QObject 被设置为另一个 QObject 的子对象时(通过构造函数或 setParent()),父对象会在析构时自动删除所有子对象。 这是避免内存泄漏的关键。 使用 deleteLater() 阅读全文
posted @ 2018-12-06 00:00 osbreak 阅读(1759) 评论(0) 推荐(0)
摘要: 1.01 高 DPI 缩放 在 main() 函数开头调用 // 确保应用在高分辨率屏幕上显示清晰。 QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_UseHighD 阅读全文
posted @ 2018-11-28 23:46 osbreak 阅读(250) 评论(0) 推荐(0)
摘要: // 1. 同步定时器 #include <cstdio> #include <iostream> #include <boost/asio.hpp> #include <boost/date_time/posix_time/posix_time.hpp> int main() { boost::a 阅读全文
posted @ 2018-11-27 22:11 osbreak 阅读(458) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <pthread.h> #include <arpa/inet.h> #include <liburing.h> #defi 阅读全文
posted @ 2018-11-19 23:19 osbreak 阅读(482) 评论(0) 推荐(0)
摘要: # 安装 liburing 开发库 sudo apt-get install liburing-dev # 或从源码编译安装:https://github.com/axboe/liburing io_uring 是 Linux 内核提供的一套 异步 I/O 框架,它通过 共享内存环形队列(ring 阅读全文
posted @ 2018-11-19 23:10 osbreak 阅读(265) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/socket.h> #include <sys/epoll.h> #include <netinet/in.h> 阅读全文
posted @ 2018-11-19 23:05 osbreak 阅读(301) 评论(0) 推荐(0)
摘要: epoll 是 Linux 内核为处理大批量文件描述符而作了改进的 poll,是 Linux 下多路复用 IO接口 select/poll 的增强版本. 在 linux 的网络编程中,很长时间都在使用 select 来做事件触发。在 2.6 内核中,有一种替换它的机制,就是 epoll。 selec 阅读全文
posted @ 2018-11-18 21:10 osbreak 阅读(620) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> 阅读全文
posted @ 2018-11-18 21:09 osbreak 阅读(200) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> 阅读全文
posted @ 2018-11-18 21:09 osbreak 阅读(175) 评论(0) 推荐(0)
摘要: 阻塞: 阻塞调用是指调用结果返回之前,当前线程会被挂起(线程进入非可执行状态,在这个状态下,cpu不会给线程分配时间片,即线程暂停运行)。 函数只有在得到结果之后才会返回。 非阻塞: 非阻塞和阻塞的概念相对应,指在不能立刻得到结果之前,该函数不会阻塞当前线程,而会立刻返回。 /** 参 数 :int 阅读全文
posted @ 2018-11-14 23:24 osbreak 阅读(1347) 评论(0) 推荐(0)
摘要: 下载库:http://sourceforge.net/projects/jsoncpp/files/ tar -zxvf jsoncpp-src-0.5.0 -C jsoncpp (1) 安装 scons $ sudo apt-get install scons (2) 切换到 jsoncpp 目录 阅读全文
posted @ 2018-11-08 14:40 osbreak 阅读(879) 评论(0) 推荐(0)
摘要: 定义业务类,继承 Thread类,实现run函数。可跨平台,调用start()即可 #pragma once #include <thread> #include <atomic> #include <functional> class Thread { private: std::thread _ 阅读全文
posted @ 2018-11-06 11:34 osbreak 阅读(184) 评论(0) 推荐(0)
摘要: 线程 1.01 创建Worker线程THREAD_PARAM void CDemoDlg::OnBeginThread() { m_ThreadParam.hWnd = m_hWnd; //启动线程,初始为挂起状态 AfxBeginThread(ThreadProc, &m_ThreadParam) 阅读全文
posted @ 2018-10-23 23:05 osbreak 阅读(247) 评论(0) 推荐(0)
摘要: #include "stdafx.h" #include <boost/multi_index_container.hpp> #include <boost/multi_index/ordered_index.hpp> #include <boost/multi_index/hashed_index 阅读全文
posted @ 2018-10-21 16:35 osbreak 阅读(1434) 评论(0) 推荐(0)