| 67 | } |
| 68 | |
| 69 | void receiver::drain() { |
| 70 | link_context &ctx = link_context::get(pn_object()); |
| 71 | if (ctx.draining) |
| 72 | throw proton::error("drain already in progress"); |
| 73 | else { |
| 74 | ctx.draining = true; |
| 75 | if (credit() > 0) |
| 76 | pn_link_set_drain(pn_object(), true); |
| 77 | else { |
| 78 | // Drain is already complete. No state to communicate over the wire. |
| 79 | // Create dummy flow event where "drain finish" can be detected. |
| 80 | pn_connection_t *pnc = pn_session_connection(pn_link_session(pn_object())); |
| 81 | pn_collector_put_object(pn_connection_collector(pnc), pn_object(), PN_LINK_FLOW); |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | receiver_iterator receiver_iterator::operator++() { |
| 87 | if (!!obj_) { |