[Gambas-user] Pb instanciating inotify watch

Bruce adamnt42 at gmail.com
Thu Mar 7 10:09:16 CET 2019



On 7/3/19 7:29 pm, Tobias Boege wrote:
> On Thu, 07 Mar 2019, Bruce wrote:
>> On 7/3/19 6:04 pm, Cedron Dawg wrote:
>>> I'm feeling prescient.  I wrote this a few hours ago:
>>>
>>> https://forum.gambas.one/viewtopic.php?f=4&t=669
>>>
>>> It's called "The True True"
>>>
>>> Not exactly spot on, but close.
>>>
>> Nothing is false! Therefore everything is true.
>> This is getting very confusing.
>> b
>>
> 
> What is? The Watch.Events case or the arithmetic properties of True?
> I thought I made a good summary of the situation with this paragraph:
> 
>>>> Every use of `Watch.Events[Mask] = Value` sets all events in the
>>>> Mask (an OR of event constants representing a set of events) to Value,
>>>> without affecting the state of events outside the set. That's how
>>>> it was supposed to be, how it was initially implemented, how it is
>>>> documented inside the source code, how the array interface makes sense,
>>>> it's just not what the current implementation does.
> 
> Before my change an hour ago, the Watch.Events object would roughly
> do this (details omitted and written in Gambas):
> 
>    Public Sub _put(Value As Boolean, Mask As Integer)
>      $hInotify.Events = Mask
>    End
> 
> where $hInotify is a hypothetical object representing the kernel's
> inotify watch and assigning to its Events property subscribes and
> unsubscribes certain events. What it should have done according
> to documentation, what it did initially and what it does now is:
> 
>    Public Sub _put(Value As Boolean, Mask As Integer)
>      If Value Then
>        $hInotify.Events = $hInotify.Events Or Mask
>      Else
>        $hInotify.Events = $hInotify.Events And Not Mask
>      Endif
>    End
> 
> Notice how:
> 
>    - it doesn't ignore the Value argument anymore,
>    - turns on/off only the events given in the Mask
>      and leaves the other bits alone,
>    - the Mask can be a single event constant or an
>      OR of multiple of them.
> 
> The faulty implementation was part of a big refactor done by Benoît
> back in the day. I suspect he misjudged what the array accessors did
> before rewriting them from scratch. That's how the implementation
> and interface/intent drifted apart. And anyway, I imagine most users
> never touching Watch.Events directly because a Watch object auto-
> magically watches everything you wrote an event handler for.
> (That's what all gb.inotify users in the Gambas source tree do.)
> That could explain why it wasn't discovered before.
> 
> Regards,
> Tobi
> 

Thanks Tobi, I was (WAS) getting confused (and worried) that a lot of 
general inotify stuff was about to dramtically change there for a minute.

We use it (gb.inotify) sparingly but quite specifically.
b


More information about the User mailing list