MCPcopy Create free account
hub / github.com/apache/qpid-proton / tryToSend

Method tryToSend

cpp/examples/broker.cpp:132–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130 subscriptions::iterator current_;
131
132 void tryToSend() {
133 DOUT(std::cerr << "Queue: " << this << " tryToSend: " << subscriptions_.size(););
134 // Starting at current_, send messages to subscriptions with credit:
135 // After each send try to find another subscription; Wrap around;
136 // Finish when we run out of messages or credit.
137 size_t outOfCredit = 0;
138 while (!messages_.empty() && outOfCredit<subscriptions_.size()) {
139 // If we got the end (or haven't started yet) start at the beginning
140 if (current_==subscriptions_.end()) {
141 current_=subscriptions_.begin();
142 }
143 // If we have credit send the message
144 DOUT(std::cerr << "(" << current_->second << ") ";);
145 if (current_->second>0) {
146 DOUT(std::cerr << current_->first << " ";);
147 auto msg = messages_.front();
148 auto sender = current_->first;
149 sender->add([=]{sender->sendMsg(msg);});
150 messages_.pop_front();
151 --current_->second;
152 ++current_;
153 } else {
154 ++outOfCredit;
155 }
156 }
157 DOUT(std::cerr << "\n";);
158 }
159
160public:
161 Queue(proton::container& c, const std::string& n) :

Callers

nothing calls this directly

Calls 6

sendMsgMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected