void blocking_connection_impl::wait(const condition &condition, const std::string &msg, duration wait_timeout)
{
    reactor& reactor = container_->reactor();

    if (wait_timeout == duration(-1))
        wait_timeout = container_->reactor().timeout();

    if (wait_timeout == duration::FOREVER) {
        while (!condition()) {
            reactor.process();
        }
    } else {
        save_timeout st(reactor);
        reactor.timeout(wait_timeout);
        pn_timestamp_t deadline = pn_reactor_mark(pn_cast(&reactor)) + wait_timeout.milliseconds;
        while (!condition()) {
            reactor.process();
            if (!condition()) {
                pn_timestamp_t now = pn_reactor_mark(pn_cast(&reactor));
                if (now < deadline)
                    reactor.timeout(duration(deadline - now));
                else
                    throw timeout_error("connection timed out " + msg);
            }
        }
    }
}
예제 #2
0
bool encoder::encode(char* buffer, size_t& size) {
    save_state ss(pn_cast(this)); // In case of error
    ssize_t result = pn_data_encode(pn_cast(this), buffer, size);
    if (result == PN_OVERFLOW) {
        result = pn_data_encoded_size(pn_cast(this));
        if (result >= 0) {
            size = result;
            return false;
        }
    }
    check(result, pn_cast(this));
    size = result;
    ss.cancel();                // Don't restore state, all is well.
    pn_data_clear(pn_cast(this));
    return true;
}
blocking_connection_impl::blocking_connection_impl(const url& url, duration timeout) :
    container_(new container())
{
    container_->reactor().start();
    container_->reactor().timeout(timeout);
    connection_ = container_->connect(url, this).ptr(); // Set this as handler.
    wait(connection_opening(pn_cast(connection_.get())));
}
예제 #4
0
session& connection::default_session() {
    struct connection_context& ctx = connection_context::get(pn_cast(this));
    if (!ctx.default_session) {
        ctx.default_session = &create_session();
        ctx.default_session->open();
    }
    return *ctx.default_session;
}
예제 #5
0
encoder& operator<<(encoder& e, const start& s) {
    switch (s.type) {
    case ARRAY:
        pn_data_put_array(pn_cast(&e), s.is_described, pn_type_t(s.element));
        break;
    case MAP:
        pn_data_put_map(pn_cast(&e));
        break;
    case LIST:
        pn_data_put_list(pn_cast(&e));
        break;
    case DESCRIBED:
        pn_data_put_described(pn_cast(&e));
        break;
    default:
        throw encode_error(MSG("" << s.type << " is not a container type"));
    }
    pn_data_enter(pn_cast(&e));
    return e;
}
예제 #6
0
encoder& operator<<(encoder& e, amqp_long value) {
    return insert(e, pn_cast(&e), value, pn_data_put_long);
}
예제 #7
0
encoder& operator<<(encoder& e, amqp_timestamp value) {
    return insert(e, pn_cast(&e), value, pn_data_put_timestamp);
}
예제 #8
0
data& encoder::data() {
    return *data::cast(pn_cast(this));
}
예제 #9
0
파일: link.cpp 프로젝트: b-cuts/qpid-proton
terminus& link::remote_target() const { return *terminus::cast(pn_link_remote_target(pn_cast(this))); }
예제 #10
0
encoder& operator<<(encoder& e, amqp_symbol value) {
    return insert(e, pn_cast(&e), value, pn_data_put_symbol);
}
예제 #11
0
encoder& operator<<(encoder& e, const data& v) {
    if (pn_cast(&e) == pn_cast(&v)) throw encode_error("cannot insert into self");
    check(pn_data_append(pn_cast(&e), pn_cast(&v)), pn_cast(&e));
    return e;
}
예제 #12
0
파일: link.cpp 프로젝트: b-cuts/qpid-proton
endpoint::state link::state() const { return pn_link_state(pn_cast(this)); }
예제 #13
0
encoder& operator<<(encoder& e, amqp_decimal128 value) {
    return insert(e, pn_cast(&e), value, pn_data_put_decimal128);
}
예제 #14
0
파일: link.cpp 프로젝트: b-cuts/qpid-proton
void link::handler(class handler &h) {
    pn_record_t *record = pn_link_attachments(pn_cast(this));
    connection_context& cc(connection_context::get(pn_cast(&connection())));
    counted_ptr<pn_handler_t> chandler = cc.container_impl->cpp_handler(&h);
    pn_record_set_handler(record, chandler.get());
}
예제 #15
0
파일: link.cpp 프로젝트: b-cuts/qpid-proton
void link::detach_handler() {
    pn_record_t *record = pn_link_attachments(pn_cast(this));
    pn_record_set_handler(record, 0);
}
예제 #16
0
파일: link.cpp 프로젝트: b-cuts/qpid-proton
class session &link::session() const {
    return *session::cast(pn_link_session(pn_cast(this)));
}
예제 #17
0
파일: link.cpp 프로젝트: b-cuts/qpid-proton
class connection &link::connection() const {
    return *connection::cast(pn_session_connection(pn_link_session(pn_cast(this))));
}
예제 #18
0
파일: link.cpp 프로젝트: b-cuts/qpid-proton
std::string link::name() const { return std::string(pn_link_name(pn_cast(this)));}
예제 #19
0
encoder& operator<<(encoder& e, amqp_float value) {
    return insert(e, pn_cast(&e), value, pn_data_put_float);
}
예제 #20
0
delivery& blocking_sender::send(const message_value &msg, duration timeout) {
    delivery& dlv = sender().send(msg);
    connection_.impl_->wait(delivery_settled(pn_cast(&dlv)), "sending on sender " + link_->name(), timeout);
    return dlv;
}
예제 #21
0
encoder& operator<<(encoder& e, amqp_double value) {
    return insert(e, pn_cast(&e), value, pn_data_put_double);
}
예제 #22
0
encoder& operator<<(encoder& e, finish) {
    pn_data_exit(pn_cast(&e));
    return e;
}
예제 #23
0
encoder& operator<<(encoder& e, amqp_uuid value) {
    return insert(e, pn_cast(&e), value, pn_data_put_uuid);
}
예제 #24
0
파일: link.cpp 프로젝트: b-cuts/qpid-proton
int link::credit() const {
    return pn_link_credit(pn_cast(this));
}
예제 #25
0
encoder& operator<<(encoder& e, amqp_binary value) {
    return insert(e, pn_cast(&e), value, pn_data_put_binary);
}
예제 #26
0
encoder& operator<<(encoder& e, amqp_boolean value) {
    return insert(e, pn_cast(&e), value, pn_data_put_bool);
}
예제 #27
0
파일: link.cpp 프로젝트: b-cuts/qpid-proton
const receiver* link::receiver() const {
    return pn_link_is_receiver(pn_cast(this)) ? reinterpret_cast<const class receiver*>(this) : 0;
}
예제 #28
0
encoder& operator<<(encoder& e, amqp_char value) {
    return insert(e, pn_cast(&e), value, pn_data_put_char);
}
예제 #29
0
encoder& operator<<(encoder& e, amqp_null) {
    pn_data_put_null(pn_cast(&e));
    return e;
}
예제 #30
0
파일: link.cpp 프로젝트: b-cuts/qpid-proton
terminus& link::remote_source() const { return *terminus::cast(pn_link_remote_source(pn_cast(this))); }