[Plugin] ThreadedCMD
#1

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
Reply
#2

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.
Reply
#3

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.
Reply
#4

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.
Reply
#5

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.
Reply
#6

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 ...
Reply
#7

Links updated, added mutex method support.
Reply
#8

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

Where are threads

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

***** is indeed right.
Reply
#10

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

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.
Reply
#12

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).
Reply
#13

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
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)