- 博客(12)
- 收藏
- 关注
原创 duilib 消息循环机制
1 消息处理 在duilib中我们一般会创建一个继承WindowImplBase的窗口,然后重写Notify函数,在Notify函数中处理控件消息,比如button的消息类型就是click,代码如下所示:class MyWnd :public DuiLib::WindowImplBase{ ... virtual void Notify(DuiLib::TNotifyUI& msg) override;};void MyWnd::Notify(DuiLib::TNotif
2022-05-25 16:32:38
772
原创 leveldb之block
BlockBuilderblock的数据是通过BlockBuilder实现定义restarts_表示重启点,主要用来保护数据损坏。class BlockBuilder {public: explicit BlockBuilder(const Options* options); BlockBuilder(const BlockBuilder&) = delete; BlockBuilder& operator=(const BlockBuilder&
2022-04-25 17:43:40
190
原创 leveldb之arena
定义class Arena { public: Arena(); Arena(const Arena&) = delete; Arena& operator=(const Arena&) = delete; ~Arena(); // Return a pointer to a newly allocated memory block of "bytes" bytes. char* Allocate(size_t byte
2022-04-21 10:26:31
178
原创 leveldb之Reader 写日志
leveldb之Reader 写日志总体的流程就是先读块,然后再从块中读记录。定义主要对外接口就ReadRecord,读取记录。namespace log {class Reader { public: // Interface for reporting errors. class Reporter { public: virtual ~Reporter(); // Some corruption was detected. "bytes" is the a
2022-04-18 17:18:49
283
原创 信号导致localtime_r死锁
1 现象服务器上发现有两个服务同时在跑,且子进程处理Sleep状态,查看sleep进程堆栈如下#0 0x00007f47d6b8065c in __lll_lock_wait_private () from /lib64/libc.so.6#1 0x00007f47d6b2acac in _L_lock_2546 () from /lib64/libc.so.6#2 0x00007f47d6b2aae7 in __tz_convert () from /lib64/libc.so.6....
2022-04-18 14:22:07
1394
原创 leveldb之log_write
leveldb之log_write路径:/leveldb/log_writer.hleveldb在修改数据时会先写入日志,然后再更新内存memtable。这样保证了内存数据丢失时可以恢复。log数据格式log格式在官方文档中定义,详细的可以看官方链接:block := record* trailer?record := checksum: uint32 // crc32c of type and data[] ; little-endian length: uint16
2022-04-07 21:23:58
396
原创 leveldb之memtable
Varint先粗糙的说下MemTable中的varint压缩算法,后面挑个时间专门看下。算法是独立的,所以可以把函数单独拎出来跑下,这样理解起来很快。编码长度int VarintLength(uint64_t v) { int len = 1; while (v >= 128) { v >>= 7; len++; } return len;}根据v的二进制长度进行判断,64位最大编码长度为10,可以用std::numeric_limits<
2022-04-01 19:15:35
244
原创 leveldb之SkipList
关于跳跃表的理论知识可以查看:跳跃表的理论Node路径:leveldb/db/skiplist.h定义和实现比较简单,就不再阐述了关于内存模型memory_order可以查看:内存模型template <typename Key, class Comparator>struct SkipList<Key, Comparator>::Node { explicit Node(const Key& k) : key(k) {} Key const key;
2022-03-28 15:00:21
908
原创 2021-09-13 多屏下获取各个屏幕快照
一、整体思路1.通过EnumDisplayMonitors枚举所有显示器,GetMonitorInfo和EnumDisplaySettings获取详细信息2.将上面信息放入GDI api进行抓屏3.转换成bmp文件二、代码#include <stdio.h>#include <Windows.h>#include <tchar.h>#include <fstream>#include <vector>#include <s
2021-09-13 19:50:16
417
原创 windows vs2017编译cef3
Windows编译Cef31. 下载源码下载地址:https://cef-builds.spotifycdn.com/index.html输入网址后进入到下面界面,选择win64,下载2. 创建sln工程文件下载完成后,解压文件,会发现有个CMakeLists.txt,采用CMake-gui编译,当然你也可以直接输指令输入源码地址和编译地址后,点击Configure,我这里选择的是vs2017 x64,点击finsh然后再点击Generate即可创建工程3.编译duild目录下有
2021-08-19 11:37:13
560
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人