Re: [go-nuts] Syscalls inside loops + runtime.KeepAlive

2017-04-05 Thread Caleb Spare
Thanks, Ian.

On Wed, Mar 29, 2017 at 1:03 PM, Ian Lance Taylor  wrote:
> On Wed, Mar 29, 2017 at 9:42 AM, Caleb Spare  wrote:
>> I have a question about this runtime.KeepAlive call:
>>
>> https://github.com/golang/go/blob/041ecb697f0e867a2bb0bf219cc2fd5f77057c2e/src/os/dir_unix.go#L68
>>
>> (There are other examples in the stdlib as well, I think.)
>>
>> It seems to me that, strictly speaking, KeepAlive is unnecessary here
>> since the compiler/runtime cannot know whether the loop will terminate
>> before the result of the ReadDirent is seen. Is that true?
>>
>> I'm not arguing that the KeepAlive should be removed; it's probably
>> best to stick with the pattern syscall(f.Fd(), ...);
>> runtime.KeepAlive(f) in most cases. I'm just checking my understanding
>> here.
>
> Yes, I think you are correct.
>
> Ian

-- 
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.


Re: [go-nuts] Syscalls inside loops + runtime.KeepAlive

2017-03-29 Thread Ian Lance Taylor
On Wed, Mar 29, 2017 at 9:42 AM, Caleb Spare  wrote:
> I have a question about this runtime.KeepAlive call:
>
> https://github.com/golang/go/blob/041ecb697f0e867a2bb0bf219cc2fd5f77057c2e/src/os/dir_unix.go#L68
>
> (There are other examples in the stdlib as well, I think.)
>
> It seems to me that, strictly speaking, KeepAlive is unnecessary here
> since the compiler/runtime cannot know whether the loop will terminate
> before the result of the ReadDirent is seen. Is that true?
>
> I'm not arguing that the KeepAlive should be removed; it's probably
> best to stick with the pattern syscall(f.Fd(), ...);
> runtime.KeepAlive(f) in most cases. I'm just checking my understanding
> here.

Yes, I think you are correct.

Ian

-- 
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.


[go-nuts] Syscalls inside loops + runtime.KeepAlive

2017-03-29 Thread Caleb Spare
I have a question about this runtime.KeepAlive call:

https://github.com/golang/go/blob/041ecb697f0e867a2bb0bf219cc2fd5f77057c2e/src/os/dir_unix.go#L68

(There are other examples in the stdlib as well, I think.)

It seems to me that, strictly speaking, KeepAlive is unnecessary here
since the compiler/runtime cannot know whether the loop will terminate
before the result of the ReadDirent is seen. Is that true?

I'm not arguing that the KeepAlive should be removed; it's probably
best to stick with the pattern syscall(f.Fd(), ...);
runtime.KeepAlive(f) in most cases. I'm just checking my understanding
here.

Thanks!
Caleb

-- 
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.