Jump to content

concurrency ?


DarkLink

Recommended Posts

Hi there guys, I have one question in mind .

Does server scripts manage concurrency ?

Example, on server script there is a var like x = 2

I mean, two client at the same time try to acess a function on a server side script and both try to decrement that var, it would like x = 0 if server manage concurrency like a locks on java.

But if server doesnt support concurrency on blocks, and they try to decrement x at the same time, it will appear x = 1, caused by a dirty read.

My question is, how this works on MTA ?

I am out of MTA for a few months, and when we came back to Lua coming from Java its kinda weird x)

Thanks alot in advance.

Link to comment

Hmm I see, thanks for your reply.

Thats fine, but look if two clients do the same operation (trigger the same event to serverside), what will happen if that is a critic zone ? that I want only one client executing at same time ? do you understand?

Thats why we use synchronized on java, I am asking how Lua on mta handle this..

Thanks in advance guys

Link to comment

I'm not quite sure if I understood you correctly, but I think you are talking about problems with a multithreaded environment.

As far as I know MTA handles the scripting part in one single thread. Therefore it would be (for the server):

Global Var x = 2

Client A triggers the event.

Client B triggers the event.

Server Recognizes the Event of Client A

Function is executed

x is now 1

Server Recognizes the Event of Client B

Function is executed

x is now 0

Link to comment

Yes you are close dude, thanks for your reply.

But still didnt got fully clarified.. clients are individual threads right?

So how do I make a piece of code only executed by one client at a time ?

Do u understand ? LOCK the method/function, synchronized methods on java.

Thanks.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...