users@grizzly.java.net

Re: LinuxSpinningWorkaround & managing connections

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Wed, 23 Sep 2009 16:28:09 -0400

Salut,

Alexei Dets wrote:
> Hi!
>
> Can anybody please give me some advice about the ways of managing/tracking
> connections (application specific state attached to connection) in Grizzly
> framework in light of introduction of LinuxSpinningWorkaround?
>
> What I mean is that I know only 3 ways of doing this and none of them works:
> 1. Most simple and common: attach some context to SelectionKey. Doesn't work
> because of ParserProtocolFilter - it removes attachment.

Use ThreadAttachement instead:

   * http://is.gd/3BKTx

with WorkerThread

   * http://is.gd/3BKS3


> 2. Create some map (list, set etc.) that holds information about the
> SelectionKey and its associated context. Doesn't work anymore after
> introduction of LinuxSpinningWorkaround - SelectionKey can be invalidated
> at any time and so information in the map (list, set etc.) will be stale.
> 2. Create some map (list, set) etc. that holds information about the
> SelectableChannel and its associated context. Doesn't work anymore after
> introduction of LinuxSpinningWorkaround - in general it is not possible to
> get a SelectionKey for the SelectableChannel (the key you'll get can be
> invalidated right away by LinuxSpinningWorkaround in another thread before
> you'll be able to do anything with it).
>
> I'm lost... :-(
>

Take a look at the ThreadAttachement API. I'm sure that will meet your
needs.

A+

--Jeanfrancois

> Alexei
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>