Initial refactor to use channels to share memory instead of mutex.

Please remove pending tests cases flushMetrics and handleTcpRequest