periodic_file_deleter.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 #pragma once
16 
17 #include <memory>
18 #include <mutex>
19 #include <string>
20 #include <thread>
21 
22 #include <boost/function.hpp>
23 #include <ros/ros.h>
24 
25 namespace Aws
26 {
27 namespace Rosbag
28 {
29 namespace Utils
30 {
31 
33 {
34 public:
35  explicit PeriodicFileDeleter(
36  boost::function<std::vector<std::string>()> deletion_list_callback,
37  const int interval_period_s=10);
39  // Delete copy and move constructors
44 
45  void Start();
46  void Stop();
47  bool IsActive() const;
48 private:
49  // Whether the deleter should be deleting files now
50  bool is_active_;
51  // Callback function to get a list of files for deletion
52  boost::function<std::vector<std::string>()> deletion_list_callback_;
53  // How often the deleter should check for new files to delete
54  const int interval_period_s_;
55  // Protects is_active_
56  mutable std::mutex mutex_;
57  // Runs the deletion loop
58  std::thread thread_;
59  // Main logic for deleting a list of files
60  void DeleteFiles();
61 };
62 
63 } // namespace Utils
64 } // namespace Rosbag
65 } // namespace Aws
boost::function< std::vector< std::string >)> deletion_list_callback_
PeriodicFileDeleter & operator=(PeriodicFileDeleter const &)=delete
PeriodicFileDeleter(boost::function< std::vector< std::string >()> deletion_list_callback, const int interval_period_s=10)


rosbag_cloud_recorders
Author(s): AWS RoboMaker
autogenerated on Tue Jun 1 2021 02:51:27