SA-MP Forums Archive
[Plugin] ThreadedCMD - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Plugin Development (https://sampforum.blast.hk/forumdisplay.php?fid=18)
+--- Thread: [Plugin] ThreadedCMD (/showthread.php?tid=394160)



ThreadedCMD - BJIADOKC - 21.11.2012

Hi everybody.

I decided to wrote a new plugin, it's just a command processor for SA-MP server, but Threaded.
It works like zcmd, plugin calls callbacks with params, but now, there is additional arg, where params len stored.
It is not faster than zcmd or YCMD (because working with ProcessTick), but it free's some time in PAWN thread.

Usage:

It's simple, just add include and plugin to your server and make new commands!
PHP код:
TCMD:test(playeridparams[], params_len)
{
    if(!
params_len// We haven't got params
    
{
        
SendClientMessage(playerid, -1"Test without params!");
    }
    else
    {
        new 
string[128]; // 128 because PAWN don't support dynamic arrays, :(
        
format(stringsizeof string"Yahoo! Test with params %s, length is %d"paramsparams_len);
        
SendClientMessage(playerid, -1string);
    }
    return 
1;

Links

https://www.dropbox.com/s/jngfg6g88vnohsz/bin.zip - .dll + .so + .inc
https://www.dropbox.com/s/cn1oawqdj2v25nb/src.zip - Source code


Re: ThreadedCMD - BJIADOKC - 21.11.2012

Quote:
Originally Posted by ******
Посмотреть сообщение
You realise PAWN isn't thread safe right? Using ANY globals in this code will mess up, in fact I suspect using anything at all in here will mess up very quickly.
I'm executing commands from ProcessTick, code was tested, and these no random crashes.
If you doubt if the plugin efficiency, please, post some reasons why.


Re: ThreadedCMD - BJIADOKC - 21.11.2012

Quote:
Originally Posted by ******
Посмотреть сообщение
So if you're using ProcessTick, in what way is this threaded?
Look at the source code. Maybe it's awful, yeah. By the way, I will add mutexes in the next ver.


Re: ThreadedCMD - Dan.. - 21.11.2012

Quote:
Originally Posted by ******
Посмотреть сообщение
So if you're using ProcessTick, in what way is this threaded?
He thinks that the Pawn code is executed in one thread and plugins are executed in another thread.


Re: ThreadedCMD - BJIADOKC - 21.11.2012

Quote:
Originally Posted by Dan..
Посмотреть сообщение
He thinks that the Pawn code is executed in one thread and plugins are executed in another thread.
No, ProcessTick is the "syncronizer" above PAWN thread and another threads. This is the queue to AMX exec, if I right.


Re: ThreadedCMD - BJIADOKC - 21.11.2012

Quote:
Originally Posted by ******
Посмотреть сообщение
And by the way, what happens if you want to write "/process"? Having your native use the same format as valid commands seems like a very bad plan.
Ah, you're right. If i type /exec ...


Re: ThreadedCMD - BJIADOKC - 21.11.2012

Links updated, added mutex method support.


Re: ThreadedCMD - Crypt - 21.11.2012

To be honest i do agree with "Y" because there is no reason for threading.


Re: ThreadedCMD - Vinnyy - 23.11.2012

Where are threads

Damn, Vladoks, why you posted bad(noob) script?

***** is indeed right.


Respuesta: ThreadedCMD - Parka - 23.11.2012

but it's good the Plugin, this is secure, stable ?


Re: ThreadedCMD - Dan.. - 23.11.2012

Quote:
Originally Posted by ******
Посмотреть сообщение
There are threads there, I've read the code. And please don't outright call someone's code bad - you can express concerns and point out how it could be better, but don't insult them.
He may consider it bad code since the threads, in this case, aren't improving the performance of the server and it would have been better if he stuck to the KISS principle.


Re: ThreadedCMD - Vinnyy - 23.11.2012

Quote:
Originally Posted by Dan..
Посмотреть сообщение
He may consider it bad code since the threads, in this case, aren't improving the performance of the server and it would have been better if he stuck to the KISS principle.
That is right.

What mutexes doing in this program?

Only one thread.
Mutexes used in manythreads applications with sharing memory(critical sections).


Re: ThreadedCMD - BJIADOKC - 23.11.2012

Quote:
Originally Posted by Vinnyy
Посмотреть сообщение
That is right.

What mutexes doing in this program?

Only one thread.
Mutexes used in manythreads applications with sharing memory(critical sections).
POPs/PUSHes from/to queue are mutex-locked