Refactor NodeStore, add NodeStoreSchedulerService

This commit is contained in:
Vinnie Falco
2013-09-20 00:42:45 -07:00
parent 63de1618e9
commit 85fc59b28b
66 changed files with 2857 additions and 2494 deletions

View File

@@ -30,10 +30,10 @@ static int s_nodeStoreDBCount = NUMBER (s_nodeStoreDBInit);
//------------------------------------------------------------------------------
class SqliteBackendFactory::Backend : public NodeStore::Backend
class SqliteFactory::BackendImp : public NodeStore::Backend
{
public:
Backend (size_t keyBytes, std::string const& path, NodeStore::Scheduler& scheduler)
BackendImp (size_t keyBytes, std::string const& path, NodeStore::Scheduler& scheduler)
: m_keyBytes (keyBytes)
, m_name (path)
, m_db (new DatabaseCon(path, s_nodeStoreDBInit, s_nodeStoreDBCount))
@@ -47,7 +47,7 @@ public:
m_db->getDB()->executeSQL (s.toStdString ().c_str ());
}
~Backend()
~BackendImp()
{
}
@@ -58,9 +58,9 @@ public:
//--------------------------------------------------------------------------
Status fetch (void const* key, NodeObject::Ptr* pObject)
NodeStore::Status fetch (void const* key, NodeObject::Ptr* pObject)
{
Status result = ok;
NodeStore::Status result = NodeStore::ok;
pObject->reset ();
@@ -87,7 +87,7 @@ public:
}
else
{
result = notFound;
result = NodeStore::notFound;
}
pSt.reset();
@@ -132,7 +132,7 @@ public:
pStE.reset();
}
void visitAll (VisitCallback& callback)
void visitAll (NodeStore::VisitCallback& callback)
{
// No lock needed as per the visitAll() API
@@ -165,11 +165,6 @@ public:
return 0;
}
void stopAsync ()
{
m_scheduler.scheduledTasksStopped ();
}
//--------------------------------------------------------------------------
void doBind (SqliteStatement& statement, NodeObject::ref object)
@@ -216,28 +211,28 @@ private:
//------------------------------------------------------------------------------
SqliteBackendFactory::SqliteBackendFactory ()
SqliteFactory::SqliteFactory ()
{
}
SqliteBackendFactory::~SqliteBackendFactory ()
SqliteFactory::~SqliteFactory ()
{
}
SqliteBackendFactory* SqliteBackendFactory::getInstance ()
SqliteFactory* SqliteFactory::getInstance ()
{
return new SqliteBackendFactory;
return new SqliteFactory;
}
String SqliteBackendFactory::getName () const
String SqliteFactory::getName () const
{
return "Sqlite";
}
NodeStore::Backend* SqliteBackendFactory::createInstance (
NodeStore::Backend* SqliteFactory::createInstance (
size_t keyBytes,
StringPairArray const& keyValues,
NodeStore::Parameters const& keyValues,
NodeStore::Scheduler& scheduler)
{
return new Backend (keyBytes, keyValues ["path"].toStdString (), scheduler);
return new BackendImp (keyBytes, keyValues ["path"].toStdString (), scheduler);
}

View File

@@ -4,28 +4,28 @@
*/
//==============================================================================
#ifndef RIPPLE_SQLITEBACKENDFACTORY_H_INCLUDED
#define RIPPLE_SQLITEBACKENDFACTORY_H_INCLUDED
#ifndef RIPPLE_APP_SQLITEFACTORY_H_INCLUDED
#define RIPPLE_APP_SQLITEFACTORY_H_INCLUDED
/** Factory to produce SQLite backends for the NodeStore.
@see NodeStore
@see Database
*/
class SqliteBackendFactory : public NodeStore::BackendFactory
class SqliteFactory : public NodeStore::Factory
{
private:
class Backend;
SqliteBackendFactory ();
~SqliteBackendFactory ();
SqliteFactory ();
~SqliteFactory ();
public:
static SqliteBackendFactory* getInstance ();
class BackendImp;
static SqliteFactory* getInstance ();
String getName () const;
NodeStore::Backend* createInstance (size_t keyBytes,
StringPairArray const& keyValues,
NodeStore::Parameters const& keyValues,
NodeStore::Scheduler& scheduler);
};