vibe.d 0.7.9 released

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Thu Nov 1 14:52:17 PDT 2012


On Thu, 01 Nov 2012 19:53:37 +0100
"Rob T" <rob at ucora.com> wrote:
> 
> I'm also wondering how the co-routines are working out with vibe? 
> I thought of using them, but my current design will be using 
> message passing instead, where the code is broken up into small 
> parts to perform the co-processing. When messages are received at 
> a location, the code fragment executes. I've done this before in 
> C++ and it worked great, but with D I now have an alternative 
> using fibers, but I have no exerience with using them.
> 

Personally, I think the fibers/coroutines are working out great for it.
The cool thing about the way vibe.d is designed is you really don't
even notice that you're using fibers. It's pretty much all handled
behind-the-scenes. You just give it your callbacks and don't worry
about how they get called. So it feels more like a
simplified message-passing. You rarely deal with the fibers/coroutines
yourself unless you want to.

About the only big thing to be careful of, in my experience, is
remembering not to reuse the same open connection (to a DB or other
server, for example) across different requests without using the
built-in connection pool stuff.

And similarly, you may want to be careful about updating global state
(because while globals are *thread*-local by default in D, they're
*NOT* fiber-local). But that's a LOT easier to deal with than writing
*thread*-safe code with shared state because unlike threads, the fiber
switches can only happen in very specific places (when you use vibe.d's
async I/O or manually yield the fiber yourself). So just don't do IO or
call yield in the middle of an atomic global-state update (or just
don't use global state), and you're golden.



More information about the Digitalmars-d-announce mailing list