- 博客(8)
- 收藏
- 关注
翻译 什么是并发控制中的2PL
In this blog I will describe the concurrency control methods implemented in database management systems, and the differences between them. I will also explain about what locking technique is used in C
2016-03-28 08:51:34 2424
原创 使用libevent和多线程构建高性能服务器(客户端)
有问题可以联系我[email protected]因为开发数据库集群,节点需要通信,必须构建基于socket的C++网络通信系统。多年前使用UPD写过P2P流媒体,但是现在需要TPC,首先使用了Nanomsg作为网络库,但是开发过程中发现其不靠谱(模式太单一,并且出了问题根本找不到解决办法)。于是又掉头回来使用原生的socket编程。发现目前比较流行的(C++)网络编程使用libevent
2016-03-24 07:53:37 11196 3
翻译 如何理解wait前面需要加while循环
如何理解wait前面需要加while循环:pthread_mutex_lock(&m);while(!condition) pthread_cond_wait(&cond, &m);// Thread stuff herepthread_mutex_unlock(&m);The real reason you should put pthread_cond_wait
2016-03-19 07:07:12 3057
转载 pthread与std::thread对比用法
Threadstd::thread的构造函数方便得出人意料,这得感谢std::bind这个神奇的函数。在std::thread的构造函数里,你可以直接传递一个函数和这个函数的参数列表给这个线程。你甚至可以传递一个类成员函数。如果你这么做了,参数列表的第二个参数(第一个参数是被传递的成员函数)会被作为该类成员函数所作用的实例。是不是有点绕……举个例子来说吧:// 假设buy是一个可调用的
2016-03-19 07:05:56 14626 1
翻译 pthread_join和pthread_detach的用法
//从别处拷贝过来的,只作为自己查看方便,原作者不详,请谅解。一:关于joinjoinjoin是三种同步线程的方式之一。另外两种分别是互斥锁(mutex)和条件变量(condition variable)。调用pthread_join()将阻塞自己,一直到要等待加入的线程运行结束。可以用pthread_join()获取线程的返回值。一个线程对应一个pthread_joi
2016-03-18 02:06:32 562
原创 多线程中使用libevent
涉及到的API:1) evthread_use_pthreads()2) struct bufferevent *bev = bufferevent_socket_new(base, -1, BEV_OPT_CLOSE_ON_FREE | BEV_OPT_THREADSAFE);3) evbuffer_enable_locking(bev->output,n
2016-03-17 08:24:30 5351 1
翻译 C++智能指针作为成员变量的用法
I'm having trouble understanding the usage of smart pointers as class members in C++11. I have read a lot about smart pointers and I think I do understand howunique_ptr and shared_ptr/weak_ptr work
2016-03-05 09:50:29 4174
原创 C++中关于静态对象的使用( local static object and global static object)
先给出一个列子:class ThreadManager { public: // global singleton static ThreadManager &GetInstance(void);}// global singletonThreadManager &ThreadManager::GetInstance(void) { static Thre
2016-03-05 03:29:15 2337
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人