目前分類:C and C++ (177)

瀏覽方式: 標題列表 簡短摘要

//https://gist.github.com/yohhoy/2156481
//reference 1 :

hedgezzz 發表在 痞客邦 留言(0) 人氣()

//https://github.com/cloudwu/skynet/blob/master/skynet-src/rwlock.h
struct rwlock { 

hedgezzz 發表在 痞客邦 留言(0) 人氣()

#include<stdio.h>
#include<pthread.h>

hedgezzz 發表在 痞客邦 留言(0) 人氣()

#include<stdio.h>
#include<pthread.h>

hedgezzz 發表在 痞客邦 留言(0) 人氣()

#include<stdio.h>
#include<pthread.h>

hedgezzz 發表在 痞客邦 留言(0) 人氣()

#include <fcntl.h>
#include <sys/stat.h>

hedgezzz 發表在 痞客邦 留言(0) 人氣()

#include <fcntl.h>
#include <sys/stat.h>

hedgezzz 發表在 痞客邦 留言(0) 人氣()

gcc testsync2.c -D_GNU_SOURCE  -march=native -lpthread -o testsync2.exe

//http://www.alexonlinux.com/

hedgezzz 發表在 痞客邦 留言(0) 人氣()

seqlock 實在是非常好用的概念 ,  假設你有兩個 threads ,

一個要寫入結構資料,一個要讀結構資料,此時,最常用的方法是 mutex or spin lock ,

hedgezzz 發表在 痞客邦 留言(0) 人氣()

http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue

 

hedgezzz 發表在 痞客邦 留言(0) 人氣()

//http://epaperpress.com/sortsearch/skl.html

#include <stdio.h>

hedgezzz 發表在 痞客邦 留言(0) 人氣()

假設,  你走高速公路要從基隆 到屏東 , 經過的每個縣都有收費站 , 你每站收費花很多時間 !!

 

hedgezzz 發表在 痞客邦 留言(0) 人氣()

offsetof 傳回一個變數在一個結構的 offset , 這個在你需要轉換指標時有用,

我在 intrusive linked list 也用到這個 function :

hedgezzz 發表在 痞客邦 留言(0) 人氣()

首先,必須介紹超級好站 : http://preshing.com/

還有這個:http://bartoszmilewski.com/2008/12/01/c-atomics-and-memory-ordering/

hedgezzz 發表在 痞客邦 留言(0) 人氣()

enqueue_pos_.compare_exchange_weak(pos, pos + 1, std::memory_order_relaxed)

memory_order_relaxed 是 c++11 的語法,以後再解釋, compare_exchange_weak 是 CAS(compare and swap) ,

hedgezzz 發表在 痞客邦 留言(0) 人氣()

網路上找到很好用的指標程式如下 :

template<class T>

hedgezzz 發表在 痞客邦 留言(0) 人氣()

想把程式備份....不太會用 痞客邦~~~~

ㄚ哉!!

hedgezzz 發表在 痞客邦 留言(0) 人氣()