dont use blitz eventqueue for your internal events

BlitzMax Forums/BlitzMax Programming/dont use blitz eventqueue for your internal events

skn3(Posted 2011) [#1]
I am writing a maxgui app ( objecty http://www.skn3.com/apps/objecty ) using the blitz event queue for maxgui events, timer events and also my own app events. I knew this would be a performance hit but it didn't know how much until today. I totally replaced all internal event code to work on a callback system and things have dramatically increased in performance. The callback system is not the solution for gui, the brl event queue is brilliant for that. For anything else where you need to hook into inter-application communications then try this:



An example of using:


[update]Now data objects are allocated on a stack so tons of objects don't have to be allocated/deallocated. The firecallback function will reset the data object so each data object should be treated as a one time only operation.

Last edited 2011

Last edited 2011


JoshK(Posted 2011) [#2]
If you are constantly emitting events, all that dynamic memory allocation will have a cost.


skn3(Posted 2011) [#3]
Hmm maybe I should add in pre created data objects... One for each depth of callback (eg calling a callback from a callback)... Will update when go back to pc.


jsp(Posted 2011) [#4]
Interesting approach.
...didn't know how much until today.

So how much was it?
How many events did you emit, that you encounter performance problems?


skn3(Posted 2011) [#5]
Double post

Last edited 2011


skn3(Posted 2011) [#6]
Well I had communication every time a node (node being an object in the editor) to tell that object was being locked, objected was being edited and then object unlocked. A few more but that was the basics. If multiple nodes were being edited at once it slowed down even after say 20 or so objects. Imagine selecting a node and moving it would generate many updating messages as position changed. Now imagine 100 objects at once.

The reason it was all going over events was so editors, dialogues and other things could react to nodes being altered. The editors, nodes and dialogues are all oop so I can't really optimise by hard coding stuff, all needs to be generic.

The callbacks rectified things and seems to have sped up some of the maxgui stuff as it isn't getting flooded in the event queue!

I don't have an exact number of performance but it went from sluggish 1-5 fps moving 1000 nodes in the editor to silky smooth no lag/delay!

Last edited 2011