This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template<typename T> | |
| bool List<T>::add(T elem) | |
| { | |
| NodeList<T> *node = new NodeList<T>(elem); | |
| std::lock_guard<std::mutex> lock(this->_mux); | |
| if (this->empty()) { | |
| this->_head = node; | |
| this->_tail = node; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template<typename T> | |
| class Set { | |
| public: | |
| virtual bool add(T elem) = 0; | |
| virtual bool remove(T elem) = 0; | |
| virtual bool exists(T elem) = 0; | |
| virtual ~Set(); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int main() { | |
| /* | |
| * Single threaded version | |
| */ | |
| List<int> simple_list; | |
| Set<int> &simple_list_ref = simple_list; | |
| // Adding elements | |
| std::cout << "1. Adding elements" << std::endl; | |
| simple_list_ref.add(22); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <unistd.h> | |
| extern char etext, edata, end; | |
| int a = 1; | |
| int b; | |
| static int c = 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void DiskJanitor::clean_files(const std::string &root) | |
| { | |
| _purger->iterate(root); | |
| } | |
| void FilesPurger::iterate(const std::string &root) | |
| { | |
| namespace fs = std::experimental::filesystem; | |
| fs::path root_path(root); | |
| if (fs::exists(root_path) && fs::is_directory(root_path)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| time_t now; | |
| struct tm t; | |
| time(&now); | |
| t = *localtime(&now); | |
| t.tm_mon = 0; t.tm_mday = 1; | |
| t.tm_hour = 0; t.tm_min = 0; t.tm_sec = 0; | |
| std::unique_ptr<FilesPurger> purger = | |
| std::make_unique<ATFilesPurger>(mktime(&t)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void SZFilesPurger::purge(const std::string &root) | |
| { | |
| namespace fs = std::experimental::filesystem; | |
| fs::path root_path(root); | |
| if (fs::exists(root_path) && fs::is_directory(root_path)) { | |
| for (const fs::directory_entry &entry : | |
| fs::recursive_directory_iterator(root_path)) { | |
| if (entry.is_directory()) { | |
| continue; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void ATFilesPurger::purge(const std::string &root) | |
| { | |
| namespace fs = std::experimental::filesystem; | |
| fs::path root_path(root); | |
| if (fs::exists(root_path) && fs::is_directory(root_path)) { | |
| for (const fs::directory_entry &entry : | |
| fs::recursive_directory_iterator(root_path)) { | |
| if (entry.is_directory()) { | |
| continue; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void MTFilesPurger::purge(const std::string &root) | |
| { | |
| namespace fs = std::experimental::filesystem; | |
| fs::path root_path(root); | |
| if (fs::exists(root_path) && fs::is_directory(root_path)) { | |
| for (const fs::directory_entry &entry : | |
| fs::recursive_directory_iterator(root_path)) { | |
| if (entry.is_directory()) { | |
| continue; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MTFilesPurger : public FilesPurger { | |
| private: | |
| time_t _rel_time; | |
| public: | |
| MTFilesPurger(const time_t rel_time); | |
| void purge(const std::string &root) override; | |
| }; |