Why isCanceled() is needed? The generator should call cancel and the effect should be immediate, so it is not necessary to check cancel state from outside the Algorithm class.