Add shared queue to AsynRPCQueue.

This commit is contained in:
Simon 2016-09-04 08:12:46 -07:00
parent b922924d14
commit 423a63d0a9
2 changed files with 11 additions and 0 deletions

View File

@ -6,6 +6,15 @@
static std::atomic<size_t> workerCounter(0);
/**
* Static method to return the shared/default queue.
*/
shared_ptr<AsyncRPCQueue> AsyncRPCQueue::sharedInstance() {
// Thread-safe in C+11 and gcc 4.3
static shared_ptr<AsyncRPCQueue> q = std::make_shared<AsyncRPCQueue>();
return q;
}
AsyncRPCQueue::AsyncRPCQueue() : closed_(false), finish_(false) {
}

View File

@ -24,6 +24,8 @@ typedef std::unordered_map<AsyncRPCOperationId, std::shared_ptr<AsyncRPCOperatio
class AsyncRPCQueue {
public:
static shared_ptr<AsyncRPCQueue> sharedInstance();
AsyncRPCQueue();
virtual ~AsyncRPCQueue();