--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Personally (Go 1.2?) I'd like to see Close defined as idempotent.
It would be nice if channel close was idempotent too, for conceptual
symmetry, and because it's not uncommon to implement io.Closer using a
channel under the hood.
On Wed, Apr 10, 2013 at 12:21 AM, Gordon Klaus <gordon...@gmail.com> wrote:I don't think so. Channel is implemented as a pointer, so the memory
> You missed the key phrase "between unsynchronized goroutines". If there is
> no synchronization, then a channel close cannot be guaranteed to be
> observed.
model allows a variable of type channel to be seen differently by two
non syncing goroutines. But as long as those two (or any number of)
goroutines already have the same pointer to the run time object
implementing a channel - it is no more possible after a channel close
- for any goroutine which attempts to close the same channel again, to
see it as non closed.
By extension: No non syncing goroutine can see a
sync.Mutex as unlocked after it was locked by any other non syncing
goroutine (let's assume no Unlock ever happens to make it simple).
Channels (and eg. mutexes) are intrinsically safe for concurrent
access - the variables (arguments, pointers to) are not - if being
updated by a non syncing goroutine.
IOW: The memory model domain covers _values_ of variables and
arguments (and things possibly pointed to by them), not necessarily
the (internal, opaque) _state_ of run time objects.
-j
By extension: No non syncing goroutine can see a
sync.Mutex as unlocked after it was locked by any other non syncing
goroutine (let's assume no Unlock ever happens to make it simple).This is true (although not by extension of the above) because otherwise the mutex would be broken.
Channels (and eg. mutexes) are intrinsically safe for concurrent
access - the variables (arguments, pointers to) are not - if being
updated by a non syncing goroutine.Channel operations are safe, yes. But that doesn't mean they have to be synchronized in all cases. For example, channel sends from multiple goroutines certainly don't have to synchronize with each other -- what matters is that a receive synchronizes with a send.
John Nagle
John Nagle
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/LJPi2RYI4c8/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
The panic behavior is currently guaranteed by the spec.
However, it doesn't specify *when* the panic will happen, so in some implementation where optimizations are made, it may happen at the runtime's leisure.