Closed matklad closed 6 years ago
Oh sorry, I should have been more specific, I didn't realize the sync version was the same name. I agree, semantics are very unclear for sync version, so maybe don't need to do that? I was just needing single thread version to be clone.
unsync case is totally uncontroversial, implemented in https://github.com/matklad/once_cell/commit/084ffbdd5ee76a1fac1a78e6bdff0b23e18611a6 and relased as 1.0.6
Closes https://github.com/matklad/once_cell/issues/4
@starkat99 one thing I am worried about that there's no strong semantics here. What happens if one thread is calling
get_or_init
, and the over thread is calling.clone
is indeterminate: you might get either an empty or a full cell. I think that's the reason why synch primitives likeOnce
orMutex
don't implementClone
in general? Will this semantics work for you?