ffmepg 导入, 视频解码初始化逻辑, 视频解码线程逻辑
This commit is contained in:
		@@ -9,7 +9,8 @@ public:
 | 
			
		||||
	~ThreadQueue() = default;
 | 
			
		||||
 | 
			
		||||
	void push(const T& value) {
 | 
			
		||||
		std::lock_guard<std::mutex> lock(mutex_);
 | 
			
		||||
		std::unique_lock<std::mutex> lock(mutex_);
 | 
			
		||||
		condition_.wait(lock, [this](){ return queue_.size() <= maxSize; });
 | 
			
		||||
		queue_.push(value);
 | 
			
		||||
		condition_.notify_one();
 | 
			
		||||
	}
 | 
			
		||||
@@ -19,6 +20,7 @@ public:
 | 
			
		||||
		condition_.wait(lock, [this] { return !queue_.empty(); });
 | 
			
		||||
		T value = queue_.front();
 | 
			
		||||
		queue_.pop();
 | 
			
		||||
		condition_.notify_one();
 | 
			
		||||
		return value;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -35,4 +37,5 @@ private:
 | 
			
		||||
	std::queue<T> queue_;
 | 
			
		||||
	mutable std::mutex mutex_;
 | 
			
		||||
	std::condition_variable condition_;
 | 
			
		||||
    unsigned int maxSize = 50;
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user