Comments (11)
How would this affect plugins that already hook and do massive computations on onupdate? Is the extra time for this implementation linear or exponential?
from terrariaapi-server.
I guess it should be noted that I am all for a better system, so long as the code is portable between updates (aka we just need to add one-two lines in the new source to invoke the hook etc)
from terrariaapi-server.
I suppose he's got a point though - plugins aren't going to work out of the box anyway.
from terrariaapi-server.
How would this affect plugins that already hook and do massive computations on onupdate? Is the extra time for this implementation linear or exponential?
Wouldn't affect them at all. It's just the call to the handler which takes a very bit more performance than before, the code that is eventually executed by the handler will have no difference in performance. It's basically as with the current implementation, the more handlers register with a hook, the more performance is consumed for each invoke of those, this implementation takes maybe a few nanosecs more processing time for each handler invoke than the current implementation - the overhead is very low and will have no notable effect as long as a hook with maybe 20 handlers is not called 1000 times in one game frame or so.
I guess it should be noted that I am all for a better system, so long as the code is portable between updates (aka we just need to add one-two lines in the new source to invoke the hook etc)
Yes, good point. The Invoke methods should therefore be implemented so that hook invocations are as simple as possible, thus except for a different syntax this design then wouldn't make a difference to the current implementation. In comparison it would be looking like this:
if (NetHooks.OnGetData(ref num2, this, ref index1, ref length))
return;
vs
if (PluginAPI.Hooks.InvokeNetGetData(ref num2, this, ref index1, ref length))
return;
So whether a hook is invoked or handlers are registered, it's basically always just one line change. I've also designed it so that adding new hooks is pretty straight forward too.
By the way, another advantage of this system is that it could also deregister all handlers of a plugin automatically when the plugin disposes.
from terrariaapi-server.
π
Lucas Nicodemus via Web
On Sat, Aug 3, 2013 at 1:28 AM, CoderCow [email protected] wrote:
How would this affect plugins that already hook and do massive
computations on onupdate? Is the extra time for this implementation linear
or exponential?Wouldn't affect them at all. It's just the call to the handler which takes
a very bit longer than before, the code that is eventually executed by the
handler will have no difference in performance. It's basically as with the
current implementation, the more handlers register with a hook, the more
performance is consumed for each invoke of those, this implementation takes
maybe a few nanosecs more processing time for each handler invoke than the
current implementation - the overhead is very low and will have no notable
effect as long as a hook with maybe 20 handlers is not called 1000 times in
one game frame or so.I guess it should be noted that I am all for a better system, so long as
the code is portable between updates (aka we just need to add one-two lines
in the new source to invoke the hook etc)Yes, good point. The Invoke methods should therefore be implemented so
that hook invocations are as simple as possible, thus except for a
different syntax this design then wouldn't make a difference to the current
implementation. In comparison it would be looking like this:if (NetHooks.OnGetData(ref num2, this, ref index1, ref length))
return;vs
if (PluginAPI.Hooks.InvokeNetGetData(ref num2, this, ref index1, ref length))
return;So whether a hook is invoked or handlers are registered, it's basically
always just one line change. I've also designed it so that adding new hooks
is pretty straight forward too.By the way, another advantage of this system is that it could also
deregister all handlers of a plugin automatically when the plugin disposes.β
Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-22051197
.
from terrariaapi-server.
Alright, I'll prepare a PR for this then, guess another branch for this would be wise?
from terrariaapi-server.
Yes, but if we need to we can always use git fetch and pull your changes directly. Just keep the fork updated and public and such.
from terrariaapi-server.
There we go, first implementation done:
https://github.com/CoderCow/TerrariaAPI-Server/tree/1.14
Needs a lot of testing of course, I'll probably port TShock and some other plugins to 1.14 to see how it runs.
Feel free to tell me what you think about the code at all and how I can improve it.
from terrariaapi-server.
TShock on 1.14, runs fine:
https://github.com/CoderCow/TShock/tree/api_1.14
from terrariaapi-server.
Noblesse oblige. I await your pull request.
Lucas Nicodemus via Web
On Tue, Aug 6, 2013 at 1:58 PM, CoderCow [email protected] wrote:
TShock on 1.14, runs fine:
https://github.com/CoderCow/TShock/tree/api_1.14β
Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-22206534
.
from terrariaapi-server.
This code was added, so I'm closing this pull request.
from terrariaapi-server.
Related Issues (17)
- Switch to async sockets on Mono
- API version HOT 3
- Remove fields/etc that are un-necessary for server-side functionality HOT 3
- -ip is missing
- plugins fail to load HOT 6
- Blue Flare HOT 1
- Quick question HOT 1
- Remove travis CI support HOT 3
- Allow headless servers
- can you support multi languageοΌ
- Missing code?? HOT 4
- PriorityClass mono incompatibility
- Contribute HOT 2
- NPC Spawn Event not returning position. HOT 15
- syncJoin exception HOT 5
- Random server freezes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terrariaapi-server.