[concurrency-interest] ForkJoinPool for async http calls?

√iktor Ҡlang viktor.klang at gmail.com
Thu May 10 14:17:07 EDT 2012


On Thu, May 10, 2012 at 7:45 PM, Zhong Yu <zhong.j.yu at gmail.com> wrote:

> On Thu, May 10, 2012 at 12:13 PM, √iktor Ҡlang <viktor.klang at gmail.com>
> wrote:
> >
> >
> > On Thu, May 10, 2012 at 7:07 PM, Zhong Yu <zhong.j.yu at gmail.com> wrote:
> >>
> >> On Thu, May 10, 2012 at 10:26 AM, Christian Essl
> >> <christianessl at googlemail.com> wrote:
> >> > Your are right my primary concern is code-simplicity not pure
> >> > performance, basicly writing in a traditional imperative blocking
> >> > style but still having IO with (mostly) non-blocking threads (and no
> >> > callbacks, no monadic futures).
> >>
> >> Thread is such a nice programming abstraction, it's a shame that we
> >> are so concerned of its overhead nowadays. Replacing simple threads
> >> with complex tasks seems to be retrogressing - aren't programming
> >> supposed to become easier?
> >>
> >> What are the fundamental reasons that Java Threads are expensive?
> >
> >
> > Can you give some arguments as to the greatness of proactive programming
> > (threads)?
>
> It just seems straightforward to me to write and read
>
>    for(i=0;i<10;i++)
>    {
>        result = db.query( q[i] );  // blocking
>        s = format(result);
>        out.write( s );  // blocking
>    }
>    out.write("done") // blocking
>

Something like this should work:

sequence {
  q map db.query flatMap { result => out write format(result) }
} foreach {
  _ => out write "done"
}

Cheers,
√


> Now convert it to async style - it's not rocket science hard, but at
> least it's quite a chore.
>
> Zhong Yu
>



-- 
Viktor Klang

Akka Tech Lead
Typesafe <http://www.typesafe.com/> - The software stack for applications
that scale

Twitter: @viktorklang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20120510/4d2c588a/attachment.html>


More information about the Concurrency-interest mailing list