You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I propose to add SafeLength and DirtyLength method to sync.Map. Currently, we don't get the length of sync.Map. For that reason, we can't prepare length and capacity for map and slice. sync.Map has two map, m contained in readOnly struct and dirty.
So, SafeLength returns the length of m, DirtyLength returns the length of dirty. If a developer wanna get the length of m (i.e. wanna to get the length of immutable struct stored atomically), we'll use SafeLength. Conversely, If a developer wanna to get the length of dirty which contains all values, we'll use DirtyLength.
But, dirty may be initialized. For example, Load and missLocked initialize it. Above the reason, I recommend to use SafeLength, but I also added DirtyLength for every case. If this proposal is accepted, we can execute following code.
I propose to add SafeLength and DirtyLength method to sync.Map. Currently, we don't get the length of sync.Map. For that reason, we can't prepare length and capacity for
map
andslice
. sync.Map has two map,m
contained in readOnly struct and dirty.So, SafeLength returns the length of
m
, DirtyLength returns the length of dirty. If a developer wanna get the length ofm
(i.e. wanna to get the length of immutable struct stored atomically), we'll use SafeLength. Conversely, If a developer wanna to get the length of dirty which contains all values, we'll use DirtyLength.But, dirty may be initialized. For example, Load and missLocked initialize it. Above the reason, I recommend to use SafeLength, but I also added DirtyLength for every case. If this proposal is accepted, we can execute following code.
The text was updated successfully, but these errors were encountered: