From 0b27c37fe95c6aced613d51a3624f8930a96ad3f Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 4 Jun 2009 22:23:07 +0200 Subject: RequestHandler-Interface ?berarbeitet --- src/madc.cpp | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) (limited to 'src/madc.cpp') diff --git a/src/madc.cpp b/src/madc.cpp index 40bd51c..64078c8 100644 --- a/src/madc.cpp +++ b/src/madc.cpp @@ -37,21 +37,10 @@ using namespace Mad; -static bool commandRunning = false; -static boost::mutex commandMutex; -static boost::condition_variable commandNotify; - static void usage(const std::string &cmd) { std::cerr << "Usage: " << cmd << " address" << std::endl; } -static void commandFinished() { - boost::lock_guard lock(commandMutex); - commandRunning = false; - - commandNotify.notify_one(); -} - int main(int argc, char *argv[]) { if(argc != 2) { usage(argv[0]); @@ -75,12 +64,9 @@ int main(int argc, char *argv[]) { Common::RequestManager::get()->registerConnection(connection); { - boost::unique_lock lock(commandMutex); - commandRunning = true; - Common::RequestManager::get()->sendRequest0(connection, boost::bind(&commandFinished)); - while(commandRunning) { - commandNotify.wait(lock); - } + boost::shared_ptr request(new Common::Requests::IdentifyRequest); + Common::RequestManager::get()->sendRequest(connection, request); + request->wait(); } std::cerr << " connected." << std::endl; @@ -92,13 +78,10 @@ int main(int argc, char *argv[]) { std::cerr << " done." << std::endl << std::endl; Client::CommandParser::get()->setConnection(connection); - Client::CommandManager::get()->connectSignalFinished(&commandFinished); - while(connection->isConnected() && !Client::CommandManager::get()->willDisconnect()) { + while(connection->isConnected() && !Client::CommandParser::get()->willDisconnect()) { char *cmd = readline("mad> "); - boost::unique_lock lock(commandMutex); - if(!cmd) { Client::CommandParser::get()->requestDisconnect(); } @@ -107,11 +90,6 @@ int main(int argc, char *argv[]) { add_history(cmd); } else continue; - - commandRunning = Client::CommandManager::get()->requestsActive(); - - while(commandRunning) - commandNotify.wait(lock); } connection->waitWhileConnected(); -- cgit v1.2.3