remove directory tools/clib (#21250)
	
		
	
				
					
				
			
							parent
							
								
									060b5caf1b
								
							
						
					
					
						commit
						06625f3a0e
					
				
				 1 changed files with 0 additions and 35 deletions
			
			
		| @ -1,35 +0,0 @@ | ||||
| #ifndef CHANNEL_HPP | ||||
| #define CHANNEL_HPP | ||||
| 
 | ||||
| #include <mutex> | ||||
| #include <list> | ||||
| #include <condition_variable> | ||||
| 
 | ||||
| template<class item> | ||||
| class channel { | ||||
| private: | ||||
|   std::list<item> queue; | ||||
|   std::mutex m; | ||||
|   std::condition_variable cv; | ||||
| public: | ||||
|   void put(const item &i) { | ||||
|     std::unique_lock<std::mutex> lock(m); | ||||
|     queue.push_back(i); | ||||
|     cv.notify_one(); | ||||
|   } | ||||
|   void put_front(const item &i) { | ||||
|     std::unique_lock<std::mutex> lock(m); | ||||
|     queue.push_front(i); | ||||
|     cv.notify_one(); | ||||
|   } | ||||
|   item get() { | ||||
|     std::unique_lock<std::mutex> lock(m); | ||||
|     cv.wait(lock, [&](){ return !queue.empty(); }); | ||||
|     item result = queue.front(); | ||||
|     queue.pop_front(); | ||||
|     return result; | ||||
|   } | ||||
| }; | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
					Loading…
					
					
				
		Reference in new issue