Hi,

thank you both for your responses.

In the system I am building right now, the vibe.d thread serves as a network interface to a system that is doing its own stuff. The thread is created as a std.concurrency thread that calls processEvents() in its main loop to process vibe.d events.

When a request from network comes, it is translated to a command that the system understands and passed via std.concurrency.send to another thread that enqueues it for execution. The execution may take some time, depending on the number of commands already waiting for execution. That is why I need to "pause" the calling fiber, but let the entire thread to continue. Because other requests may be comming from outside and they also can be served faster as different commands take different execution time.

Currently I am doing it like this:

The vibe.d thread:

bool finish = false;
while (true)
{
  processEvents();

  std.concurrency.receiveTimeout
  (
    20.msecs,
    (CommandResponse response)
    {
      // Pass the response to the appropriate interface 
      // emit a ManualEvent there
    },
    (EventFinish e)
    {
      // ...
      finish = true;
    }
  );

  if (finish)
  {
    // ...
    break;
  }
}

The fiber that sends a command then just waits for the ManualEvent, checks if the response was intended for it and eventually processes it. If not, it just waits again.

The problem with this approach is that the event wakes all waiting fibers, whereas I would just like to wake only the correct fiber. I know which one it is, as it is part of the request/response messages. I just don't know how...

Drasha