Esempio n. 1
0
void
QmfObject::run_pending_calls(void)
{
	Agent a = _qmf_data.getAgent();
	for (list<QmfAsyncRequest*>::iterator it = _pending_jobs.begin();
		     it != _pending_jobs.end(); ++it) {
		QmfAsyncRequest* ar = *it;
		qb_loop_timer_handle th;
		uint32_t correlation_id = a.callMethodAsync(ar->method, ar->args, _qmf_data.getAddr());
		_outstanding_calls[correlation_id] = ar;
		g_timer_stop(ar->time_queued);
		g_timer_start(ar->time_execed);
		ar->state = QmfAsyncRequest::JOB_RUNNING;
		ar->ref();
		mainloop_timer_add(ar->timeout, ar,
				   method_call_tmo, &th);
	}
}
Esempio n. 2
0
void
QmfObject::method_call_async(std::string method,
			     qpid::types::Variant::Map in_args,
			     void *user_data,
			     uint32_t timeout_ms)
{
	uint32_t correlation_id;
	QmfAsyncRequest *ar;

	if (_method_response_fn == NULL) {
		qb_log(LOG_WARNING,
		       "can't do async call without response callback");
		return;
	}

	ar = new QmfAsyncRequest();
	ar->method = method;
	ar->args = in_args;
	ar->obj = this;
	ar->user_data = user_data;
	ar->timeout = timeout_ms;

	if (_connected) {
		qb_loop_timer_handle th;
		Agent a = _qmf_data.getAgent();
		correlation_id = a.callMethodAsync(method, in_args, _qmf_data.getAddr());
		_outstanding_calls[correlation_id] = ar;
		g_timer_stop(ar->time_queued);
		g_timer_start(ar->time_execed);
		ar->state = QmfAsyncRequest::JOB_RUNNING;
		ar->ref();
		mainloop_timer_add(timeout_ms, ar,
				   method_call_tmo, &th);
	} else {
		ar->state = QmfAsyncRequest::JOB_SCHEDULED;
		g_timer_start(ar->time_queued);
		_pending_jobs.push_back(ar);
	}
}