Merge pull request #3695 from unknownbrackets/threadend

Improve threadend waits, add callback handlers, some cleanup
Merge pull request #3694 from unknownbrackets/atrac-minor

Improve sceAtrac error handling
Split msgpipe handling logic from wait/resched.

This way I can reuse it for the callback stuff.
Reorganize msgpipes code a bit to prep. for cbs.

No real changes.
Adjust some helpers for msgpipes.
Refactor and add a way to remove msgpipe waits.
Add callback handlers for msgpipes.