Hello.
Can I use synchronized or reentrantlock in smartfox, if so, where store objects of locks, and if not then what alternative solution to this problem? Thx.
Synchronized or ReentrantLock in smartfox?
Re: Synchronized or ReentrantLock in smartfox?
Hi,
of course you can.
It mostly depends on what your code does and the scope of your lock(s).
Maybe you could give us more details as to what you're trying to do?
of course you can.
if so, where store objects of locks, and if not then what alternative solution to this problem? Thx.
It mostly depends on what your code does and the scope of your lock(s).
Maybe you could give us more details as to what you're trying to do?
Re: Synchronized or ReentrantLock in smartfox?
I have game rooms. After the game in the same room to move players to other rooms(if other rooms have free place), this operation must be performed for every room synchronized. I find Singleton solution and use it. What do you think is a good solution?
Re: Synchronized or ReentrantLock in smartfox?
I am not sure why moving a User from a Room to another Room should be synchronized. The operation is already thread safe.
Re: Synchronized or ReentrantLock in smartfox?
For example:
Have 2 rooms,
Room1 - 8 players
Room2 - 9 players
Room1 end game, and 6 players leave the game, 2 players must be moved to other room - Room2. At that time Room2 also end game, and can move users. So, movement must be held in a queue and can not execute multiple threads simultaneously
Have 2 rooms,
Room1 - 8 players
Room2 - 9 players
Room1 end game, and 6 players leave the game, 2 players must be moved to other room - Room2. At that time Room2 also end game, and can move users. So, movement must be held in a queue and can not execute multiple threads simultaneously
Re: Synchronized or ReentrantLock in smartfox?
I am not sure I entirely understand the use case, but in any case I don't think you need any Singleton to do what you're asking.
If you're joining users in Rooms you must be working at Zone level, therefore you can keep references to your lock objects in the Zone Extension, which is a global object if you will.
If you're joining users in Rooms you must be working at Zone level, therefore you can keep references to your lock objects in the Zone Extension, which is a global object if you will.
Re: Synchronized or ReentrantLock in smartfox?
Rooms can finish the game at a time and begin to move the players to each other, in this case, instead of merging the rooms (if possible) will exchange players or some players will be moved, and some - not. Each room should conduct this operation successively.
I tried to use a zone setProperty and getProperty, but in this case getting ClassCastException after reload extension.
And if create objects in the Zone, then the reload they will be re-created.
I tried to use a zone setProperty and getProperty, but in this case getting ClassCastException after reload extension.
And if create objects in the Zone, then the reload they will be re-created.
Re: Synchronized or ReentrantLock in smartfox?
You always have the option to use the extensions/__lib__/ folder avoid class loading options, but you will have to restart the server to reload changes in the re-deployed code.
http://docs2x.smartfoxserver.com/Advanc ... assLoading
cheers
http://docs2x.smartfoxserver.com/Advanc ... assLoading
cheers
Who is online
Users browsing this forum: Google [Bot] and 100 guests