users@grizzly.java.net

Re: WG: Re: WG: Re: WG: Re: Asynchronous Request Processing with TCPIP

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Mon, 07 Jul 2008 21:08:03 -0400

Salut,


John ROM wrote:
> Hi Jeanfrancois,
>
>> Why do we need to synchronize here? I think as soon as you invoke the
>> suspend method, the developer should take care of making a single thread
>> is manipulating the new object.
>
> maybe I am just misusing the concept.

No maybe it's my implementation that is wrong :-)

>
> When I suspend a Context I want to say no one should recycle Context
> until Context.resume is called.

Yes.

>
>
> So what can happen is :
>
> Business Thread calls Context.resume() and then line
> isSuspended = false;
>
> and now scheduler makes WorkThread the current Thread so
>
> WorkThread calls ContextTask.recycle.isSuspended() which is false and
> now both recycle ... which is not good (-:

OK but when you said Business Thread, it is the Grizzly Thread? Let's
say I have:

WorkerThread_1 call Context.suspend();

Hence here the Context will not be recycled. Now let's say we have
another thread, let's say AThread_1, which call Context.resume(). If
AThread_1 does:

Context.resume();
Context.get/set/ do something

Then I agree this is a problem. Hence I guess I need to improve the
documentation and make sure we warn the user to not do any operation
after calling the resume();


>
> On the other hand in my protocol many business Threads might use the same
> Context because many messages can be in one byteBuffer and in my code I might
> be calling resume() twice or more times on the same context.

Haa ha! Then I agree we have a problem with the current implementation.
Maybe we should just not recycled the object when calling resume()
then...I suspect that will be error prone if we recycle the object. What
do you think?

To recap: the best solution would consist of *never* recycling the object.


>
> I do not want that continuousExecution Logic is changed because I like the
> performance I gain by staying on the same WorkerThread and calling
> ReadFilter again.....

Me too.


>
> So maybe I should stick to copying Context....
>
>
> Was I able to explain my usecase?

That was great!

Thanks!!

-- Jeanfrancois

>
> Many Greetings
> John
>
>
>
>