Ben Chuanlong Du's Blog

It is never too late to learn.

Thread-Local Storage for Rayon

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

There might be issue if the code relies on Drop of the struct. For example, if you create a BufWriter in thread-local storage, last buffered output might not flush. You have …

Async, Concurrency, Multithreading and Parallel Computing in Rust

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Basic Struct Types for Rust Concurrency

UnsafeCell: the only foundamental struct which allows interior mutability. Other struct (e.g., Cell, RefCell, Rc, Arc, etc.) with interior mutability relies on UnsafeCell. Rc …

Send and Sync in Rust

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Tips and Traps

  1. Send and Sync are 2 thread-safty related marker traits in Rust.

  2. A type is Send if and only if it can be transferred across thread boundaries. A type is Sync if and only if &T

Tips on C++ Compilers

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

GCC

  1. User option -lpthread to link the thread library when your code use the thread library. If you do not use, the option -lpthread, you can probably compile your coe without …

Parallel Computing in Java

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

The following are a few tips for multithreading parallel computing in Java.

  1. Instance fields, static fields and elements of arrays are stored in heap memory and thus can be shared between …