初探《Linuxマルチスレッドサービス端のプログラミングはmuduo C++ネットワークライブラリを使う》
2855 ワード
第1部c++マルチスレッドシステムプログラミング
第1章スレッドセキュリティの対象ライフサイクル管理
第2章スレッド同期要約
第3章マルチスレッドサーバの適用場面と常用プログラミングモデル
C++マルチスレッドシステムプログラミング要点
第1章スレッドセキュリティの対象ライフサイクル管理
1. , race condition
2. : , ; , ; 。
3. MutexLock , RAII 。 linux pthread_mutex_t, 。
4. class noncopyable protected , , , 。 noncopyable private, copy , , copy
5. race condition: ; this ; 。
6. mutex
7. class , 。
8. observer:
9.
10. share_ptr weak_ptr
11. : 、 、 、 、 、 new/delete。
12. shared_ptr string : shared_ptr ; shared_ptr , ; shared_ptr , 。
13. shared_ptr 。
14. shared_ptr 。 pass by const reference
15. ??? : ;share_ptr , ;share_ptr , DLL , A B 。; : foo , , ; 。
16. : ,
17. RAII handle: : handle share_ptr
18. :
19.
20. : , , , 。
第2章スレッド同期要約
1. :message passing shared memory。
2. :
, 。
:TaskQueue、Producer-Consumer Queue、CountDownLatch
, , ,
atomic , lock-free , “ ” 。
3. : RAII mutex 、 、 、 ; mutex( mutex); lock() unlock() , Guard 。 Guard , ( ) , 。
4.
第3章マルチスレッドサーバの適用場面と常用プログラミングモデル
1. : , ( ) , ( ), ( , )。 , (crash,sigchld), 。
2. ( ); ( ); ( ); ( bug, , )
3. , , , 。
4. : IO + IO , Reactor 。
5. :non-blocking IO + one loop per thread
6. one loop per thread : , , ; ;IO , TCP 。
7. IO , event loop , blocking queue taskQueue
8. :one(event) loop per thread + thread pool:event loop IO , IO ;thread pool ,
9. TCP, ;
10. TCP , marshal/unmarshal , , google protocol buffers
11. TCP ?
12. : fork; CPU ( )
13. Event loop ,
14. : 、 IO “ ” , latency。
15.
C++マルチスレッドシステムプログラミング要点
1.