Sswift's event system question

Blitz3D Forums/Blitz3D Programming/Sswift's event system question

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Heh, I don't even use that myself (too much work to bother with event systems unless I'm forced to with Blitzplus, and then only for windows events) so I don't remember exaclty what I was doing with that system, but I think I can offer a suggestion.

Looping through all the events really wouldn't be any kind of performance hit worth worrying about. I would just do that. I loop through large types with lots of objects in many of my systems. It's just not going to suck that much CPU time to worry about. Less than a millisecond probably.

But if you really want to delete an event faster, you'll have to store the pointer to the event type somewhere. And since the system can delete an event at any time if it's a timed event, then you need to worry about what happens if you try to access that event manually after it has been deleted by the system.

Thankfully, Blitz helps you out here. I think. I'm pretty sure that if you have a pointer to a type in another type, that if the type is deleted, the pointer in the type referencing it will be automatically set to null.

I think this might even work if the type is in a variable.

So if you go KillMe.Event = New Event, and then you go Blah.Event= KillMe then if you go Delete KillMe, then Blah should be set to Null.

It should be easy for you to test this. But in any case, if that does not work, I am almost 100% positive it will work if Blah.Event is a field in a type.

But that's kind of kludgy, don't you think? I think the better solution is to just make a killevent function that goes through and looks for events of a specific type like you show above and kills them all.