In addition to [Future
The biggest decision is how to declare it. EmptyFuture exposes no new accessible methods or properties above what Future already exposes. If a class doesn’t provide any additional behavior is there any reason to expose it’ In this case I think not. Therefore it will be declared as a private inner class of Future.
Yes this makes it impossible to directly create from a user perspective. You could also make a good argument that creation is new behavior and therefore EmptyFuture should be exposed. However for Future’s, as with other generic classes, I prefer static factory methods for creation. It allows the user to take advantage of type inference as much as possible.
private sealed class EmptyFuture : Future
{
private Action m_action;
internal EmptyFuture(Action action)
{
m_action = action;
}
protected override void RunCore()
{
m_action();
}
}
Next we’ll go over the creation of the factory methods to create this and Future