//////////////////////////////////////////////////////////////////////////
// Implementation
//////////////////////////////////////////////////////////////////////////
private Future _send(object msg, Duration dur, Future whenDone)
{
// ensure immutable or safe copy
msg = Sys.safe(msg);
// don't deliver new messages to a stopped pool
if (m_pool.isStopped())
{
throw Err.make("ActorPool is stopped").val;
}
// get the future instance to manage this message's lifecycle
Future f = new Future(msg);
// either enqueue immediately or schedule with pool
if (dur != null)
{
m_pool.schedule(this, dur, f);
}
else if (whenDone != null)
{
whenDone.sendWhenDone(this, f);
}
else
{
f = _enqueue(f, true);
}
return(f);
}