Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dbzero/bindings/python/PyAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ namespace db0::python
if (prefix_name) {
PyToolkit::getPyWorkspace().getWorkspace().close(db0::PrefixName(prefix_name));
} else {
PyToolkit::getPyWorkspace().close();
PyToolkit::getPyWorkspace().close();
}
Py_RETURN_NONE;
}
Expand Down
1 change: 1 addition & 0 deletions src/dbzero/bindings/python/PyToolkit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace db0
{

class Fixture;
class ProcessTimer;

}

Expand Down
9 changes: 7 additions & 2 deletions src/dbzero/bindings/python/PyTypeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <dbzero/bindings/python/types/PyClass.hpp>
#include <dbzero/bindings/python/types/PyTag.hpp>
#include <dbzero/bindings/python/types/PyDecimal.hpp>
#include <dbzero/core/utils/ProcessTimer.hpp>

namespace db0::python

Expand Down Expand Up @@ -485,8 +486,12 @@ namespace db0::python
}
}

void PyTypeManager::close()
{
void PyTypeManager::close(db0::ProcessTimer *timer_ptr)
{
std::unique_ptr<db0::ProcessTimer> timer;
if (timer_ptr) {
timer = std::make_unique<db0::ProcessTimer>("PyTypeManager::close", *timer_ptr);
}
// close Enum's but don't remove from cache
// this is to allow future creation / retrieval of dbzero enums while keeping python objects alive
for (auto &item : m_enum_cache) {
Expand Down
10 changes: 9 additions & 1 deletion src/dbzero/bindings/python/PyTypeManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
#include <dbzero/bindings/python/types/PyEnumType.hpp>
#include <dbzero/bindings/python/MemoTypeDecoration.hpp>

namespace db0

{

class ProcessTimer;

}

namespace db0::object_model {

class Object;
Expand Down Expand Up @@ -185,7 +193,7 @@ namespace db0::python
// Decode either of: None, False or True from a lo-fi code
ObjectSharedPtr getLangConstant(unsigned int) const;

void close();
void close(db0::ProcessTimer *timer_ptr = nullptr);

private:
static std::vector<std::unique_ptr<std::string> > m_string_pool;
Expand Down
10 changes: 7 additions & 3 deletions src/dbzero/bindings/python/PyWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,18 @@ namespace db0::python
return m_workspace;
}

void PyWorkspace::close()
void PyWorkspace::close(db0::ProcessTimer *timer_ptr)
{
std::unique_ptr<db0::ProcessTimer> timer;
if (timer_ptr) {
timer = std::make_unique<db0::ProcessTimer>("PyWorkspace::close", *timer_ptr);
}
if (m_workspace) {
getWorkspace().close();
getWorkspace().close(false, timer.get());
// NOTE: must unlock API because workspace destroy may trigger db0 object deletions
m_workspace = nullptr;
}
PyToolkit::getTypeManager().close();
PyToolkit::getTypeManager().close(timer.get());
m_config = nullptr;
m_workspace = nullptr;
}
Expand Down
3 changes: 2 additions & 1 deletion src/dbzero/bindings/python/PyWorkspace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace db0 {
class Config;
class Fixture;
class Memspace;
class ProcessTimer;

}

Expand Down Expand Up @@ -70,7 +71,7 @@ namespace db0::python

std::shared_ptr<db0::Workspace> getWorkspaceSharedPtr() const;

void close();
void close(ProcessTimer *timer = nullptr);

bool refresh();

Expand Down
2 changes: 1 addition & 1 deletion src/dbzero/core/dram/DRAM_Prefix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ namespace db0
return m_pages.empty();
}

void DRAM_Prefix::close()
void DRAM_Prefix::close(ProcessTimer *)
{
for (auto &page: m_pages) {
page.second.resetDirtyFlag();
Expand Down
2 changes: 1 addition & 1 deletion src/dbzero/core/dram/DRAM_Prefix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace db0

std::uint64_t commit(ProcessTimer * = nullptr) override;

void close() override;
void close(ProcessTimer *timer_ptr = nullptr) override;

std::size_t getDirtySize() const override;

Expand Down
2 changes: 1 addition & 1 deletion src/dbzero/core/memory/Memspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace db0
getAllocatorForUpdate().close();
m_allocator_ptr = nullptr;
m_allocator = nullptr;
m_prefix->close();
m_prefix->close(timer.get());
m_prefix = nullptr;
}

Expand Down
2 changes: 1 addition & 1 deletion src/dbzero/core/memory/Prefix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace db0
*/
virtual std::uint64_t commit(ProcessTimer * = nullptr) = 0;

virtual void close() = 0;
virtual void close(ProcessTimer *timer_ptr = nullptr) = 0;

/**
* Get last update timestamp
Expand Down
9 changes: 7 additions & 2 deletions src/dbzero/core/memory/PrefixImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,14 @@ namespace db0
return m_head_state_num;
}

void PrefixImpl::close()
void PrefixImpl::close(ProcessTimer *timer_ptr)
{
m_cache.release();
std::unique_ptr<ProcessTimer> timer;
if (timer_ptr) {
timer = std::make_unique<ProcessTimer>("Prefix::close", timer_ptr);
}
// FIXME: log
// m_cache.release();
m_storage_ptr->close();
}

Expand Down
2 changes: 1 addition & 1 deletion src/dbzero/core/memory/PrefixImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace db0
* this method should be called before closing the prefix to clean up used resources
* Finally close the corresponding storage.
*/
void close() override;
void close(ProcessTimer *timer_ptr = nullptr) override;

bool beginRefresh() override;

Expand Down
2 changes: 1 addition & 1 deletion src/dbzero/core/memory/PrefixViewImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace db0
<< "PrefixViewImpl::getLastUpdated: cannot get last updated timestamp from snapshot" << THROWF_END;
}

void PrefixViewImpl::close() {
void PrefixViewImpl::close(ProcessTimer *) {
// close does nothing
}

Expand Down
2 changes: 1 addition & 1 deletion src/dbzero/core/memory/PrefixViewImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace db0

std::uint64_t getLastUpdated() const override;

void close() override;
void close(ProcessTimer *timer_ptr = nullptr) override;

AccessType getAccessType() const override;

Expand Down
2 changes: 1 addition & 1 deletion tests/utils/PrefixProxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace db0::tests
return m_prefix->commit(timer);
}

void close() override {
void close(ProcessTimer * = nullptr) override {
m_prefix->close();
}

Expand Down