Support source/sink task & random priority & Fix some bugs

Hi,
This pull request includes:

- Support source/sink task:
  + source/sink tasks are treated as wrapper (run on its own wrapper thread)
  + entry tasks read from source, exit tasks write to sink
  + entry/exit task has different priority function
- Add a priority function which generates a random priority
- Bugs:
  + Race condition in stream close/replace (which will fix the example loadbalance from Bert)