|
@@ -25,8 +25,8 @@ namespace robotics {
|
|
|
* @param name
|
|
|
* @param values
|
|
|
*/
|
|
|
- cache_queue(std::string const& name, std::vector<_Type>& values) :
|
|
|
- v3::linq<_Type>(values),
|
|
|
+ cache_queue(std::string const& name) :
|
|
|
+ v3::linq<_Type>(source_data_),
|
|
|
file_name_(name) {
|
|
|
}
|
|
|
/**
|
|
@@ -34,6 +34,29 @@ namespace robotics {
|
|
|
*/
|
|
|
~cache_queue() {
|
|
|
}
|
|
|
+ /**
|
|
|
+ * @brief Ìí¼Ó
|
|
|
+ * @param value
|
|
|
+ */
|
|
|
+ void push(_Type const&value) {
|
|
|
+ this->append(value);
|
|
|
+ save();
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @brief ÒƳý
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ _Type pop() {
|
|
|
+ _Type value;
|
|
|
+ {
|
|
|
+ std::lock_guard<std::mutex> locker(this->mutex_);
|
|
|
+ value = source_data_.front();
|
|
|
+ source_data_.erase(source_data_.begin());
|
|
|
+ }
|
|
|
+ this->reset();
|
|
|
+ save();
|
|
|
+ return value;
|
|
|
+ }
|
|
|
/**
|
|
|
* @brief ¼ÓÔØ
|
|
|
*/
|
|
@@ -78,7 +101,8 @@ namespace robotics {
|
|
|
std::filesystem::create_directory(directory);
|
|
|
}
|
|
|
v3::archive::stream stream;
|
|
|
- for (auto& it : this->source()) {
|
|
|
+ auto datas = source_data_;
|
|
|
+ for (auto& it : datas) {
|
|
|
stream << it;
|
|
|
}
|
|
|
std::fstream file("data/" + file_name_, std::ios::binary | std::ios::out);
|
|
@@ -93,6 +117,7 @@ namespace robotics {
|
|
|
return true;
|
|
|
}
|
|
|
private:
|
|
|
+ std::vector<_Type> source_data_;
|
|
|
std::string file_name_;
|
|
|
};
|
|
|
}
|