- 博客(11)
- 资源 (1)
- 收藏
- 关注
原创 [C++11] ThreadPool
背景近期,在造一个异步HTTP调用的轮子;https://github.com/Sai-Jiang简单来说,通过一个Restful接口,代理会接收异步HTTP调用的请求;这些接收到的异步HTTP调用请求,将会由代理代为去执行;适用的场景,主要是低时延接口调用高时延接口;HTTP的调用,目前准备用线程池来做;线程池实现中的任务队列,我就直接复用了之前博客中的BoundedBl...
2018-10-16 23:51:23 560
原创 [C++] 适用程序退出的Signal Handler
To the point#include <csignal>#include <glog/logging.h>#include <mutex>#include <condition_variable>class SignalHandler {public: SignalHandler() = delete; st...
2018-10-16 16:17:58 2284
原创 [C++采坑实录] Lambda按值捕获 和 array
背景 一个学环境的朋友,正准备转码农,今天碰巧遇到一个Bug。这里,我把代码简化之后,来看看到底哪里出现了问题? 代码int main() { int collection[5] = {}; auto process = [=]() { // 按值捕获 for(int i : collection) std:...
2018-10-12 23:44:59 2067 7
原创 [N周N语言] C++实现Golang中的WaitGroup
class WaitGroup {public: void Add(int incr = 1) { counter += incr; } void Done() { counter--; if (counter <= 0) cond.notify_all(); } void ...
2018-10-10 22:15:05 623
原创 [C++11] 线程安全的BlockingQueue
参照muduo中的源码,使用C++11语法进行改写#include <mutex>#include <condition_variable>#include <deque>template <typename T>class BlockingQueue {public: BlockingQueue() : mutex_(), c...
2018-10-10 21:07:43 1002
原创 [kafka] Kafka Docker单机环境搭建
Kafka搭建docker pull wurstmeister/zookeeperdocker pull wurstmeister/kafkadocker run -d --name zookeeper -p 2181:2181 -t wurstmeister/zookeeper docker run -d --name kafka --publish 9092:9092 \--l...
2018-10-09 12:07:22 3176 1
原创 [N周N语言] Golang for range,C++ auto for 遍历时是否可以删除元素?
先说下结论Golang中的map,是可以在for range时删除元素的;但是,不能取元素的地址;C++中的auto for,则是不支持删除元素的;
2018-10-06 20:48:10 1180
原创 [STL] lower_bound和upper_bound实现
int lower_bound(vector<int>& nums, int target) { int lo = 0, hi = nums.size() - 1; while (lo <= hi) { // equal int mid = lo + (hi - lo) / 2; ...
2018-10-05 15:45:22 1960
原创 [Leetcode] 124. Binary Tree Maximum Path Sum
Given a non-empty binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connection...
2018-10-04 16:15:56 290
原创 [uService] Asynchronous Processing with Go using Kafka and MongoDB
参考文献:https://www.melvinvivas.com/developing-microservices-using-kafka-and-mongodb/
2018-10-03 00:30:49 170
原创 [C++] lock_guard vs unique_lock
Lock doesn’t have to taken right at the construction, you can pass the flag std::defer_lock during its construction to keep the mutex unlocked during construction.std::unique_lock<std::mutex>...
2018-10-01 02:27:37 342
ECC(bell labs technical journal)
2014-09-19
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人