How can i make my cloud code thread safe? is there any lock mechanism for part of code?
Best Answer
U
Ufuk Coban
said
over 6 years ago
Spark.LockKey :-) it says;
Creates a lock on an arbitrary key. Whilst the script ‘owns’ this lock no other script can lock on the same key, and will be blocked until the lock is released.
if 2 players call the same script at the same time will just one of them get this lock? it looks lock is per script, it is not per thread/request. Or i misunderstand it because of my poor English.
Creates a lock on an arbitrary key. Whilst the script ‘owns’ this lock no other script can lock on the same key, and will be blocked until the lock is released.
if 2 players call the same script at the same time will just one of them get this lock? it looks lock is per script, it is not per thread/request. Or i misunderstand it because of my poor English.
D
David Brandes
said
over 6 years ago
I have a question regarding Spark.LockKey()
This locks the key per request or provides a unique mutex? I mean, does the lock fail when I try to get it twice in the same script?
D
David Brandes
said
over 6 years ago
Sorry to answer myself.
var mutex = Spark.lockKey("foo", 0);
var mutex2 = Spark.lockKey("foo", 0);
Ufuk Coban
How can i make my cloud code thread safe? is there any lock mechanism for part of code?
Spark.LockKey :-) it says;
Creates a lock on an arbitrary key. Whilst the script ‘owns’ this lock no other script can lock on the same key, and will be blocked until the lock is released.
if 2 players call the same script at the same time will just one of them get this lock? it looks lock is per script, it is not per thread/request. Or i misunderstand it because of my poor English.
2 people have this question
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstUfuk Coban
Spark.LockKey :-) it says;
Creates a lock on an arbitrary key. Whilst the script ‘owns’ this lock no other script can lock on the same key, and will be blocked until the lock is released.
if 2 players call the same script at the same time will just one of them get this lock? it looks lock is per script, it is not per thread/request. Or i misunderstand it because of my poor English.
David Brandes
I have a question regarding Spark.LockKey()
This locks the key per request or provides a unique mutex? I mean, does the lock fail when I try to get it twice in the same script?
David Brandes
Sorry to answer myself.
In this case both mutex variables are true.
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics