[libcamera-devel,v4,3/4] ipa: raspberrypi: Add Merge method to RPiController::Metadata
diff mbox series

Message ID 20210419131715.256802-4-naush@raspberrypi.com
State Superseded
Headers show
Series
  • ipa: raspberrypi: Rate-limit the controller algorithms
Related show

Commit Message

Naushir Patuck April 19, 2021, 1:17 p.m. UTC
Add a new Merge method to the Metadata class. This will move all
key/value pairs between a source and destination metadata object. Once
complete, the source Metadata object will be empty.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
---
 src/ipa/raspberrypi/controller/metadata.hpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Patch
diff mbox series

diff --git a/src/ipa/raspberrypi/controller/metadata.hpp b/src/ipa/raspberrypi/controller/metadata.hpp
index 319f2320fc70..1d3e941b3e52 100644
--- a/src/ipa/raspberrypi/controller/metadata.hpp
+++ b/src/ipa/raspberrypi/controller/metadata.hpp
@@ -75,6 +75,18 @@  public:
 		return *this;
 	}
 
+	void Merge(Metadata &other)
+	{
+		std::lock_guard<std::mutex> lock(mutex_);
+		std::lock_guard<std::mutex> other_lock(other.mutex_);
+
+		for (auto const &kv: other.data_)
+			data_[kv.first] = std::move(kv.second);
+
+		/* Render the other object as empty now! */
+		other.data_.clear();
+	}
+
 	template<typename T>
 	T *GetLocked(std::string const &tag)
 	{