Add RPC queuing, task loop locking, and a unit test to verify functionality.