Factor launch code (#580)
Factor launch code (#580)

* Factor launch code

Prior to this commit, there were two ways in which a task would be launched,
depending on whether there were dependencies pending when the task was
created or not.

These two ways were similar but not identical.

This commit makes a single `launch_if_ready` method which captures one of those
launch behaviours - the case where a launch had been deferred.

This commit also changes the initial submission to always submit as if
dependencies were pending, and then immediately calls `launch_if_ready`.

This makes the code easier to follow, I think, as tidying up the separation
of creating a non-running task first, and then separately visiting it
to decide if it can be run.

There is a (hopefully minor) increased expense in visiting all of the dependencies
twice to see if they are done, on task creation (as launch_if_ready always checks
dependencies, even if task creation has just done so).

This refactoring also means that `launch_if_ready` can be called *anywhere* where
there is a possibility that a task has become ready for launch, without needing
further co-ordination of that launching.

* Fix flake8

* Add some more notes on usage and safety

* remove a log line

* Make indentation of launch_if_ready follow correct style

* remove unneeded status change that only happened in one of the paths

* tidy documentation

Parsl/parsl,Parsl/parsl,swift-lang/swift-e-lab,swift-lang/swift-e-lab,Parsl/parsl,Parsl/parsl