What happends if...
#1

What happends if I use a global variable, and then I use that variable in two commands, and two players tipe a command at the same time, the variable would be bugged?
Reply
#2

It is very very (very) unlikely that they type it at exactly the same time, there will always be at least 10ms difference.
Even if they should get it done, pawn is only single-threaded, meaning, the two command requests will be processed one after the other, so the variable will get the value of the last processed request.

So no fear, there will be no problems
Reply
#3

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
It is very very (very) unlikely that they type it at exactly the same time, there will always be at least 10ms difference.
Even if they should get it done, pawn is only single-threaded, meaning, the two command requests will be processed one after the other, so the variable will get the value of the last processed request.

So no fear, there will be no problems
Thanks!
Reply
#4

The situation you mentioned is generally called a "race condition". You can read more about it at http://en.wikipedia.org/wiki/Race_condition

Usually OOP solves some of the problems, as each objects can have their own state controllers without the need of using globals, but that's just a theory not usable in Pawn. I'd suggest you digging deeper on the article i pasted.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)