Skip to content

Commit eb8afbd

Browse files
committed
Clean up the code
1 parent 2d3828f commit eb8afbd

File tree

14 files changed

+11
-569
lines changed

14 files changed

+11
-569
lines changed

cpp/examples/tx_recv.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class tx_recv : public proton::messaging_handler, proton::transaction_handler {
4646
int committed = 0;
4747

4848
proton::session session;
49-
// proton::transaction transaction;
5049
public:
5150
tx_recv(const std::string &s, int c, int b):
5251
url(s), expected(c), batch_size(b) {}
@@ -72,18 +71,14 @@ class tx_recv : public proton::messaging_handler, proton::transaction_handler {
7271
void on_transaction_declared(proton::session s) override {
7372
std::cout << "[on_transaction_declared] txn called " << (&s)
7473
<< std::endl;
75-
// std::cout << "[on_transaction_declared] txn is_empty " << (t.is_empty())
76-
// << "\t" << transaction.is_empty() << std::endl;
77-
receiver.add_credit(batch_size);
78-
// transaction = t;
74+
receiver.add_credit(batch_size);
7975
}
8076

8177
void on_message(proton::delivery &d, proton::message &msg) override {
8278
std::cout<<"# MESSAGE: " << msg.id() <<": " << msg.body() << std::endl;
8379
session.txn_accept(d);
8480
current_batch += 1;
8581
if(current_batch == batch_size) {
86-
// transaction = proton::transaction(); // null
8782
}
8883
}
8984

cpp/examples/tx_send.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class tx_send : public proton::messaging_handler, proton::transaction_handler {
4949
int confirmed = 0;
5050

5151
proton::session session;
52-
// proton::transaction transaction;
52+
5353
public:
5454
tx_send(const std::string &s, int c, int b):
5555
url(s), total(c), batch_size(b), sent(0) {}
@@ -96,7 +96,7 @@ class tx_send : public proton::messaging_handler, proton::transaction_handler {
9696

9797
msg.id(unique_id++);
9898
msg.body(m);
99-
std::cout << "##### [example] transaction send msg: " << msg
99+
std::cout << "[example] transaction send msg: " << msg
100100
<< std::endl;
101101
session.txn_send(sender, msg);
102102
current_batch += 1;

cpp/include/proton/session.hpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,6 @@ PN_CPP_CLASS_EXTERN session : public internal::object<pn_session_t>, public endp
109109

110110
PN_CPP_EXTERN void declare_transaction(proton::transaction_handler &handler, bool settle_before_discharge = false);
111111

112-
113-
// static transaction mk_transaction_impl(sender &s, transaction_handler &h,
114-
// bool f);
115-
// PN_CPP_EXTERN transaction(transaction_impl *impl);
116-
117-
// PN_CPP_EXTERN transaction();
118-
// PN_CPP_EXTERN ~transaction();
119112
PN_CPP_EXTERN bool txn_is_empty();
120113
PN_CPP_EXTERN bool txn_is_declared();
121114
PN_CPP_EXTERN void txn_commit();
@@ -126,10 +119,6 @@ PN_CPP_CLASS_EXTERN session : public internal::object<pn_session_t>, public endp
126119
PN_CPP_EXTERN void txn_accept(delivery &t);
127120
PN_CPP_EXTERN proton::connection txn_connection() const;
128121

129-
// PN_CPP_EXTERN session_context& get_session_context();
130-
131-
// transaction _txn;
132-
133122
/// @cond INTERNAL
134123
friend class internal::factory<session>;
135124
friend class session_iterator;

cpp/include/proton/target.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ class target : public terminus {
6565
/// @endcond
6666
};
6767

68-
69-
/// TODO: A point of coordinator for messages.
70-
///
7168
class coordinator : public terminus {
7269
public:
7370
/// Create an empty coordinator.

cpp/include/proton/transaction.hpp

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -36,69 +36,6 @@
3636
namespace proton {
3737

3838
class transaction_handler;
39-
// class transaction_impl;
40-
41-
// TODO: This should not be accessible to users.
42-
// class transaction_impl {
43-
// public:
44-
// proton::sender txn_ctrl;
45-
// proton::transaction_handler *handler = nullptr;
46-
// proton::binary id;
47-
// proton::tracker _declare;
48-
// proton::tracker _discharge;
49-
// bool failed = false;
50-
// std::vector<proton::tracker> pending;
51-
52-
// void commit();
53-
// void abort();
54-
// void declare();
55-
// proton::tracker send(proton::sender s, proton::message msg);
56-
57-
// void discharge(bool failed);
58-
// void release_pending();
59-
// void accept(delivery &d);
60-
// void update(tracker &d, uint64_t state);
61-
// void set_id(binary _id);
62-
63-
// proton::tracker send_ctrl(proton::symbol descriptor, proton::value _value);
64-
// void handle_outcome(proton::tracker t);
65-
// transaction_impl(proton::sender &_txn_ctrl,
66-
// proton::transaction_handler &_handler,
67-
// bool _settle_before_discharge);
68-
69-
// // delete copy and assignment operator to ensure no copy of this object is
70-
// // every made transaction_impl(const transaction_impl&) = delete;
71-
// // transaction_impl& operator=(const transaction_impl&) = delete;
72-
// };
73-
74-
// class
75-
// PN_CPP_CLASS_EXTERN transaction {
76-
// private:
77-
// // PN_CPP_EXTERN transaction(proton::sender& _txn_ctrl,
78-
// // proton::transaction_handler& _handler, bool _settle_before_discharge);
79-
80-
// static transaction mk_transaction_impl(sender &s, transaction_handler &h,
81-
// bool f);
82-
// PN_CPP_EXTERN transaction(transaction_impl *impl);
83-
// transaction_impl *_impl;
84-
85-
// public:
86-
// // TODO:
87-
// // PN_CPP_EXTERN transaction(transaction &o);
88-
// PN_CPP_EXTERN transaction();
89-
// PN_CPP_EXTERN ~transaction();
90-
// PN_CPP_EXTERN bool is_empty();
91-
// PN_CPP_EXTERN void commit();
92-
// PN_CPP_EXTERN void abort();
93-
// PN_CPP_EXTERN void declare();
94-
// PN_CPP_EXTERN void handle_outcome(proton::tracker);
95-
// PN_CPP_EXTERN proton::tracker send(proton::sender s, proton::message msg);
96-
// PN_CPP_EXTERN void accept(delivery &t);
97-
// PN_CPP_EXTERN proton::connection connection() const;
98-
99-
// friend class transaction_impl;
100-
// friend class session;
101-
// };
10239

10340
class
10441
PN_CPP_CLASS_EXTERN transaction_handler {

cpp/include/proton/transfer.hpp

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,9 @@
3333
/// @copybrief proton::transfer
3434

3535
struct pn_delivery_t;
36-
// struct pn_disposition_t;
3736

3837
namespace proton {
3938

40-
// class disposition : public internal::object<pn_disposition_t> {
41-
// /// @cond INTERNAL
42-
// disposition(pn_disposition_t *d) : internal::object<pn_disposition_t>(d) {}
43-
// /// @endcond
44-
45-
// public:
46-
// /// Create an empty disposition.
47-
// disposition() : internal::object<pn_disposition_t>(0) {}
48-
49-
// proton::value data() const;
50-
51-
// /// @cond INTERNAL
52-
// friend class internal::factory<disposition>;
53-
// /// @endcond
54-
// };
55-
5639
/// The base class for delivery and tracker.
5740
class transfer : public internal::object<pn_delivery_t> {
5841
/// @cond INTERNAL
@@ -94,28 +77,20 @@ class transfer : public internal::object<pn_delivery_t> {
9477
/// Return true if the transfer has been settled.
9578
PN_CPP_EXTERN bool settled() const;
9679

97-
// Set transaction
98-
// PN_CPP_EXTERN void transaction(transaction t);
99-
100-
// PN_CPP_EXTERN class transaction transaction() const;
101-
10280
/// Set user data on this transfer.
10381
PN_CPP_EXTERN void user_data(void* user_data) const;
10482

10583
/// Get user data from this transfer.
10684
PN_CPP_EXTERN void* user_data() const;
10785

108-
// PN_CPP_EXTERN disposition remote();
109-
// PN_CPP_EXTERN disposition local();
110-
11186
/// @cond INTERNAL
11287
friend class internal::factory<transfer>;
11388
/// @endcond
11489
};
11590

116-
/// Human-readable name of the transfer::state
91+
/// Human-readalbe name of the transfer::state
11792
PN_CPP_EXTERN std::string to_string(enum transfer::state);
118-
/// Human-readable name of the transfer::state
93+
/// Human-readalbe name of the transfer::state
11994
PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const enum transfer::state);
12095

12196
} // proton

cpp/src/contexts.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ namespace proton {
4242

4343
class proton_handler;
4444
class connector;
45-
// class transaction;
4645

4746
namespace io {class link_namer;}
4847

@@ -153,6 +152,7 @@ class session_context : public context {
153152
public:
154153
session_context() : handler(0), user_data_(nullptr) {}
155154
static session_context& get(pn_session_t* s);
155+
156156
transaction_impl* _txn_impl;
157157
messaging_handler* handler;
158158
void* user_data_;
@@ -163,7 +163,6 @@ class transfer_context : public context {
163163
transfer_context() : user_data_(nullptr) {}
164164
static transfer_context& get(pn_delivery_t* s);
165165

166-
// std::unique_ptr<transaction> transaction_;
167166
void* user_data_;
168167
};
169168

cpp/src/messaging_adapter.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ void message_decode(message& msg, proton::delivery delivery) {
112112
msg.decode(buf);
113113
pn_link_advance(unwrap(link));
114114
}
115+
115116
void on_delivery(messaging_handler& handler, pn_event_t* event) {
116117
pn_link_t *lnk = pn_event_link(event);
117118
pn_delivery_t *dlv = pn_event_delivery(event);
@@ -301,38 +302,25 @@ void on_link_local_open(messaging_handler& handler, pn_event_t* event) {
301302
void on_link_remote_open(messaging_handler& handler, pn_event_t* event) {
302303
auto lnk = pn_event_link(event);
303304
int type = pn_terminus_get_type(pn_link_remote_target(lnk));
304-
std::cout << " on_link_remote_open, type:" << type << std::endl;
305305
if (pn_terminus_get_type(pn_link_remote_target(lnk))==PN_COORDINATOR) {
306306
auto cond = pn_link_condition(lnk);
307307
if (pn_condition_is_set(cond)) {
308-
std::cout<<" Got condition on_link_remote_open(.PN_COORDINATOR): "
309-
<< pn_event_type_name(pn_event_type(event)) << " "
310-
<< pn_condition_get_name(cond) << " "
311-
<< pn_condition_get_description(cond) << std::endl;
312-
313308
pn_condition_set_name(cond, "amqp:on_link_remote_open:FAILED");
314309
pn_link_close(lnk);
315310
return;
316311
}
317-
std::cout<<" IN on_link_remote_open(.PN_COORDINATOR) success " << std::endl;
318-
std::cout<<" IN on_link_remote_open(.PN_COORDINATOR) have handler " << &handler << std::endl;
319-
320312
return;
321313
}
322314
if (pn_link_state(lnk) & PN_LOCAL_UNINIT) { // Incoming link
323315
// Copy source and target from remote end.
324-
std::cout<<" Inside on_link_remote_open() .. PN_LOCAL_UNINIT " << std::endl;
325-
326316
pn_terminus_copy(pn_link_source(lnk), pn_link_remote_source(lnk));
327317
pn_terminus_copy(pn_link_target(lnk), pn_link_remote_target(lnk));
328318
}
329319
if (pn_link_is_receiver(lnk)) {
330-
std::cout<<" Inside on_link_remote_open() .. pn_link_is_receiver " << std::endl;
331320
receiver r(make_wrapper<receiver>(lnk));
332321
handler.on_receiver_open(r);
333322
credit_topup(lnk);
334323
} else {
335-
std::cout<<" Inside on_link_remote_open() .. sender " << std::endl;
336324
sender s(make_wrapper<sender>(lnk));
337325
handler.on_sender_open(s);
338326
}

cpp/src/proactor_container_impl.cpp

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
#include <random>
5555

5656
// XXXX: Debug
57-
#include <iostream>
57+
// #include <iostream>
5858

5959
namespace proton {
6060

@@ -866,45 +866,4 @@ void container::impl::stop(const proton::error_condition& err) {
866866
pn_condition_free(error_condition);
867867
}
868868

869-
// TODO: declare this in separate internal header file
870-
// extern transaction mk_transaction_impl(sender&, transaction_handler&, bool);
871-
872-
// transaction container::impl::declare_transaction(proton::connection conn, proton::transaction_handler &handler, bool settle_before_discharge) {
873-
// class InternalTransactionHandler : public proton::messaging_handler {
874-
// // TODO: auto_settle
875-
876-
// void on_tracker_settle(proton::tracker &t) override {
877-
// std::cout<<" [InternalTransactionHandler][on_tracker_settle] called with tracker.txn"
878-
// << std::endl;
879-
// if (!t.transaction().is_empty()) {
880-
// t.transaction().handle_outcome(t);
881-
// }
882-
// }
883-
// };
884-
885-
// proton::target_options t;
886-
// std::vector<symbol> cap = {proton::symbol("amqp:local-transactions")};
887-
// t.capabilities(cap);
888-
// t.type(PN_COORDINATOR);
889-
890-
// proton::sender_options so;
891-
// so.name("txn-ctrl");
892-
// so.target(t);
893-
// static InternalTransactionHandler internal_handler; // internal_handler going out of scope. Fix it
894-
// so.handler(internal_handler);
895-
// std::cout<<" [declare_transaction] txn-name sender open with handler: " << &internal_handler << std::endl;
896-
897-
// static proton::sender s = conn.open_sender("does not matter", so);
898-
899-
// settle_before_discharge = false;
900-
901-
// std::cout<<" [declare_transaction] calling mk_transaction_impl" << std::endl;
902-
903-
// auto txn =
904-
// transaction::mk_transaction_impl(s, handler, settle_before_discharge);
905-
// std::cout<<" [declare_transaction] txn address:" << &txn << std::endl;
906-
907-
// return txn;
908-
// }
909-
910869
}

0 commit comments

Comments
 (0)