自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(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)

This J›roblem oJ “rloing things right” on a large scale is not essentially new; in a telephone central office, for exa niJ ie, a v ery large numher of operations are performccl iv lii Ie the errors lea‹1iiig to vv roii g numbers are kept well under control, though t I ey have net 1›eeu cont pletely elimiiia te‹I . This has been achieved, in part, through the use ‹if sell-checking circuits. The occasional failure that escapes routine check rug is still ‹letected 1›y' the customer an‹J iv ill, iI it persists, result in customer conipla int, v hile if it is t ransieiit it will J›roduce only occasional iv mug nu nil›crs. .\ I the same t ime the rest of the central ofhce fu nctions sa I isla ct or i I\'. lii a r1i =ita I compu ter, on the other hand, a single failure usual I y me:iris I lie complete la i l ure, in the sense that iI it is detec te‹l no more com J›utiiig can he done until the Jai lure is located ancl correcte‹l , wit i l e if it escapes rlot e‹ ti‹m their it iiival relates all suhsequent operat ions of the machine. Put in other words, in a telephone central office there are ii numlier of J:ara11e1 paths v’1iich are more or less iiiclependent of each other ; in :i digital mach ine there is usually a sinyle ton g path w'hich passes t li ro •b³' 'lie same J, of Sql many time beforethe answer is obtaine‹l.

2014-09-19

空空如也

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

TA关注的人

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