mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-05-09 12:07:51 +03: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
|
@ -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…
Add table
Add a link
Reference in a new issue