Skip to content

Commit 2bac4b0

Browse files
committed
move transaction counters to children classes
1 parent bb8d21a commit 2bac4b0

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

include/dtlmod/Engine.hpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,8 @@ class Engine {
5555
ActorRegistry subscribers_;
5656
std::string metadata_file_;
5757

58-
protected:
5958
sg4::ActivitySet pub_transaction_;
60-
sg4::ConditionVariablePtr pub_transaction_completed_ = sg4::ConditionVariable::create();
61-
unsigned int current_pub_transaction_id_ = 0;
62-
unsigned int completed_pub_transaction_id_ = 0;
63-
bool pub_transaction_in_progress_ = false;
64-
6559
sg4::ActivitySet sub_transaction_;
66-
unsigned int current_sub_transaction_id_ = 0;
67-
bool sub_transaction_in_progress_ = false;
6860

6961
void close_stream() const;
7062

@@ -138,7 +130,7 @@ class Engine {
138130

139131
/// @brief Get the id of the current transaction (on the Publish side).
140132
/// @return The id of the ongoing transaction.
141-
[[nodiscard]] unsigned int get_current_transaction() const noexcept { return current_pub_transaction_id_; }
133+
[[nodiscard]] virtual unsigned int get_current_transaction() const noexcept = 0;
142134

143135
/// @brief Get the name of the file in which the engine stored metadata
144136
/// @return The name of the file.

include/dtlmod/FileEngine.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ class FileEngine : public Engine {
3434
sg4::ConditionVariablePtr pub_activities_completed_ = sg4::ConditionVariable::create();
3535
std::unordered_map<sg4::ActorPtr, sg4::ActivitySet> file_sub_transaction_;
3636
std::unordered_map<sg4::ActorPtr, sg4::ActivitySet> file_pub_transaction_;
37+
unsigned int current_pub_transaction_id_ = 0;
38+
unsigned int completed_pub_transaction_id_ = 0;
39+
bool pub_transaction_in_progress_ = false;
40+
sg4::ConditionVariablePtr pub_transaction_completed_ = sg4::ConditionVariable::create();
41+
42+
unsigned int current_sub_transaction_id_ = 0;
43+
bool sub_transaction_in_progress_ = false;
3744

3845
protected:
3946
void create_transport(const Transport::Method& transport_method) override;
@@ -45,6 +52,7 @@ class FileEngine : public Engine {
4552
void begin_sub_transaction() override;
4653
void end_sub_transaction() override;
4754
void sub_close() override;
55+
[[nodiscard]] unsigned int get_current_transaction() const noexcept override { return current_pub_transaction_id_; }
4856

4957
public:
5058
explicit FileEngine(const std::string& fullpath, const std::shared_ptr<Stream>& stream);

include/dtlmod/StagingEngine.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ class StagingEngine : public Engine {
2121
std::atomic<unsigned int> num_subscribers_starting_{0};
2222
bool pub_closing_ = false;
2323
bool sub_closing_ = false;
24+
unsigned int current_pub_transaction_id_ = 0;
25+
unsigned int completed_pub_transaction_id_ = 0;
26+
bool pub_transaction_in_progress_ = false;
27+
sg4::ConditionVariablePtr pub_transaction_completed_ = sg4::ConditionVariable::create();
28+
29+
unsigned int current_sub_transaction_id_ = 0;
30+
bool sub_transaction_in_progress_ = false;
2431

2532
protected:
2633
void begin_pub_transaction() override;
@@ -29,6 +36,7 @@ class StagingEngine : public Engine {
2936
void begin_sub_transaction() override;
3037
void end_sub_transaction() override;
3138
void sub_close() override;
39+
[[nodiscard]] unsigned int get_current_transaction() const noexcept override { return current_pub_transaction_id_; }
3240

3341
public:
3442
explicit StagingEngine(const std::string& name, const std::shared_ptr<Stream>& stream)

0 commit comments

Comments
 (0)