原创 muduo之Thread

         muduo也對線程進行了封裝,下面看一下實現。 Thread.h // Use of this source code is governed by a BSD-style license // that can be

原创 常見算法之貪心算法

         test

原创 muduo之ThreadLocal

         ThreadLocal用來存儲線程私有數據的類。 // Use of this source code is governed by a BSD-style license // that can be found i

原创 redis源碼之util

         util.c裏面是一些常見的輔助處理算法,下面看一下。 /* Convert a string representing an amount of memory into the number of * bytes,

原创 常見算法之回溯法

         test

原创 muduo之ThreadPool

         muduo中的線程池。 ThreadPool.h // Use of this source code is governed by a BSD-style license // that can be found i

原创 redis源碼之sds

        sds是redis中一個很重要的數據結構,今天看學一下它源碼的實現。 typedef char *sds; /* Note: sdshdr5 is never used, we just access the flag

原创 邏輯運算符'&'取某值

         邏輯運算符'&'可以去特定位數的值。 #include <stdio.h> //1111 0100 0010 0100 0000 //1000000 // 11 1111 1111

原创 常見算法之動態規劃

         test

原创 redis源碼之字符串壓縮

        redis關於字符串壓縮的幾個文件分別是:lzf.h,lzfP.h,lzf_c.c,lzf_d.c,下面看一個測試用例。 #include <iostream> #include <string> #include "l

原创 docker搭建常見組件

         docker安裝環境比較簡單,docker一鍵啓動和停止。          docker安裝consul             docker pull consul   //下載consul鏡像          e

原创 多線程服務端和客戶端通信

         golang示例多線程服務端和客戶端通信 package main import ( "net" "fmt" "time" ) func server(){ listen_sock, err := net

原创 muduo之GzipFile

        GzipFile封裝了gzip的一些API,記錄一下 // Use of this source code is governed by a BSD-style license // that can be found

原创 muduo之mutex和condition

        線程同步所需的mutex和condition,記錄一下。 Mutex.h // Use of this source code is governed by a BSD-style license // that can

原创 muduo之FileUtil

        FileUtil用來操作文件。AppendFile用來寫日誌,使用的fopen函數;ReadSmallFile使用open函數用來讀取linux內核的一些信息。 FileUtil.h // Use of this sou