>> I don't see an obvious way to do this with the sync package as it
>> stands. Am I missing something? Is there a good workaround short of
>> juggling channels? (Or should I go file an issue?)
>
> How do you plan to tell interested goroutines that there is a new
> value available?
Via a method call; interested objects implement an interface and
register themselves to be notified. This allows the concurrency to be
hidden from the API.
> If you are going to use a channel to tell them about
> the new value, why not just send them the new value? Then they don't
> have to read it, and you don't have to worry about this locking
> behaviour.
There's already a call in place to read the value, with most of this
locking behavior; I was hoping to simply reuse it.
Passing along the new value is an option, although there are different
types of values in play, and I was hoping to spare the clients the
bother of converting interface{} to the expected type (or of having a
multiplicity of methods, one for each type).
> To answer your question, you aren't missing anything: the
> implementation of RWMutex does not support atomically downgrading a
> write lock to a read lock. I don't know how hard it would be to add
> that facilty.
Okie dokie. I guess I'll start with passing along the new value for
now, and entertain myself later by looking at the RWMutex
implementation.
Thanks!
-josh