FiberManager

27 views
Skip to first unread message

Blue God

unread,
Jul 9, 2011, 3:56:39 PM7/9/11
to jetlang-dev
Hi Mike,

I'm not sure if I have understood how jetlang pool fibers work
therefore wondering if you can let me know if I am on the right path.

I will be writing an app, that will have one listener which will be
waiting on multiple topics. When the listener is called, it will post
a message to the jetlang channel and then one of the fibers (if I had
used PoolFiberFactory) would process the message. Therefore, incoming
messages would be handled by a pool of Fibers.

But, it seems to be that when you do fiberFactory.create() this only
creates one Fibre. So when you send a message to the channel only one
Fiber will ever process the message.

It seems like I will need to write some kind of FiberManager that upon
receiving a message would pass it onto one of a pool of Fibers.

Is my understanding of this correct?

Mike Rettig

unread,
Jul 9, 2011, 4:05:16 PM7/9/11
to jetla...@googlegroups.com
A PoolFiber and a ThreadFiber have the same behavior. If the fiber is
subscribed to a channel, it will receive all messages posted to that
channel.

It sounds like you want a queue that is serviced by multiple threads.
The Executors class in the jdk is a better choice for this type of
problem. It allows you to create a simple task queue and the configure
the number of threads that will service the queue.

http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Executors.html

If you need the stateful, single threaded behavior of a fiber, then
you will need to write the fiber manager that distributes the events
to each of the fibers.

Mike

> --
> You received this message because you are subscribed to the Google Groups "jetlang-dev" group.
> To post to this group, send email to jetla...@googlegroups.com.
> To unsubscribe from this group, send email to jetlang-dev...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/jetlang-dev?hl=en.
>
>

Blue God

unread,
Jul 9, 2011, 6:05:48 PM7/9/11
to jetlang-dev

Good point, I don't need to keep state for the first service I need
to write, therefore will look at Executors.
But, work coming up will require need to keep state then I will look
into writing some kind of FibreManager then.

thanks, for your quick response

Nesh


On Jul 9, 9:05 pm, Mike Rettig <mike.ret...@gmail.com> wrote:
> A PoolFiber and a ThreadFiber have the same behavior. If the fiber is
> subscribed to a channel, it will receive all messages posted to that
> channel.
>
> It sounds like you want a queue that is serviced by multiple threads.
> The Executors class in the jdk is a better choice for this type of
> problem. It allows you to create a simple task queue and the configure
> the number of threads that will service the queue.
>
> http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Exe...
Reply all
Reply to author
Forward
0 new messages