[Gambas-devel] [Gambas-devel-svn] SF.net SVN: gambas:[6035] gambas/trunk

Benoît Minisini gambas at ...1...
Mon Dec 30 03:16:01 CET 2013


Le 30/12/2013 02:49, Tobias Boege a écrit :
> On Mon, 30 Dec 2013, tobiasboe at ...1... wrote:
>> Revision: 6035
>>            http://sourceforge.net/p/gambas/code/6035
>> Author:   tobiasboe
>> Date:     2013-12-30 01:37:38 +0000 (Mon, 30 Dec 2013)
>> Log Message:
>> -----------
>> [GB.INOTIFY]
>> * NEW: New component to interface Gambas with the Linux-specific inotifies
>> * NEW: The Inotify class can be created to watch a certain path for events
>>    which are reported by various Gambas events being raised.
>>
>
> Benoit, the Inotify class gets a bonus reference because it is watched by
> the interpreter. IIRC, I have seen this in another component and begin now
> to wonder if this is necessary.
>
> Assumed, it wouldn't have that bonus reference and the user dropped the last
> "regular" reference (i.e. from a variable) and the _free() method would
> de-register the watch, wouldn't all be fine? Then the Inotify class would
> behave more naturally among other Gambas classes (which normally don't have
> hidden bonus references).
>
> Sample project attached. It works well because I use a console program and
> QUIT all the stuff away anyway.
>
> But my worries arose when I thought about using inotifies in a GUI
> application. I would have (to not use QUIT) to manually remove all the
> watches so that the interpreter terminates. This means I would have to save
> all the Inotify objects in an array and Release() every object, then clear
> the array. Doesn't sound like it should be...
>
> So: is this bonus reference for watched objects necessary or just an awry
> memory in my head?
>
> Regards,
> Tobi
>

Hi,

First, as inotify depends on no other library than the libc, you must 
put it in the /main/lib directory, not in its own component directory.

The event loop won't terminate if there is at least one file descriptor 
to watch. It's up to you to disable the watch automatically as soon as 
the last notify object is freed. Apparently this is what you done, so I 
don't see the problem. But it is late, I will look at it another day.

Regards,

-- 
Benoît Minisini




More information about the Devel mailing list