Jump to content

concurrency ?


DarkLink

Recommended Posts

Posted

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.

Posted

I am not sure I got you right..

But if 2 clients use event triggering to serverside to handle decrementation of a variable then it will happen twice (because 2 clients do it)

To avoid this, you'll need to use dictionary tables

Posted

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

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