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
There is no global mutex lock on changing the value of the global in InitGlobalBox and as such, is open to race conditions.
It also remains unclear when and where it should be called from. If I import two libraries, apples and bananas both of which use the global pandora box, which of them is suppose to make this call to InitGlobalBox? Or is neither supposed to call it, and it is my duty as the top-level code to call it? If so, how can either apples or bananas guarantee that the init has been called?
Couldn’t this be a simple func init() { … } to ensure that it is called once at initialization of the program before any importing packages has its own inits run, thus guaranteeing it is well-behaved? (Also, the init process is run single-threaded, meaning many things that would otherwise be race conditions do not happen. That is, a write-once/read-many variable can be written to without fear of racing reads.)
The text was updated successfully, but these errors were encountered:
There is no global mutex lock on changing the value of the global in
InitGlobalBox
and as such, is open to race conditions.It also remains unclear when and where it should be called from. If I import two libraries,
apples
andbananas
both of which use the global pandora box, which of them is suppose to make this call toInitGlobalBox
? Or is neither supposed to call it, and it is my duty as the top-level code to call it? If so, how can eitherapples
orbananas
guarantee that the init has been called?Couldn’t this be a simple
func init() { … }
to ensure that it is called once at initialization of the program before any importing packages has its owninit
s run, thus guaranteeing it is well-behaved? (Also, theinit
process is run single-threaded, meaning many things that would otherwise be race conditions do not happen. That is, a write-once/read-many variable can be written to without fear of racing reads.)The text was updated successfully, but these errors were encountered: