lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, 30 Jul 2020 at 22:27, Egor Skriptunoff
<egor.skriptunoff@gmail.com> wrote:
>
> On Thu, Jul 30, 2020 at 9:08 PM Dibyendu Majumdar wrote:
>>
>> You just need to ensure that the close
>> logic is also invoked by the GC
>
>
> If I understand your words correctly, you suggest the following:
> if a coroutine is exiting due to error,
> all the "defer" statements will be executed by GC when collecting the coroutine?
>
>

Not exactly ... I am saying that the close() method should invoke the
finalizer on the object - and of course the finalizer needs to be
idempotent so that it can be safely invoked multiple times.
Eventually every object will be garbage and the object finalizer will
clean it up even if the close() never got called.

Regards
Dibyendu