|
|
|
|
#1 |
|
Beta Tester
![]() ![]() ![]() ![]() ![]() Join Date: Jun 2008
Location: 629
Posts: 13,235
Reputation: 1900
|
I think this may literally be the ultimate callback hooking method EVER! Those of you who write libraries should know about ALS:
pawn Code:
This chunk of code allows people to use "OnGameModeInit" in multiple scripts, so that library writers don't need to worry about people correctly calling their setup functions. This works quite well but it's VERY cumbersome, as a result "y_hooks" was developed: pawn Code:
This is VASTLY nicer code to read and write, but it is slower than ALS - this is part of YSI but the YSI libraries themselves don't actually use it for speed reasons. However the other day I was contacted by JoeBullet/Google63 about the use of the "SCTRL" OpCode to modify the current instruction pointer which I combined with existing knowledge of the AMX data structure to create the ULTIMATE callback hook system. This is nicer than y_hooks (or the old y_hooks, this is an update) and MUCH faster than ALS (no benchmarks available): pawn Code:
That is now it! This completely bypasses CallLocalFunction, which is where the speed comes from, and you don't even need to define a prefix as with the old version (unless you have multiple versions of a single callback in one file). Note that the old syntax still works. If you are interested the code is here, but note also that you can't compile it because it uses some new libraries I've not released yet. The interesting code is lines 60-297, everything beyond that is just the same thing over and over and over again! http://pastebin.com/KHtzcWVf Note that you will need to get YSI from SVN - the official version hasn't been updated yet because I'm working on some big things! Last edited by Y_Less; 19/03/2011 at 12:24 AM. |
|
|
|
|
|
#2 |
|
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Mar 2008
Location: USA - California
Posts: 1,024
Reputation: 260
|
Dude, you're amazing man! This is really awesome, i can now stop being so hesitant to hook callbacks now.
Really nice idea, thank both you and google63. |
|
|
|
|
|
#3 |
|
Beta Tester
![]() ![]() ![]() ![]() ![]() Join Date: Jun 2008
Location: 629
Posts: 13,235
Reputation: 1900
|
I just did some basic test which put this at around 10x faster than the old y_hooks system, however it is only just faster than ALS - as in almost not faster:
Code:
1514 - New 15371 - Old 1732 - ALS |
|
|
|
|
|
#4 |
|
Big Clucker
![]() ![]() Join Date: Feb 2011
Posts: 146
Reputation: 7
|
what does this do? I mean, it's function...
|
|
|
|
|
|
#5 |
|
Banned
![]() Join Date: Apr 2007
Location: Republic of Ireland
Posts: 4,307
Reputation: 350
|
It allows you to hook callbacks easily and with better performance than previous callback hooking methods, this page gives a fairly good explanation of what you would need to use a callback hook for.
http://forum.sa-mp.com/showthread.php?t=166016 |
|
|
|
|
|
#6 | |
|
Beta Tester
![]() ![]() ![]() ![]() ![]() Join Date: Jun 2008
Location: 629
Posts: 13,235
Reputation: 1900
|
It's basically a development tool for library writers. Take this library for example:
http://forum.sa-mp.com/showthread.php?t=240436 Quote:
pawn Code:
If they were to define the function as: pawn Code:
That would instantly remove the need for the user to have to manually call the function, so then you and they don't need to worry about it. Also, the code for this is on the YSI SVN so if you do want to use it you can get a working copy from there: Address: https://dedi.y-less.com/svn/ysi Username: public Password: public That won't let you upload, but if you want to upload just ask me for an upload account. |
|
|
|
|
|
|
#7 |
|
Guest
Posts: n/a
|
Very nice efficient and fast, thanks
|
|
|
|
#8 |
|
Godfather
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Mar 2008
Posts: 5,609
Reputation: 377
|
Good job, you finally made it faster! You always impress me with your marvelous work.
This thing is really something new and hard for me to understand. Keep on releasing more and more and impress people! |
|
|
|
|
|
#9 |
|
Godfather
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2009
Location: England
Posts: 6,540
Reputation: 697
|
Brilliant, time to try understand how you've done it and time to abuse it in a million includes I plan to make.
|
|
|
|
|
|
#10 |
|
Big Clucker
![]() ![]() Join Date: Mar 2011
Posts: 50
Reputation: 2
|
i downloaded YSI and i found y_hooks in the folder
thats it?? i mean thats the right include?? |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| is there any callback for ..... | MrIncredible | Help Archive | 4 | 15/03/2010 04:52 AM |
| Callback | Bomber | Help Archive | 4 | 04/03/2010 08:08 PM |
| Is there such callback as | JoeDaDude | Help Archive | 12 | 21/01/2010 05:29 PM |