[REL] Threaded Fread & Fwrite plugin -
JernejL - 28.09.2011
This is a THREADED Fread / Fwrite plugin.
When you use fread / fwrite in pawn directly, if a file is being read by another external program, or hdd writing is slow or file IO is under a strain, you will end up losing some miliseconds in server sync due to file system locking to accomodate the underlying safety mechanisms in order to ensure a stable file transaction.
This can become painfully obvious if you still use text files to store accounts. I know that on a few very popular servers this problem can take whole seconds to finish - imagine a random up to 1 second ini file reading lag on the server whenever a player joins - same can happen during leaving & writing data to account.
This plugin allows you to write data to file without this waiting delay, so you can "shove" out large amouts of data without any problems.
Reading is also done without any locking - the thread will load the data you desire and pass it to your callback.
The main purpose of the plugin is basically.. outputing a lot of data to text files without lagging the script.
Natives:
pawn Код:
native ThreadW(file[], text[]);
native ThreadR(file[], callback[], beginoffset = 0, extraid = -1);
Download .inc, win32 dll and linux 32bit .so:
http://www.mathpudding.com/temp/rwthread.rar
Download source code:
http://www.mathpudding.com/temp/rwthread_src.rar
Example usage:
Quote:
forward readwholetext(texts[], extraid);
public readwholetext(texts[], extraid) {
printf("received from thread: \"%s\" extraid: %d.", texts, extraid);
}
ThreadW("scriptfiles/test.txt", "TEXT MEEEEEE\n");
ThreadW("scriptfiles/test.txt", "LINE 2\n");
ThreadW("scriptfiles/test.txt", "MOAR LINES\n");
ThreadR("scriptfiles/test.txt", "readwholetext", 5); // read everything in this file starting at 5 bytes offset.
|
NOTE that this is still a very untested plugin, if you intend to use it make sure you understand what it is for and that it might screw things up for you - i cannot and will not take any responsibility for lost data because of this plugin.
Additionally - thanks to BlueG for his work on threads in his mysql plugin. This plugin is based on his work.
Re: [REL] Threaded Fread & Fwrite plugin -
Scott - 28.09.2011
Great job!
Re: [REL] Threaded Fread & Fwrite plugin -
Phanto90 - 28.09.2011
Nice! I've not tested it but if it works good as threaded queries then good job.
Re: [REL] Threaded Fread & Fwrite plugin -
CJ101 - 28.09.2011
Awesome that we finally have something like this. Me likes.
OT: does it feature turtles?
Re: [REL] Threaded Fread & Fwrite plugin -
JernejL - 28.09.2011
Turtle plugin is still work in progress.
Re: [REL] Threaded Fread & Fwrite plugin -
GhoulSlayeR - 28.09.2011
Good work, i'll run the usual tests later.
Re: [REL] Threaded Fread & Fwrite plugin -
Babul - 28.09.2011
oh, thats exactly what i need. i AM using the native functions to store data - i will definetly give it a intensive test-drive at the weekend. thank you!
question: is there a chance that you add a function to get all entries of a directory? it would come in handy for getting all race files existing. the way i do it by storing all saved races in another file, can be a pain...
edit: i encountered some problems at scaninng files like a "fake directory" with unknown size. some files are >2000 chars in size, f.ex using 50 race names. i cant figure out how to parse them properly coz all data gets put into a huge string instead of the chance to fread 50 lines >-<
Re: [REL] Threaded Fread & Fwrite plugin -
olaf137 - 29.09.2011
You could use sscanf to unformat the large string.
Re: [REL] Threaded Fread & Fwrite plugin -
HyperZ - 29.09.2011
Nice work.
AW: Re: [REL] Threaded Fread & Fwrite plugin -
Meta - 01.10.2011
Quote:
Originally Posted by Babul
question: is there a chance that you add a function to get all entries of a directory? it would come in handy for getting all race files existing. the way i do it by storing all saved races in another file, can be a pain...
|
I'm sorry for being that kind of bastard, but I have to say that this is scriptable and I already made it
If you're interested, contact me.
Re: [REL] Threaded Fread & Fwrite plugin -
vyper - 01.10.2011
This looks nice
Re: [REL] Threaded Fread & Fwrite plugin -
QuaTTrO - 09.10.2011
This is awesome

now server will be not lag when i save a file
Re: [REL] Threaded Fread & Fwrite plugin -
AirKite - 10.10.2011
Nice!
Re: [REL] Threaded Fread & Fwrite plugin -
Richie© - 03.04.2012
Thanks for this plugin, alot of stuffs are beeing writed to log files in my server and this really was a good upgrade from fwrite
Re: [REL] Threaded Fread & Fwrite plugin -
AirKite - 06.04.2012
Where Threaded for Fwrite?
Code:
native ThreadW(file[], text[]);
native ThreadR(file[], callback[], beginoffset = 0, extraid = -1);
example ThreadW(file[], text[],
callback[], extraid = -1);
Re: [REL] Threaded Fread & Fwrite plugin -
Niko_boy - 07.04.2012
it is epic,
Love ya mr. turtle
Re: [REL] Threaded Fread & Fwrite plugin -
PGaming - 16.05.2018
Link is down, please update the link.
Re: [REL] Threaded Fread & Fwrite plugin -
PgMNA - 29.05.2018
update download link pls.
Re: [REL] Threaded Fread & Fwrite plugin -
QuaTTrO - 29.05.2018
I dug up my old HDD and found only Win32 version from 29.09.2011.
Re: [REL] Threaded Fread & Fwrite plugin -
iRc97 - 07.08.2018
Quote:
Originally Posted by QuaTTrO
I dug up my old HDD and found only Win32 version from 29.09.2011.
|
You have the plugin but in version .so?