Add mutex to setEpsilon#4112
Conversation
1995f53 to
598fb8b
Compare
|
This scares me a bit. If I try to set epsilon to a new value while I'm in a non-threaded section of code, and then I enter into threads, what happens? My first guess would be "if new threads are being forked then they inherit the new value, but if we're using an underlying thread pool then only one of the threads in the pool has the new value", and if that's the case then that would be horrifying. If there's already a setter function and we're only ever using that, could we just add a lock in the setter instead? |
|
excellent point |
|
We'll my first commit just makes epsilon atomic. That seems like the easiest way. |
|
Push it |
ec4b80d to
84274e2
Compare
|
arithmetic operators aren’t overloaded for 😭 meaning we'd have to add a crapton of |
84274e2 to
1a7c594
Compare
1a7c594 to
a7490b9
Compare
The right answer would be to set epsilon in the thread you expect it to be used (which is what we do in MOOSE). |
roystgnr
left a comment
There was a problem hiding this comment.
Looks good to me now; we'll merge in a day or so unless John has any complaint.
jwpeterson
left a comment
There was a problem hiding this comment.
My only question was whether making the std::mutex itself static creates another kind of race condition, but that appears to be safe to do.
|

Closes #4111
Thanks @lindsayad for pointing me to
thread_local