并发相关
https://www.boost.org/doc/libs/1_79_0/libs/context/doc/html/context/performance.html
https://www.boost.org/doc/libs/1_79_0/libs/fiber/doc/html/fiber/overview/implementations__fcontext_t__ucontext_t_and_winfiber.html
完成了boost.asio boost.beast boost.fiber基于work_stealing调度模型的整合
sched_yield()和nanosleep()对进程调度的影响
https://www.cnblogs.com/arnoldlu/p/11287972.html
std::this_thread::yield()使用理解
https://blog.csdn.net/liuhhaiffeng/article/details/52604052
1 | // while(1) std::this_thread::yield(); |
Windows event notification
https://github.com/python-trio/trio/issues/52#issuecomment-424591743
https://stackoverflow.com/questions/41527964/is-there-any-way-to-use-iocp-to-notify-when-a-socket-is-readable-writeable
libbfd
https://blog.csdn.net/crazycoder8848/article/details/51456297
1 | // Windows does not provide sleep functionality with nanosecond resolution, so we |
yield/sched_yield/SwitchToThread
cv条件变量
macOS/xnu
pthread_cond_wait –> sched_yield –> swtch_pri(0)
std::condition_variable –> pthread_cond_wait
API swtch_pri/swtch/thread_switch
1 | std::mutex m; |
1 | pthread_mutex_t mtx=PTHREAD_MUTEX_INITIALIZER; |
suspend or parking
[ref:https://github.com/rust-lang/rust/blob/master/library/std/src/sys_common/thread_parker/mod.rs]
[https://github.com/maracl/dpca_s/blob/master/common/fast_sync_utils.cpp]
1 | Win32 |
Qt
mutex实现
UNIX sem(sysv) > cond(pthread)
MAC semaphore
WIN event
cond实习
UNIX/MAC cond(pthread)
WIN event
semaphores
linux -> futex
win -> WaitOnAddress
mac可以用_dispatch_wait_on_address 未实现
wait_on_address
Linux的libpthread属于glibc
https://blog.csdn.net/puncha/article/details/8487933
并发学习之:Keyed Events(没看懂,要调试下才能明白,伤心!)
http://undocumented.ntinternals.net/
https://cfsamson.github.io/book-exploring-async-basics
https://repositum.tuwien.at/retrieve/8679
qmutex wait
system v sem -> semop
Linux
#ifdef QT_UNIX_SEMAPHORE
sem_wait/sem_timedwait
#else
pthread_cond_wait/pthread_cond_timedwait
#endif
macOS
semaphore_wait/semaphore_timedwait
条件变量与信号量
http://events.jianshu.io/p/5a2b66ccb9a7
条件变量 -> 二元信号量
信号量 -> WaitGroup(Go)/Barrier(libuv)/pthread_barrier_wait
pthread_barrier_wait(Linux PTHREAD_BARRIER_SERIAL_THREAD)
Java(CountDownLatch)
C++ 20 std::latch/std::barrier
https://zh.cppreference.com/w/cpp/thread/latch
https://zh.cppreference.com/w/cpp/thread/barrier
多线程——CountDownLatch详解
https://www.jianshu.com/p/b90309b78775
java 与 golang 并发控制 CountDownLatch CyclicBarrier Semaphore 以及 WaitGroup 的简单使用
https://my.oschina.net/wang520/blog/4480379
https://www.apiref.com/java11-zh/java.base/java/util/concurrent/package-summary.html
Semaphore/CountDownLatch/CyclicBarrier/Phaser/Exchanger
https://www.apiref.com/java11-zh/java.base/java/util/concurrent/locks/package-summary.html
https://www.apiref.com/java11-zh/java.base/java/util/concurrent/atomic/package-summary.html
C# Mutex/Semaphore/EventWaitHandle/CountdownEvent/Barrier
https://learn.microsoft.com/zh-cn/dotnet/api/system.threading.waithandle
https://learn.microsoft.com/zh-cn/dotnet/standard/threading/overview-of-synchronization-primitives
https://github.com/dotnet/runtime/blob/main/src/coreclr/pal/src/thread/threadsusp.cpp
https://github.com/dotnet/runtime/tree/main/src/coreclr/pal/src/synchobj
Event和Mutex区别
https://blog.csdn.net/anjen/article/details/4727791
libuv漫谈之线程
https://zhuanlan.zhihu.com/p/25973650
https://github.com/rust-lang/rust/blob/master/library/std/src/sys/unix/locks/mod.rs
https://github.com/rust-lang/rust/blob/master/library/std/src/sys/unix/futex.rs
https://github.com/rust-lang/rust/tree/master/library/std/src/sys/unix/locks
pthread condvar/mutex/rwlock
https://github.com/rust-lang/rust/blob/master/library/std/src/sys/windows/locks
mutex -> AcquireSRWLockExclusive
rwlock -> AcquireSRWLockShared
conavar -> SleepConditionVariableSRW
https://github.com/rust-lang/rust/blob/master/library/std/src/sync/barrier.rs
1 | pub struct Barrier { |
http://docs.libuv.org/en/v1.x/guide.html
https://pursuitking.com/go_2/
https://qinyuanpei.github.io/posts/345410188/
std::future/std::promise -> std::condition_variable
std::promise -> set_value(cv.notify_all)
std::future -> wait(cv.wait)/get(__sub_wait->cv.wait)
std::packaged_task -> ::operator()(set_value->cv.notify_all)
https://zh.cppreference.com/w/cpp/thread/promise
https://zh.cppreference.com/w/cpp/thread/future
C ++ 20中的新线程(jthread)功能
https://www.jianshu.com/p/c610ad5db6b7
When a program terminates (ie, main returns) the remaining detached threads executing in the background are not waited upon; instead their execution is suspended and their thread-local objects destructed.
https://www.itcodar.com/c-plus-1/what-is-different-between-join-and-detach-for-multi-threading-in-c.html
https://stackoverflow.com/questions/22803600/when-should-i-use-stdthreaddetach
thread — detach()的使用
https://blog.csdn.net/shunlu5586/article/details/127799458
使用join需要等它启动cv.wait_for
使用detach需要等它结束cv.wait_for?
响应式编程 And/When/Then
Promise -> When/Then
https://github.com/ReactiveX/RxCpp/blob/main/Rx/v2/src/rxcpp/rx-observable.hpp
1 | // blocking_subscribe -> |
https://github.com/ReactiveX/RxJava/blob/3.x/src/main/java/io/reactivex/rxjava3/internal/operators/observable/BlockingObservableLatest.java
https://github.com/ReactiveX/RxJava/blob/3.x/src/main/java/io/reactivex/rxjava3/internal/operators/flowable/BlockingFlowableLatest.java
1 | final Semaphore notify = new Semaphore(0); |
https://github.com/David-Haim/concurrencpp/#when_all-function
https://github.com/Naios/continuable
1 | // Connect continuables through when_all, when_any or when_seq |
https://github.com/ponylang/ponyc/blob/main/src/libponyrt/platform/threads.c
https://www.cnblogs.com/wuyongqiang/p/7458184.html
setjmp 的正确使用
https://blog.codingnow.com/2010/05/setjmp.html
- setjmp/longjmp setcontext/getcontext
- ucontext swapcontext/makecontext
- winfiber GetThreadContext/SetThreadContext CreateFiber/SwitchToFiber
- fcontext BOOST_JMP make_fcontext/jump_context/swap_fcontext asm
JCTools -> java
work-stealing in qt
QFuture: mention the work-stealing algorithm in the docs
https://github.com/qt/qtbase/commit/0235de994be7e04aca3456f1260b18313dd45b74
1 | QThreadPool::stealAndRunRunnable |