每一天都是离别

人生弯弯曲曲水,世事重重叠叠山,名利坎坎坷坷路,情缘朝朝暮暮云

Mar 23rd
2023
c++20
coroutines

https://www.cursor.so
https://zhuanlan.zhihu.com/p/395250667
https://zhuanlan.zhihu.com/p/614523230
https://zhuanlan.zhihu.com/p/611081264
目前看到的比较好的两个系列的coroutine的文章,基本是零基础小白可以看的:
一、 这是一个系列

  1. the first overview
  2. more details
  3. an infinite data stream
  4. thread synchronization
  5. coroutines with cppcoro
  6. abstraction with cppcoro
  7. thread pools

二、 https://github.com/lewissbaker/cppcoro
看这个coroutine的STL辅助类实现,有很多例子,能给个第一印象。
目前貌似没有linux下面的网络实现,不过我看有人fork并实现了,用的liburing。不知道会不会merge。

这2个系列的文章都是从用户出发介绍stl支持,然后在介绍一些底层co_xx原语。
就像我们先学std::vector()再学底层operator new(), 比较友好。

三、 第三个系列是cppcoro作者的blog,比较艰深,建议看完前两个系列再尝试。
其中2)有中文译文:https://juejin.im/post/6844903715099377672

  1. coroutine threory
  2. understanding operator co_wait
  3. understanding the promise type
  4. understanding symmetric transfer

16:03


Mar 3rd
2023
gtkmm

Gtkmm编写GUI程序,在调用Gtk::Application::create()时,Glibmm的init()方法会将C和C++的全局locale 设为用户偏好的locale (std::locale::global(std::locale(""))). 这个用户偏好的locale通常是在编程环境中由变量LANG指定的。 假如环境变量中的locale是zh_CN.UTF-8,那么程序中的输入输出流都会受到影响。

若要避免C和C++的全局locale被更换,则在Gtk::Application初始化之前调用Glib::set_init_to_users_preferred_locale(false);

混合使用Glib::ustring和std::iostreams的方法请参考: https://developer-old.gnome.org/gtkmm-tutorial/stable/sec-i18n-expecting-utf8.html.zh_CN

13:13


Feb 17th
2023
wsl
c++

如果Windows中VSCode开发选择了vcpkg为构建工具,则会有如下配置:

"cmake.configureSettings": {
  "CMAKE_TOOLCHAIN_FILE": ".../vcpkg/scripts/buildsystems/vcpkg.cmake"
}

即使取消勾选“同步此设置”,在WSL中仍然会使用这一设置项,导致cmake报错。可以在VSCode的WSL设置中将此项的值改成空字符串,从而覆盖主机的配置。

另外启用ninja的情况下,cmake install阶段会报错,并建议设置CMAKE_BUILD_WITH_INSTALL_RPATH

在VSCode中点Ctrl+,切换到“WSL”或“工作区”,添加:

"cmake.configureSettings": {
    "CMAKE_BUILD_WITH_INSTALL_RPATH": true
}

注意:build install会失败,因为permission denied. 还是去终端里 sudo make install 吧。

13:43


Feb 8th
2023
linux
  • tmux a -t dev
  • 窗格全屏快捷键:prefix + z
  • prefix + $ 重命名session ; prefix + s 列出所有会话。
  • 切换session的快捷键:prefix + ( 或 ) 前后切换client
  • 服务器重启后sessions设置丢失怎么办?分别安装 https://github.com/tmux-plugins/tpmhttps://github.com/tmux-plugins/tmux-resurrect
    使用快捷键 prefix + Ctrl-s - 保存sessions; prefix + Ctrl-r - 恢复sessions
  • 复制模式:添加 set-window-option -g mode-keys vi 到.tmux.conf中。 prefix + [ 进入复制模式,类似vi中查找、定位,按空格键开始选择复制区域,选择完成后Enter键退出,prefix + ] 粘贴。
  • 其他: https://www.bbsmax.com/A/8Bz813RoJx/

11:11