原创 A deep dive into /proc/cpuinfo

A deep dive into /proc/cpuinfo Background knowledge /proc/cpuinfo is a read only file, which shows each logic CPU w

原创 C++ Locks

C++ Locksstd::mutexdeadlockstd::lock_guardTo avoid deadlockstd::unique_lockTo avoid deadlockTo get higher paralleli

原创 C++ keywork explicit

最近code的時候遇到一個warning,雖然不是error,但是也值得好好說一下: Warning: Single-argument constructors must be marked explicit to avoid

原创 C++ Multithreading(3) -- passing arguments to threads

線程傳參passing arguments to threadscaveat:pass stack-located local variable to threadspass heap-located variable to th

原创 C++ Multithreading(4) -- event handling

Event handlingEvent handling in C++ multithreading:global variablecondition variable Event handling in C++ multithr

原创 C++ alias template

C++ alias templatetype aliastypedefusingtypedef和using的區別alias template: type alias type alias就是將某一個type重新命名爲另一個更加直觀

原创 C++ Multithreading (2) -- joining/detaching threads

Joining/Detaching threadsjoin threadsdetach threads join threads 當在main()函數中創建了線程t1,如果不使用t1.join(),那麼main就有可能在t1結束前

原创 C++ Multithreading (1) -- creating threads

Three ways to create threadsintroductionthread creationcreating threads with function pointercreating threads with

原创 GDB Tutorial

GDB tutorialGDB overviewload executable file into GDBrun program in GDBquit GDBGDB commandsbreaknextlistprintup / d

原创 C++ getopt

本文講解如何處理命令行傳入的選項和參數getopt()getopt_long()getopt_long_only()example 比如我們執行如下指令會輸出file文件的前10行: head file // 默認輸出file的前

原创 C++ Lambda function

Lambda FuctionDefinitionNeed of Lambda functionsHow to pass outer scope elements inside Lambda functions Definition

原创 C++ Function object

本文介紹C++ standard library中的function objectdefinitioncreate a function objectfunction object VS function優勢1:優勢2: defi

原创 C++ Smart pointer

Smart pointer in C++什麼是smart pointer爲什麼要使用smart pointer常用的smart pointer以及使用方法shared_ptrshared_ptr的使用方法weak_ptrweak_

原创 C++ Condition variable

如果你的線程需要 改變某個變量,改動完成之後通知另一個線程 持續等待,直到收到某一個線程發來的通知 那麼就可以放心食用std::condition_variable了。 下面用一個例子來介紹什麼是condition varia

原创 C++ object initialization

在C++中,即使是非常簡單的初始化也有很多需要了解的東西,總結起來,一共分爲以下幾個部分: initializer list uniform initialization copy initialization Initi