Finalizers are essential in a highly concurrent system - otherwise you are 
doing manual resource management with automatic memory management (a resource) 
and its ugly and error prone. 

Even though they are no guaranteed to be called they work very well to manage 
shared resources. 

> On Nov 23, 2020, at 5:32 AM, tokers <zchao1...@gmail.com> wrote:
> 
> Are there any documents?
> 
>> On Monday, November 23, 2020 at 7:28:31 PM UTC+8 Tamás Gulácsi wrote:
>> There is a runtime.SetFinalizer, but it is not guaranteed to be run, anytime.
>> The most idiomatic and safe solution is to have a Close() method on the Go 
>> side, which frees the C side.
>> You may even add a Finalizer that panics if Close haven't been called 
>> before...
>> 
>> tokers a következőt írta (2020. november 23., hétfő, 4:17:18 UTC+1):
>>> There is a runtime.SetFinalizer function.
>>> 
>>>> On Sunday, November 22, 2020 at 8:13:22 PM UTC+8 Sean wrote:
>>>> I am writing a Golang wrapper for OpenAL-Soft. 
>>>> I need to create some buffers. These operations are happening on the 
>>>> OpenAL-Soft side (So C functions). I am loading PCM data into buffers. 
>>>> 
>>>> Can I set up a trigger mechanism like "x.__del__" as in Python? 
>>>> 
>>>> I can set the garbage collector to follow some objects. 
>>>> But I have to call some C functions (alDeleteBuffers) to delete buffers 
>>>> in OpenAL. 
>>>> 
>>>> I want garbage collector to run this function while deleting the object. 
>>>> 
>>>> Is this possible? 
>>>> 
> 
> -- 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/97bafe0a-46a6-46ba-8aeb-fa875bf80b58n%40googlegroups.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/A0B5093F-5306-4B0F-BA98-B71A5E8CCCCD%40ix.netcom.com.

Reply via email to