Skip to content

Commit

Permalink
Changed resources() to a const accessor
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-hughes-tiledb committed Sep 5, 2024
1 parent c1ccef9 commit 3dc230b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion tiledb/sm/consolidator/consolidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class Consolidator : public JobBranch {
/**
* Derived from `JobBranch`
*/
ContextResources& resources() override {
ContextResources& resources() const override {
return resources_;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class ArrayDimensionLabelQueries : public JobBranch {
/**
* Derived from `JobBranch`
*/
ContextResources& resources() override {
ContextResources& resources() const override {
return resources_;
}
};
Expand Down
2 changes: 1 addition & 1 deletion tiledb/sm/query/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ class Query : public JobBranch {
/**
* Derived from `JobBranch`
*/
ContextResources& resources() override {
ContextResources& resources() const override {
return resources_;
}
};
Expand Down
2 changes: 1 addition & 1 deletion tiledb/sm/storage_manager/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class Context : public ContextBase, public JobRoot {
/**
* Derived from `JobRoot`
*/
[[nodiscard]] ContextResources& resources() override {
[[nodiscard]] ContextResources& resources() const override {
return resources_;
}

Expand Down
2 changes: 1 addition & 1 deletion tiledb/sm/storage_manager/job.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ struct JobResourceMixin {
* Each class derived from `Parent` implements its own resources accessor.
* Typically this accessor will simply return its own member variable.
*/
[[nodiscard]] virtual ContextResources& resources() = 0;
[[nodiscard]] virtual ContextResources& resources() const = 0;

/**
* Factory for cancellation source objects that are tied to the cancellation
Expand Down
27 changes: 19 additions & 8 deletions tiledb/sm/storage_manager/test/unit_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,24 @@ TEST_CASE("job::Child - construct and size") {
CHECK(jf.context_.number_of_jobs() == 0);
}

class TestJobRoot : public JobRoot {

class TestJobRootBase {
protected:
Config config_{};
ContextResources resources_{
mutable ContextResources resources_{
config_, std::make_shared<Logger>("log"), 1, 1, ""};
StorageManager sm_{resources_, config_};
TestJobRootBase() = default;
};

class TestJobRoot : protected TestJobRootBase, public JobRoot {
using Base = TestJobRootBase;
public:
TestJobRoot()
: JobRoot(sm_) {
: TestJobRootBase(), JobRoot(Base::sm_) {
}
ContextResources& resources() override {
return resources_;
ContextResources& resources() const override {
return Base::resources_;
}
};
static_assert(TestJobRoot::is_parent);
Expand All @@ -258,7 +264,7 @@ class TestJobBranch : public JobBranch {
TestJobBranch(JobParent& parent)
: JobBranch(parent) {
}
ContextResources& resources() override {
ContextResources& resources() const override {
return parent().resources();
}
};
Expand Down Expand Up @@ -297,15 +303,20 @@ TEST_CASE("TestJobLeaf - construct from branch") {
TestJobLeaf leaf{branch};
}

class TestJobIsolate : public JobIsolate {
class TestJobIsolateBase {
protected:
Config config_{};
ContextResources resources_{
config_, std::make_shared<Logger>("log"), 1, 1, ""};
StorageManager sm_{resources_, config_};
TestJobIsolateBase() = default;
};

class TestJobIsolate : protected TestJobIsolateBase, public JobIsolate {
using Base = TestJobIsolateBase;
public:
TestJobIsolate()
: JobIsolate(sm_) {
: TestJobIsolateBase(), JobIsolate(Base::sm_) {
}
};
static_assert(!TestJobIsolate::is_parent);
Expand Down

0 comments on commit 3dc230b

Please sign in to comment.