Fix Windows line feeds and chdmod

actorid
athile 15 years ago
parent 5825af45c3
commit 450542b4b9

@ -1,2 +1,2 @@
project(clientconsole) project(clientconsole)
add_executable(clientconsole client.cpp) add_executable(clientconsole client.cpp)

@ -108,7 +108,7 @@ int main(int argc, char* argv[])
do do
{ {
std::cout << "Client> "; std::cout << "Client> ";
std::string buffer; std::string buffer;
std::getline(std::cin, buffer); std::getline(std::cin, buffer);
if (buffer == "quit") if (buffer == "quit")

@ -1,19 +1,19 @@
#ifndef COMMANDSERVER_COMMAND_HPP #ifndef COMMANDSERVER_COMMAND_HPP
#define COMMANDSERVER_COMMAND_HPP #define COMMANDSERVER_COMMAND_HPP
namespace OMW namespace OMW
{ {
/// ///
/// A Command is currently defined as a string input that, when processed, /// A Command is currently defined as a string input that, when processed,
/// will generate a string output. The string output is passed to the /// will generate a string output. The string output is passed to the
/// mReplyFunction as soon as the command has been processed. /// mReplyFunction as soon as the command has been processed.
/// ///
class Command class Command
{ {
public: public:
std::string mCommand; std::string mCommand;
boost::function1<void, std::string> mReplyFunction; boost::function1<void, std::string> mReplyFunction;
}; };
} }
#endif COMMANDSERVER_COMMAND_HPP #endif COMMANDSERVER_COMMAND_HPP

@ -6,51 +6,51 @@
// //
// Adapted from http://www.justsoftwaresolutions.co.uk/threading/implementing-a-thread-safe-queue-using-condition-variables.html // Adapted from http://www.justsoftwaresolutions.co.uk/threading/implementing-a-thread-safe-queue-using-condition-variables.html
// //
template<typename Data> template<typename Data>
class TsDeque class TsDeque
{ {
private: private:
std::deque<Data> the_queue; std::deque<Data> the_queue;
mutable boost::mutex the_mutex; mutable boost::mutex the_mutex;
boost::condition_variable the_condition_variable; boost::condition_variable the_condition_variable;
public: public:
void push_back(Data const& data) void push_back(Data const& data)
{ {
boost::mutex::scoped_lock lock(the_mutex); boost::mutex::scoped_lock lock(the_mutex);
the_queue.push_back(data); the_queue.push_back(data);
lock.unlock(); lock.unlock();
the_condition_variable.notify_one(); the_condition_variable.notify_one();
} }
bool empty() const bool empty() const
{ {
boost::mutex::scoped_lock lock(the_mutex); boost::mutex::scoped_lock lock(the_mutex);
return the_queue.empty(); return the_queue.empty();
} }
bool try_pop_front(Data& popped_value) bool try_pop_front(Data& popped_value)
{ {
boost::mutex::scoped_lock lock(the_mutex); boost::mutex::scoped_lock lock(the_mutex);
if(the_queue.empty()) if(the_queue.empty())
return false; return false;
popped_value=the_queue.front(); popped_value=the_queue.front();
the_queue.pop_front(); the_queue.pop_front();
return true; return true;
} }
void wait_and_pop_front(Data& popped_value) void wait_and_pop_front(Data& popped_value)
{ {
boost::mutex::scoped_lock lock(the_mutex); boost::mutex::scoped_lock lock(the_mutex);
while(the_queue.empty()) while(the_queue.empty())
{ {
the_condition_variable.wait(lock); the_condition_variable.wait(lock);
} }
popped_value=the_queue.front(); popped_value=the_queue.front();
the_queue.pop_front(); the_queue.pop_front();
} }
}; };
#endif // TSDEQUE_H #endif // TSDEQUE_H

Loading…
Cancel
Save