SourceForge Patches ID: 2701443 - Add methods to adjust timeout. Submitted: Oron Peled ( oron ) - 2009-03-21 23:27:55 CET
This commit is contained in:
parent
7889c46e57
commit
d083d07167
3 changed files with 25 additions and 4 deletions
|
@ -52,6 +52,10 @@ public:
|
|||
|
||||
inline Connection &conn();
|
||||
|
||||
void set_timeout(int new_timeout = -1);
|
||||
|
||||
inline int get_timeout() const;
|
||||
|
||||
private:
|
||||
|
||||
DXXAPILOCAL virtual bool handle_message(const Message &) = 0;
|
||||
|
@ -63,6 +67,7 @@ private:
|
|||
Connection _conn;
|
||||
DBus::Path _path;
|
||||
std::string _service;
|
||||
int _default_timeout;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -83,6 +88,11 @@ const std::string &Object::service() const
|
|||
return _service;
|
||||
}
|
||||
|
||||
int Object::get_timeout() const
|
||||
{
|
||||
return _default_timeout;
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
|
|
|
@ -109,8 +109,11 @@ Timeout *BusDispatcher::add_timeout(Timeout::Internal *ti)
|
|||
bt->expired = new Callback<BusDispatcher, void, DefaultTimeout &>(this, &BusDispatcher::timeout_expired);
|
||||
bt->data(bt);
|
||||
|
||||
debug_log("added timeout %p (%s) interval=%d",
|
||||
bt, ((Timeout *)bt)->enabled() ? "on":"off", ((Timeout *)bt)->interval());
|
||||
debug_log("added timeout %p (%s) (%d millies)",
|
||||
bt,
|
||||
((Timeout*)bt)->enabled() ? "on":"off",
|
||||
((Timeout*)bt)->interval()
|
||||
);
|
||||
|
||||
return bt;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
using namespace DBus;
|
||||
|
||||
Object::Object(Connection &conn, const Path &path, const char *service)
|
||||
: _conn(conn), _path(path), _service(service ? service : "")
|
||||
: _conn(conn), _path(path), _service(service ? service : ""), _default_timeout(-1)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,14 @@ Object::~Object()
|
|||
{
|
||||
}
|
||||
|
||||
void Object::set_timeout(int new_timeout)
|
||||
{
|
||||
debug_log("%s: %d millies", __PRETTY_FUNCTION__, new_timeout);
|
||||
if(new_timeout < 0 && new_timeout != -1)
|
||||
throw ErrorInvalidArgs("Bad timeout, cannot set it");
|
||||
_default_timeout = new_timeout;
|
||||
}
|
||||
|
||||
struct ObjectAdaptor::Private
|
||||
{
|
||||
static void unregister_function_stub(DBusConnection *, void *);
|
||||
|
@ -329,7 +337,7 @@ Message ObjectProxy::_invoke_method(CallMessage &call)
|
|||
if (call.destination() == NULL)
|
||||
call.destination(service().c_str());
|
||||
|
||||
return conn().send_blocking(call);
|
||||
return conn().send_blocking(call, get_timeout());
|
||||
}
|
||||
|
||||
bool ObjectProxy::_invoke_method_noreply(CallMessage &call)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue