Fix ubuntu compile errors
This commit is contained in:
parent
1dd558d57e
commit
44bf4dcb6e
|
@ -196,7 +196,6 @@ message(STATUS "Build revision: ${BUILD_REVISION}")
|
|||
add_definitions(-D"BUILD_REVISION=\\\"${BUILD_REVISION}\\\"")
|
||||
|
||||
# find boost
|
||||
set(framework_DEFINITIONS ${framework_DEFINITIONS} -DBOOST_THREAD_PROVIDES_FUTURE) # enable boost::future
|
||||
set(REQUIRED_BOOST_COMPONENTS system thread chrono)
|
||||
if(WIN32)
|
||||
set(Boost_THREADAPI win32)
|
||||
|
|
|
@ -35,9 +35,9 @@ public:
|
|||
void stop();
|
||||
|
||||
template<class F>
|
||||
std::future<typename std::result_of<F()>::type> schedule(const F& task) {
|
||||
boost::unique_future<typename std::result_of<F()>::type> schedule(const F& task) {
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
auto prom = std::make_shared<std::promise<typename std::result_of<F()>::type>>();
|
||||
auto prom = std::make_shared<boost::promise<typename std::result_of<F()>::type>>();
|
||||
m_tasks.push_back([=]() { prom->set_value(task()); });
|
||||
m_condition.notify_all();
|
||||
return prom->get_future();
|
||||
|
@ -48,8 +48,8 @@ protected:
|
|||
|
||||
private:
|
||||
std::list<std::function<void()>> m_tasks;
|
||||
std::mutex m_mutex;
|
||||
std::list<std::thread> m_threads;
|
||||
std::mutex m_mutex;
|
||||
std::condition_variable m_condition;
|
||||
stdext::boolean<false> m_running;
|
||||
};
|
||||
|
|
|
@ -96,9 +96,9 @@ void SoundManager::poll()
|
|||
|
||||
for(auto it = m_streamFiles.begin(); it != m_streamFiles.end();) {
|
||||
StreamSoundSourcePtr source = it->first;
|
||||
std::future<SoundFilePtr>& future = it->second;
|
||||
auto& future = it->second;
|
||||
|
||||
if(std::is_ready(future)) {
|
||||
if(future.is_ready()) {
|
||||
SoundFilePtr sound = future.get();
|
||||
if(sound)
|
||||
source->setSoundFile(sound);
|
||||
|
@ -264,7 +264,7 @@ SoundSourcePtr SoundManager::createSoundSource(const std::string& filename)
|
|||
source = combinedSource;
|
||||
#else
|
||||
StreamSoundSourcePtr streamSource(new StreamSoundSource);
|
||||
m_streamFiles[streamSource] = m_loadJobs [=]() -> SoundFilePtr {
|
||||
m_streamFiles[streamSource] = g_asyncDispatcher.schedule([=]() -> SoundFilePtr {
|
||||
try {
|
||||
return SoundFile::loadSoundFile(filename);
|
||||
} catch(std::exception& e) {
|
||||
|
|
|
@ -57,7 +57,7 @@ private:
|
|||
ALCdevice *m_device;
|
||||
ALCcontext *m_context;
|
||||
|
||||
std::map<StreamSoundSourcePtr, std::future<SoundFilePtr>> m_streamFiles;
|
||||
std::map<StreamSoundSourcePtr, boost::unique_future<SoundFilePtr>> m_streamFiles;
|
||||
std::unordered_map<std::string, SoundBufferPtr> m_buffers;
|
||||
std::vector<SoundSourcePtr> m_sources;
|
||||
stdext::boolean<true> m_audioEnabled;
|
||||
|
|
|
@ -23,48 +23,33 @@
|
|||
#ifndef THREAD_H
|
||||
#define THREAD_H
|
||||
|
||||
#include <boost/thread/future.hpp>
|
||||
|
||||
// hack to enable std::thread on mingw32 4.6
|
||||
#if !defined(_GLIBCXX_HAS_GTHREADS) && defined(__GNUG__)
|
||||
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/recursive_mutex.hpp>
|
||||
#include <boost/thread/locks.hpp>
|
||||
#include <boost/thread/future.hpp>
|
||||
#include <boost/thread/condition_variable.hpp>
|
||||
|
||||
namespace std {
|
||||
using boost::thread;
|
||||
using boost::future;
|
||||
using boost::future_status;
|
||||
using boost::promise;
|
||||
|
||||
using boost::mutex;
|
||||
using boost::timed_mutex;
|
||||
using boost::recursive_mutex;
|
||||
using boost::recursive_timed_mutex;
|
||||
|
||||
using boost::lock_guard;
|
||||
using boost::unique_lock;
|
||||
|
||||
using boost::condition_variable;
|
||||
using boost::condition_variable_any;
|
||||
|
||||
template<typename R>
|
||||
bool is_ready(std::future<R>& f)
|
||||
{ return f.wait_for(boost::chrono::seconds(0)) == future_status::ready; }
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <thread>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <future>
|
||||
|
||||
namespace std {
|
||||
template<typename R>
|
||||
bool is_ready(std::future<R>& f)
|
||||
{ return f.wait_for(chrono::seconds(0)) == future_status::ready; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue