Commit f3d96593 authored by Ramon Nou's avatar Ramon Nou
Browse files

Moved to static initialization of fs, avoids multiple init and finish

parent 50420484
Loading
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ class file {


public:
    file(cargo::FSPlugin::type t) {
    explicit file(cargo::FSPlugin::type t) {
        m_fs_plugin = cargo::FSPlugin::make_fs(t);
    };

+11 −3
Original line number Diff line number Diff line
@@ -12,16 +12,24 @@

namespace cargo {

std::unique_ptr<FSPlugin>
static std::shared_ptr<FSPlugin> m_fs_posix;
static std::shared_ptr<FSPlugin> m_fs_gekkofs;

std::shared_ptr<FSPlugin>
FSPlugin::make_fs(type t) {

    switch(t) {
        case type::posix:
        case type::parallel:
            return std::make_unique<cargo::posix_plugin>();
            if(m_fs_posix == nullptr)
                m_fs_posix = std::make_shared<cargo::posix_plugin>();
            return m_fs_posix;
#ifdef GEKKOFS_PLUGIN
        case type::gekkofs:
            return std::make_unique<cargo::gekko_plugin>();
            if(m_fs_gekkofs == nullptr)
                m_fs_gekkofs = std::make_shared<cargo::gekko_plugin>();
            return m_fs_gekkofs;

#endif
#ifdef HERCULES_PLUGIN
        case type::hercules:
+3 −1
Original line number Diff line number Diff line
@@ -19,7 +19,9 @@ public:
        expand,
        dataclay
    };
    static std::unique_ptr<FSPlugin> make_fs(type);

    static std::shared_ptr<FSPlugin> make_fs(type);
    // One instance per fs type

    virtual ~FSPlugin() = default;

+2 −6
Original line number Diff line number Diff line
@@ -9,18 +9,14 @@ gekko_plugin::gekko_plugin() {
    int result = gkfs_init();
    if(result != 0) {
        std::cerr << "Failed to initialize gekkofs" << std::endl;
    }  else {
        std::cout << "Initialized gekkofs" << std::endl;
    }
}

gekko_plugin::~gekko_plugin() {
    /*int result = gkfs_end();
    int result = gkfs_end();
    if(result != 0) {
        std::cerr << "Failed to finalize gekkofs" << std::endl;
    } else {
        std::cout << "Finalized gekkofs" << std::endl;
    }*/
    }
}
// Override the open function
int