Strict concurrency checking reveals that I am lazy

Hi there,

Enabling strict concurrency checking shows me things that I kind of know are bad, but have ignored until now.

One example is a function that takes some optional configuration.

In case the configuration is not present I let it default to predefined value.

And then I also want to be able to change the default based on some external events. So I end up with globally shared mutable state.

But I so rarely change the global mutable state, that I’ve ignored the presence of a bug here.

I expect that the solution is to add locks around setting and getting of the global default value.

Is there an ‘idiomatic’ lock to use in Swift?
And then how should the global default value be properly annotated with regards to concurrency?

1 Like

Soon: [Pitch] Synchronous Mutual Exclusion Lock

2 Likes