More specifically, if I want to make the read/write of a pointer value 
atomically, 
then must the pointer value be defined as a value of type unsafe.Pointer?

On Tuesday, October 11, 2016 at 10:26:21 PM UTC+8, T L wrote:
>
> package main
>
> import "unsafe"
> import "sync/atomic"
>
> type T struct {
>     a *int // no ways?!
>     b unsafe.Pointer
> }
>
> func (t T) A() *int {
>     // cannot take the address of unsafe.Pointer(t.a)
>     //return (*int)(atomic.LoadPointer(&unsafe.Pointer(t.a)))
>     
>     return t.a 
>     // no ways to read t.a atomically if unsafe.Pointer and atomic.Value 
> are not considered?
> }
>
> func (t T) B() unsafe.Pointer {
>     return atomic.LoadPointer(&t.b)
> }
>
> func main() {
> }
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to