Raised This Month: $51 Target: $400
 12% 

Registering events vs forwards


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 05-03-2019 , 23:13   Registering events vs forwards
Reply With Quote #1

My question is fairly simple. I have a little side project which uses multiple plugins, but they all pretty much use the same events. Would you gain any performance by creating a forward for lets say deathevent and using it in all plugins or using register_event in each plugin?

Mind you this is a high load server and I would like to squeeze every bit of performance out of it. Even if in a normal scenario it makes little sense, I would still like to hear the consensus.
__________________
Spirit_12 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-04-2019 , 00:35   Re: Registering events vs forwards
Reply With Quote #2

Why in the world would you create a forward for something that already has a method to catch the event? That would actually add extra overhead.

If you have code that needs executed when an event occurs, register the event.
__________________
fysiks is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-04-2019 , 03:47   Re: Registering events vs forwards
Reply With Quote #3

As fysiks said, you will only add extra overhead.
If you register DeatMsg event directly in all plugins: mod fires DeathMsg -> amxx notifies all your plugins.
If you add an extra forward: mod fires DeathMsg -> amxx notifies your main plugin -> the main plugin fires the new forward
__________________
HamletEagle is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 05-04-2019 , 04:59   Re: Registering events vs forwards
Reply With Quote #4

I was under the impression that registering an event over and over, but now that you have mentioned it. I can't even recall why I was thinking that way.
__________________
Spirit_12 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:39.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode