Commit 402e9008 authored by Eric Cano's avatar Eric Cano
Browse files

#433: implemented `ObjectOps<>::asyncInsert()`

parent 00520fcf
......@@ -460,7 +460,6 @@ public:
ObjectOps & m_obj;
std::unique_ptr<Backend::AsyncLockfreeFetcher> m_asyncLockfreeFetcher;
friend AsyncLockfreeFetcher;
......@@ -471,6 +470,38 @@ public:
return ret.release();
class AsyncInserter {
friend class ObjectOps;
AsyncInserter(ObjectOps & obj): m_obj(obj) {}
void wait() {
m_obj.m_existingObject = true;
ObjectOps & m_obj;
std::unique_ptr<Backend::AsyncCreator> m_asyncCreator;
friend AsyncInserter;
AsyncInserter * asyncInsert() {
std::unique_ptr<AsyncInserter> ret;
// Current simplification: the parsing of the header/payload is synchronous.
// This could be delegated to the backend.
// Check that we are not dealing with an existing object
if (m_existingObject)
throw NotNewObject("In ObjectOps::asyncInsert: trying to insert an already exitsting object");
// Check that the object is ready in memory
if (!m_headerInterpreted || !m_payloadInterpreted)
throw NotInitialized("In ObjectOps::insert: trying to insert an uninitialized object");
// Push the payload into the header and write the object
// We don't require locking here, as the object does not exist
// yet in the object store (and this is ensured by the )
ret->m_asyncCreator.reset(m_objectStore.asyncCreate(getAddressIfSet(), m_header.SerializeAsString()));
return ret.release();
void commit() {
if (!m_existingObject)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment