Page 1 of 1

handlers and concurrency

Posted: 07 Jun 2011, 11:13
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

Posted: 07 Jun 2011, 16:19
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

Posted: 08 Jun 2011, 05:21
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

Posted: 08 Jun 2011, 08:08
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.