自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(15)
  • 收藏
  • 关注

原创 time-wait的作用

https://zhuanlan.zhihu.com/p/51961509

2021-02-28 21:35:07 106

原创 ASIO

http://think-async.com/

2021-02-27 16:26:09 111

原创 C++基础:内存一致性和多线程的关系

转载于知乎问题:https://www.zhihu.com/question/24301047其实多线程间代码本来就是各自执行各自的,这个和memory order是两个概念,memory order是针对单线程重排序规则的概念,概念本身可以不讲多线程。多线程只是利用了memory order的规则加内存一致性来做线程同步而已。因为概念混乱,1,2,3,4都不太对的感觉。第一点,relaxed,线程内不保证所有原子操作是顺序进行的,而是如其字面意思在不影响逻辑的条件下最大限度的重排序(relax

2021-02-26 21:58:36 299

原创 非线程安全系统函数

https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09

2021-02-25 19:06:49 71

原创 C++编程实践:线程安全的单例模式

https://preshing.com/20130930/double-checked-locking-is-fixed-in-cpp11/http://www.voidcn.com/article/p-zdgudqdp-xt.html#include <iostream>#include <mutex>#include <atomic>#include <thread>class Singleton {private: ..

2021-02-23 17:40:18 123 1

原创 C++基础:std::enable_shared_from_this的作用

使用share_ptr管理自定义类型存在的问题​#include <memory>#include <iostream>class B{public: void func() { // 1.使用this裸指针进行共享指针的初始化 std::shared_ptr<B> local_sp_b(this); // 2.local_sp_b限定在作用域内,计数为1 std::cout &lt.

2021-02-21 21:45:42 343

原创 C++基础: shared_ptr<T>::reset 自定义删除器函数

class Base{public: ~Base() { std::cout << __FUNCTION__ << std::endl; } void Test(std::string name, int id) { std::shared_ptr<Base> sp(new Base()); // 1.reset函数的第二个参数需要为仅有一个Base指针参数的方法 // 2..

2021-02-21 19:24:59 721

原创 C++基础:weak_ptr初始化

#include <memory>#include <iostream>int main(){ // 1.shared_ptr直接赋值 std::shared_ptr<int> sp0(new int(10)); std::weak_ptr<int> wp1 = sp0; // 2.make_shared std::weak_ptr<int> wp2 = std::make_shared&l.

2021-02-20 23:54:53 770

原创 Cpp-Concurrency-in-Action 随书官方源码

https://github.com/bsmr-c-cpp/Cpp-Concurrency-in-Action

2021-02-20 20:31:26 189

原创 C++基础:智能指针share_ptr的初始化

// queue::front#include <memory>#include <iostream>int main (){ std::shared_ptr<int> sp1{new int(10)}; std::shared_ptr<int> sp2(new int(10)); std::shared_ptr<int> sp3 = std::make_shared<int>(10); std.

2021-02-20 17:11:38 593

原创 C++基础:伪共享(false sharing)

https://www.cnblogs.com/tong-yuan/p/FalseSharing.html

2021-02-20 17:06:50 666

原创 C++基础:shared_ptr 创建时即捕获析构

#include <iostream>using namespace std;class base{public: base(){cout << "base construct" << endl;} virtual void print(){cout << "base print" << endl;} ~base(){cout << "base destruct" << endl;}};.

2021-02-20 15:02:33 321

原创 C++基础:share_ptr与bind配合使用的引用计数陷阱

#include <iostream>#include <functional>class Foo {public: int doit() { return 10; }};int main() { std::shared_ptr<Foo> pFoo(new Foo); std::cout << pFoo.use_count() << std::endl; ...

2021-02-19 01:10:35 304

原创 C++11多线程基础:使用std::atomic_flag实现自旋锁

#include <atomic>#include <iostream>#include <thread>class spinlock_mutex{ std::atomic_flag flag;public: spinlock_mutex(): flag(ATOMIC_FLAG_INIT) {} void lock() { while(flag.test_and_set(std:.

2021-02-08 15:29:54 344

原创 C++基础:右值引用的汇编分析

https://www.cnblogs.com/likaiming/p/9045642.html

2021-02-04 20:32:29 235

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除