These are chat archives for rust-lang/rust

19th
Feb 2016
gallexme
@gallexme
Feb 19 2016 13:43 UTC
best way to have some dynamic global concurrent config in rust without passing a readwrite lock around?
Vladimir Matveev
@netvl
Feb 19 2016 13:50 UTC
@gallexme lazy_static!, I think
gallexme
@gallexme
Feb 19 2016 13:52 UTC
i thought its not changeable after one time init?
also not threadsafe? ?
Peter Atashian
@retep998
Feb 19 2016 13:52 UTC
So store a Mutex in the lazy static
that way you can mutate it and it's thread safe
Vladimir Matveev
@netvl
Feb 19 2016 13:52 UTC
it requires the inner data to be Sync, so it is thread safe
gallexme
@gallexme
Feb 19 2016 13:52 UTC
k thanks
Vladimir Matveev
@netvl
Feb 19 2016 13:52 UTC
and it may be mutable if you store a mutex in it
gallexme
@gallexme
Feb 19 2016 13:53 UTC
or would someone have a idea to do it good?
else im gonna try lazy static later
Vladimir Matveev
@netvl
Feb 19 2016 14:24 UTC
well, lazy_static is the correct and safe approach to create globally shared data
gallexme
@gallexme
Feb 19 2016 14:26 UTC
@netvl thanks