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

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

handlers and concurrency

Postby rav » 07 Jun 2011, 11:13

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: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 07 Jun 2011, 16:19

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

Postby rav » 08 Jun 2011, 05:21

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: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 08 Jun 2011, 08:08

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

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 88 guests