mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 09:19:41 +00:00
Fix Windows line feeds and chdmod
This commit is contained in:
parent
5825af45c3
commit
450542b4b9
4 changed files with 67 additions and 67 deletions
|
@ -1,2 +1,2 @@
|
|||
project(clientconsole)
|
||||
add_executable(clientconsole client.cpp)
|
||||
project(clientconsole)
|
||||
add_executable(clientconsole client.cpp)
|
||||
|
|
|
@ -108,7 +108,7 @@ int main(int argc, char* argv[])
|
|||
do
|
||||
{
|
||||
std::cout << "Client> ";
|
||||
std::string buffer;
|
||||
std::string buffer;
|
||||
std::getline(std::cin, buffer);
|
||||
|
||||
if (buffer == "quit")
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
#ifndef COMMANDSERVER_COMMAND_HPP
|
||||
#define COMMANDSERVER_COMMAND_HPP
|
||||
|
||||
namespace OMW
|
||||
{
|
||||
///
|
||||
/// A Command is currently defined as a string input that, when processed,
|
||||
/// will generate a string output. The string output is passed to the
|
||||
/// mReplyFunction as soon as the command has been processed.
|
||||
///
|
||||
class Command
|
||||
{
|
||||
public:
|
||||
std::string mCommand;
|
||||
boost::function1<void, std::string> mReplyFunction;
|
||||
};
|
||||
}
|
||||
|
||||
#endif COMMANDSERVER_COMMAND_HPP
|
||||
#ifndef COMMANDSERVER_COMMAND_HPP
|
||||
#define COMMANDSERVER_COMMAND_HPP
|
||||
|
||||
namespace OMW
|
||||
{
|
||||
///
|
||||
/// A Command is currently defined as a string input that, when processed,
|
||||
/// will generate a string output. The string output is passed to the
|
||||
/// mReplyFunction as soon as the command has been processed.
|
||||
///
|
||||
class Command
|
||||
{
|
||||
public:
|
||||
std::string mCommand;
|
||||
boost::function1<void, std::string> mReplyFunction;
|
||||
};
|
||||
}
|
||||
|
||||
#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
|
||||
//
|
||||
template<typename Data>
|
||||
class TsDeque
|
||||
{
|
||||
private:
|
||||
std::deque<Data> the_queue;
|
||||
mutable boost::mutex the_mutex;
|
||||
boost::condition_variable the_condition_variable;
|
||||
|
||||
public:
|
||||
void push_back(Data const& data)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(the_mutex);
|
||||
the_queue.push_back(data);
|
||||
lock.unlock();
|
||||
the_condition_variable.notify_one();
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
boost::mutex::scoped_lock lock(the_mutex);
|
||||
return the_queue.empty();
|
||||
}
|
||||
|
||||
bool try_pop_front(Data& popped_value)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(the_mutex);
|
||||
if(the_queue.empty())
|
||||
return false;
|
||||
|
||||
popped_value=the_queue.front();
|
||||
the_queue.pop_front();
|
||||
return true;
|
||||
}
|
||||
|
||||
void wait_and_pop_front(Data& popped_value)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(the_mutex);
|
||||
while(the_queue.empty())
|
||||
{
|
||||
the_condition_variable.wait(lock);
|
||||
}
|
||||
|
||||
popped_value=the_queue.front();
|
||||
the_queue.pop_front();
|
||||
}
|
||||
template<typename Data>
|
||||
class TsDeque
|
||||
{
|
||||
private:
|
||||
std::deque<Data> the_queue;
|
||||
mutable boost::mutex the_mutex;
|
||||
boost::condition_variable the_condition_variable;
|
||||
|
||||
public:
|
||||
void push_back(Data const& data)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(the_mutex);
|
||||
the_queue.push_back(data);
|
||||
lock.unlock();
|
||||
the_condition_variable.notify_one();
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
boost::mutex::scoped_lock lock(the_mutex);
|
||||
return the_queue.empty();
|
||||
}
|
||||
|
||||
bool try_pop_front(Data& popped_value)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(the_mutex);
|
||||
if(the_queue.empty())
|
||||
return false;
|
||||
|
||||
popped_value=the_queue.front();
|
||||
the_queue.pop_front();
|
||||
return true;
|
||||
}
|
||||
|
||||
void wait_and_pop_front(Data& popped_value)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(the_mutex);
|
||||
while(the_queue.empty())
|
||||
{
|
||||
the_condition_variable.wait(lock);
|
||||
}
|
||||
|
||||
popped_value=the_queue.front();
|
||||
the_queue.pop_front();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // TSDEQUE_H
|
||||
|
|
Loading…
Reference in a new issue