handlers and concurrency

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Post Reply
rav
Posts: 82
Joined: 06 Dec 2010, 13:14

handlers and concurrency

Post by rav »

Is it right that handlers ('someClasses extends BaseClientRequestHandler') doesn't supports cuncurrency on sfs level? As I understand all requests from users just pushed into some queue for this handler and processed consequentially

And does 'someClasses extends BaseServerEventHandler' supports cuncurrency? Seems that yes
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Doesn't support concurrency? What do you mean exactly?
Can you elaborate?
Also we explain all details about extension concurrency here:
http://docs2x.smartfoxserver.com/Advanc ... extensions
Lapo
--
gotoAndPlay()
...addicted to flash games
rav
Posts: 82
Joined: 06 Dec 2010, 13:14

Post by rav »

Lapo wrote:Doesn't support concurrency? What do you mean exactly?
Can you elaborate?
F.e. there is a class:

Code: Select all

class FirstHandler extends BaseClientRequestHandler
{
    @Override
    public void handleClientRequest(User user, ISFSObject isfso)
    {
          trace("begin");
          doSomeLongOperation();
          trace("end");
    }
}
if two users (or even one user) approximately at the same time call FirstHandler output will be:

begin
end
begin
end

so requests from clients are processed sequentially

Code: Select all

class SecondHandler extends BaseServerEventHandler
{
    @Override
    public void handleServerEvent(ISFSEvent event)
    {
          trace("begin");
          doSomeLongOperation();
          trace("end");
    }
}
in this case output will be:

begin
begin
end
end

so server events are processed concurrently
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Yes, concurrency of your logic is up to you, of course :)
And yes the server is highly concurrent, so sections of your code that need to be executed with mutual exclusion must be synchronized.
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply