Take the following program as an example.
```go
c, err := getFtpConnection()
if err != nil {
return nil, err
}
go func(c2 *ftp.ServerConn) {
c2.List()
}(c)
// c will not be used later
```
let's add `move` function.
```go
func move[T any, PT *T](pp *PT) (res PT) {
res = *pp
*pp = nil
return
}
// Goroutine G1
c, err := getFtpConnection()
if err != nil {
return nil, err
}
go func(c2 *ftp.ServerConn) { // Goroutine G2
c2.List()
}(move(&c))
// c will not be used later
```
Would this `move` without runtime support make GC unable to reach the
object pointed by `c` scanning from the stack of goroutine G? If it does,
the ownership of object is entirely moved to goroutine G2. With the
ownership transfering, freegc for `c2` in the end of goroutine G2 is
feasible in cross-goroutine reference case.
--
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 [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/golang-nuts/97151e98-d453-4ca6-9454-7abe8a27a6abn%40googlegroups.com.