the.bay.news

When to use mutex or atomic

Ziggit
When to use mutex or atomic
My problem: I’ve got a field of a struct and I need to access the data across multiple io.async and io.concurrent. The data is small (< 8 bits) I need to read / write from thread 1 and read / write from thread 2. I do not need to protect it from reads/writes for extended periods, I only need to prevent it being read or written as corrupted. Questions: When should I protect the data with a mutex vs std.atomic.Value()? Are there code portability concerns between using mutex vs atomic? Which i...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.