Should I be stubbing out BUTON_EVENT RELEASEs?
Joe Hebert
Posts: 2,159
I very rarely use the RELEASE for a BUTTON_EVENT (volume is the only one that comes to mind) and so I very rarely have a RELEASE: handler. Shouldn?t I be stubbing out the RELEASE in every BUTTTON_EVENT so Netlinx doesn?t have to make an unnecessary pass through mainline looking for it?
Do you all stub your RELEASE?
Do you all stub your RELEASE?
0
Comments
I just never include the release statement in the button events. Does that slow the event itself down then?
Could be critical in some systems I have hundreds of button events.
i only use the release function when i really need it (volume or camera control for instance)
I don't bother, I don't believe it matters.
"Stub" (verb) to put in a piece of code that does nothing just to emphasise the fact that you are doing nothing.
I support stubbing in lots of places eg switch/case defaults as a way of reminding yourself that you have or haven't thought about it. I even have a routine called DoNothing() which I sometimes use to amuse those who follow me. If anyone wants the code just let me know ;^)
But as many have noted, releases are so rarely relevant that I don't bother.
I do not believe that there is any performance implication either way.
Not sure, when I stub my toe, it definately doesn't feel like NOTHING happened :P
Jeff
That's because Joe just made it up and it's such a good word everyone else ran with it!
Consider the attached picture and the following code.
Output when button 1 is pushed and released:
Line 1 :: PUSH from Event - 02:26:47
Line 2 :: RELEASE from mainline - 02:26:47
When the PUSH is triggered mainline does not get serviced since the PUSH was found in a BUTTON_EVENT. When the RELEASE is not found in the event table, Netlinx also has to run through mainline to try to find a match. So some of the event driven power that Netlinx offers is diminished to a degree when it has to double up on work by looking through the event table and mainline.
How much of a performance implication can certainly be debated but I do believe there is one. Perhaps it?s too minuscule to matter though in most applications.
It?s an esoteric euphemism which only AMX programmers are privy too. Stub your release has several different meanings. One example of usage: If you are driving down the highway and an AMX programmer cuts you off in traffic you can roll down your window and yell, ?Hey buddy, go stub your release!?
However, in all seriousness, this is a pretty interesting topic, and probably would agree with you Joe - that even though the release is "searched" for in mainline, very little (if any) performance would be impacted. This almost falls into the same performance debate of, "should I use for-loops in mainline, or spell everything out?" I would love to hear from a Programming Master or even an AMX old-timer on this topic . . ..
Your code can have a stub, but you cannot stub your code.
If you don't want to have your Define_Program section processing button releases then it would be a good idea to have a RELEASE: with no code.
This would handle all releases of a single touch screen port. I do not believe there would be any run time improvement only a 'main line' filter.
... to open another can of worms...
Should we then also be stubbing HOLDs in the Button_Events?
-trav
Absolutely Not!
It would be like generating a huge stack of WAITs with no purpose.
Don't even go there.
: ) (gotcha!)