These are chat archives for rust-lang/rust

19th
Feb 2016
gallexme
@gallexme
Feb 19 2016 13:43
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
@gallexme lazy_static!, I think
gallexme
@gallexme
Feb 19 2016 13:52
i thought its not changeable after one time init?
also not threadsafe? ?
Peter Atashian
@retep998
Feb 19 2016 13:52
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
it requires the inner data to be Sync, so it is thread safe
gallexme
@gallexme
Feb 19 2016 13:52
k thanks
Vladimir Matveev
@netvl
Feb 19 2016 13:52
and it may be mutable if you store a mutex in it
gallexme
@gallexme
Feb 19 2016 13:53
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
well, lazy_static is the correct and safe approach to create globally shared data
gallexme
@gallexme
Feb 19 2016 14:26
@netvl thanks