mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-30 21:30:04 +00:00 
			
		
		
		
	remove polymorphism issue
This commit is contained in:
		
							parent
							
								
									fd5f71bcff
								
							
						
					
					
						commit
						8480899d8b
					
				
					 1 changed files with 30 additions and 2 deletions
				
			
		|  | @ -33,9 +33,11 @@ public: | |||
|     bool Empty() const { | ||||
|         return !read_ptr->next.load(); | ||||
|     } | ||||
| 
 | ||||
|     T& Front() const { | ||||
|         return read_ptr->current; | ||||
|     } | ||||
| 
 | ||||
|     template <typename Arg> | ||||
|     void Push(Arg&& t) { | ||||
|         // create the element, add it to the queue
 | ||||
|  | @ -108,15 +110,41 @@ private: | |||
| // single reader, multiple writer queue
 | ||||
| 
 | ||||
| template <typename T, bool NeedSize = true> | ||||
| class MPSCQueue : public SPSCQueue<T, NeedSize> { | ||||
| class MPSCQueue { | ||||
| public: | ||||
|     u32 Size() const { | ||||
|         return spsc_queue.Size(); | ||||
|     } | ||||
| 
 | ||||
|     bool Empty() const { | ||||
|         return spsc_queue.Empty(); | ||||
|     } | ||||
| 
 | ||||
|     T& Front() const { | ||||
|         return spsc_queue.Front(); | ||||
|     } | ||||
| 
 | ||||
|     template <typename Arg> | ||||
|     void Push(Arg&& t) { | ||||
|         std::lock_guard<std::mutex> lock(write_lock); | ||||
|         SPSCQueue<T, NeedSize>::Push(t); | ||||
|         spsc_queue.Push(t); | ||||
|     } | ||||
| 
 | ||||
|     void Pop() { | ||||
|         return spsc_queue.Pop(); | ||||
|     } | ||||
| 
 | ||||
|     bool Pop(T& t) { | ||||
|         return spsc_queue.Pop(t); | ||||
|     } | ||||
| 
 | ||||
|     // not thread-safe
 | ||||
|     void Clear() { | ||||
|         spsc_queue.Clear(); | ||||
|     } | ||||
| 
 | ||||
| private: | ||||
|     SPSCQueue<T, NeedSize> spsc_queue; | ||||
|     std::mutex write_lock; | ||||
| }; | ||||
| } // namespace Common
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue