Previously TaskPool's destructor waited until all the tasks were finished. Now, the public TaskPool is deleted immediately and the private instance will wait for the tasks to report themselves finished. Only after this the private instance deletes itself.
Note: When encountering a crash involving mutex unlocking, check that a Guarded object isn't deleted during the guarding.
Also cleaned up the friend relationship between Task/TaskPool.
libcore|TaskPool: Redesigned shutdown procedure
Previously TaskPool's destructor waited until all the tasks were
finished. Now, the public TaskPool is deleted immediately and the
private instance will wait for the tasks to report themselves finished.
Only after this the private instance deletes itself.
Note: When encountering a crash involving mutex unlocking, check that
a Guarded object isn't deleted during the guarding.
Also cleaned up the friend relationship between Task/TaskPool.