Advice on using Fibers?

Is there any time when you would use Fibers instead of Threads? I'm familiar with threads, I have used them in applications I've written for my office and even built a class to manage them inline with my programming style. I've done some reading, no actual programming yet, and I can't see where you would use a Fiber instead of a Thread except maybe when writting for a legacy system. Does anyone have any input on this?

I've taught myself C++ for those of you who don't know so forgive me if this is a silly question :p
Last edited on
closed account (z05DSL3A)
Is there any time when you would use Fibers instead of Threads?

Aren't fibers ran in threads? I think they are to help you port software that dose its own scheduling. Probably not much use over a well design multithreaded app.
I remember using a similar approach at least once in a game for handling the AI of all computer-controlled actors in a single thread.

But yeah, fibers aren't used (or needed) very often in my experience.
@ Greay Wolf: That's a good point, they would have to be run within Threads wouldn't they? I shudder to think about your second sentence, I know those applications exist out there and it drives me crazy.

@Athar: So you stacked the Fibers in a Thread? How did that turn out?

Thanks guys this probably saved me an afternoon.
@Athar: So you stacked the Fibers in a Thread? How did that turn out?

It was quite a while ago, but I think it worked nicely. When one AI instance decided it took too long to make a decision, it would yield prematurely to avoid stalling the others.
Still, with today's multi-core CPUs I'd choose a different approach now, like moving all expensive operations (like pathfinding) to one or several worker threads.
Topic archived. No new replies allowed.