D-Bus server: simplified internal timeout API
The API supported repeating timeouts, but none of the users of it needed that. To fit the API, they were forced to return a boolean value, which prevented binding to callbacks without such a return value. That'll be useful, so let's simplify the code...
This commit is contained in:
parent
9d9b6d8b57
commit
a5a85adaf6
2 changed files with 10 additions and 17 deletions
|
@ -562,12 +562,10 @@ void Server::removeSyncSession(Session *session)
|
|||
}
|
||||
}
|
||||
|
||||
static bool quitLoop(GMainLoop *loop)
|
||||
static void quitLoop(GMainLoop *loop)
|
||||
{
|
||||
SE_LOG_DEBUG(NULL, NULL, "stopping server's event loop");
|
||||
g_main_loop_quit(loop);
|
||||
// don't call me again
|
||||
return false;
|
||||
}
|
||||
|
||||
void Server::checkQueue()
|
||||
|
@ -601,12 +599,10 @@ void Server::checkQueue()
|
|||
}
|
||||
}
|
||||
|
||||
bool Server::sessionExpired(const boost::shared_ptr<Session> &session)
|
||||
void Server::sessionExpired(const boost::shared_ptr<Session> &session)
|
||||
{
|
||||
SE_LOG_DEBUG(NULL, NULL, "session %s expired",
|
||||
session->getSessionID().c_str());
|
||||
// don't call me again
|
||||
return false;
|
||||
}
|
||||
|
||||
void Server::delaySessionDestruction(const boost::shared_ptr<Session> &session)
|
||||
|
@ -691,17 +687,14 @@ void Server::passwordResponse(const InfoReq::InfoMap &response,
|
|||
}
|
||||
|
||||
|
||||
bool Server::callTimeout(const boost::shared_ptr<Timeout> &timeout, const boost::function<bool ()> &callback)
|
||||
bool Server::callTimeout(const boost::shared_ptr<Timeout> &timeout, const boost::function<void ()> &callback)
|
||||
{
|
||||
if (!callback()) {
|
||||
m_timeouts.remove(timeout);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
callback();
|
||||
m_timeouts.remove(timeout);
|
||||
return false;
|
||||
}
|
||||
|
||||
void Server::addTimeout(const boost::function<bool ()> &callback,
|
||||
void Server::addTimeout(const boost::function<void ()> &callback,
|
||||
int seconds)
|
||||
{
|
||||
boost::shared_ptr<Timeout> timeout(new Timeout);
|
||||
|
|
|
@ -370,10 +370,10 @@ class Server : public GDBusCXX::DBusObjectHelper,
|
|||
* called each time a timeout triggers,
|
||||
* removes those which are done
|
||||
*/
|
||||
bool callTimeout(const boost::shared_ptr<Timeout> &timeout, const boost::function<bool ()> &callback);
|
||||
bool callTimeout(const boost::shared_ptr<Timeout> &timeout, const boost::function<void ()> &callback);
|
||||
|
||||
/** called 1 minute after last client detached from a session */
|
||||
static bool sessionExpired(const boost::shared_ptr<Session> &session);
|
||||
static void sessionExpired(const boost::shared_ptr<Session> &session);
|
||||
|
||||
public:
|
||||
Server(GMainLoop *loop,
|
||||
|
@ -536,7 +536,7 @@ public:
|
|||
* before that time, then the callback will be deleted without
|
||||
* being called.
|
||||
*/
|
||||
void addTimeout(const boost::function<bool ()> &callback,
|
||||
void addTimeout(const boost::function<void ()> &callback,
|
||||
int seconds);
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue