I need to use a sync.RWMutex
as a neighborhood variable inside a bundle that copies/strikes/deletes
recordsdata after which (in easy phrases) updates the state of the paths in different native maps.
So I made a decision to create the native mutex and depart this remark in it:
// To dam/unblock when performing reads and writes in blogs.
// mu ought to solely be utilized in exportable capabilities that carry out reads and writes
// in reminiscence (i.e. someXMap and someYMap) and within the filesystem, non-exportable
// capabilities that additionally carry out such reads/writes shouldn't use mu however its
// caller which mandatorily have to be an exportable operate.
// In brief, the non-exportable capabilities that make reads/writes within the blogs
// can solely be known as by an exportable operate that makes use of mu.
mu sync.RWMutex
I’m wondering what one other developer would suppose when he will get to work with this bundle and reads that mu
ought to solely be utilized in exportable capabilities, is it a rational design?, or ought to I try to search out one other higher technique?
I need to know if my strategy will keep away from race situations.