Alex Rivera | Logout

Design Pattern Alternative to Coroutines

Asked 2009-08-23T19:24:25.837
12

Currently, I have a large number of C# computations (method calls) residing in a queue that will be run sequentially. Each computation will use some high-latency service (network, disk...).

I was going to use Mono coroutines to allow the next computation in the computation queue to continue while a previous computation is waiting for the high latency service to return. However, I prefer to not depend on Mono coroutines.

Is there a design pattern that's implementable in pure C# that will enable me to process additional computations while waiting for high latency services to return?

Thanks

Update:

I need to execute a huge number (>10000) of tasks, and each task will be using some high-latency service. On Windows, you can't create that much threads.

Update:

Basically, I need a design pattern that emulates the advantages (as follows) of tasklets in Stackless Python (http://www.stackless.com/)

  1. Huge # of tasks
  2. If a task blocks the next task in the queue executes
  3. No wasted cpu cycle
  4. Minimal overhead switching between tasks
Edit
Report

1 Answer

1

Writing it to use Async IO might be sufficient.

This can lead to nasy, hard to debug code without strong structure in the design.

answered 2009-08-23T19:45:46.633

Your Answer