diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b1fa1242..6bd2b958c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -190,7 +190,7 @@ if (HAVE_UNORDERED_MAP) endif () -set(BOOST_COMPONENTS system filesystem program_options thread) +set(BOOST_COMPONENTS system filesystem program_options) if(WIN32) set(BOOST_COMPONENTS ${BOOST_COMPONENTS} locale) endif(WIN32) diff --git a/apps/opencs/model/world/idcompletionmanager.cpp b/apps/opencs/model/world/idcompletionmanager.cpp index 12b3ebb62..3316d8567 100644 --- a/apps/opencs/model/world/idcompletionmanager.cpp +++ b/apps/opencs/model/world/idcompletionmanager.cpp @@ -1,7 +1,5 @@ #include "idcompletionmanager.hpp" -#include - #include #include "../../view/widget/completerpopup.hpp" diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index cd1ac31ec..251b94e41 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -117,7 +117,6 @@ include_directories(${SOUND_INPUT_INCLUDES}) target_link_libraries(openmw ${OPENSCENEGRAPH_LIBRARIES} ${Boost_SYSTEM_LIBRARY} - ${Boost_THREAD_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${OPENAL_LIBRARY} diff --git a/apps/openmw/mwgui/bookpage.cpp b/apps/openmw/mwgui/bookpage.cpp index 1b46e571d..2ac492824 100644 --- a/apps/openmw/mwgui/bookpage.cpp +++ b/apps/openmw/mwgui/bookpage.cpp @@ -9,8 +9,6 @@ #include #include -#include - #include namespace MWGui diff --git a/apps/openmw/mwgui/journalviewmodel.cpp b/apps/openmw/mwgui/journalviewmodel.cpp index be095035e..8153b5ead 100644 --- a/apps/openmw/mwgui/journalviewmodel.cpp +++ b/apps/openmw/mwgui/journalviewmodel.cpp @@ -2,7 +2,6 @@ #include #include -#include #include diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index af41e8d23..9c1285cdf 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -1,14 +1,16 @@ #include #include +#include #include #include +#include +#include +#include #include #include -#include - #include "openal_output.hpp" #include "sound_decoder.hpp" #include "sound.hpp" @@ -211,24 +213,32 @@ const ALfloat OpenAL_SoundStream::sBufferLength = 0.125f; struct OpenAL_Output::StreamThread { typedef std::vector StreamVec; StreamVec mStreams; - boost::recursive_mutex mMutex; - boost::thread mThread; + std::mutex mMutex; + std::thread mThread; + std::condition_variable mCondition; + volatile bool mExit; StreamThread() - : mThread(boost::ref(*this)) + : mThread(std::ref(*this)) + , mExit(false) { } ~StreamThread() { - mThread.interrupt(); + mMutex.lock(); + mExit = true; + mMutex.unlock(); + mCondition.notify_one(); + + mThread.join(); } - // boost::thread entry point + // std::thread entry point void operator()() { - while(1) + while(!mExit) { - mMutex.lock(); + std::unique_lock lock (mMutex); StreamVec::iterator iter = mStreams.begin(); while(iter != mStreams.end()) { @@ -237,8 +247,7 @@ struct OpenAL_Output::StreamThread { else ++iter; } - mMutex.unlock(); - boost::this_thread::sleep(boost::posix_time::milliseconds(50)); + mCondition.wait_for(lock, std::chrono::milliseconds(50)); } } diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 3224d0989..85852b5c9 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -173,7 +173,6 @@ add_library(components STATIC ${COMPONENT_FILES} ${MOC_SRCS} ${ESM_UI_HDR}) target_link_libraries(components ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} - ${Boost_THREAD_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${OPENSCENEGRAPH_LIBRARIES} ${BULLET_LIBRARIES} diff --git a/extern/osg-ffmpeg-videoplayer/CMakeLists.txt b/extern/osg-ffmpeg-videoplayer/CMakeLists.txt index 614a0804c..d7843cbb6 100644 --- a/extern/osg-ffmpeg-videoplayer/CMakeLists.txt +++ b/extern/osg-ffmpeg-videoplayer/CMakeLists.txt @@ -13,6 +13,6 @@ set(OSG_FFMPEG_VIDEOPLAYER_SOURCE_FILES include_directories(${FFMPEG_INCLUDE_DIRS}) add_library(${OSG_FFMPEG_VIDEOPLAYER_LIBRARY} STATIC ${OSG_FFMPEG_VIDEOPLAYER_SOURCE_FILES}) -target_link_libraries(${OSG_FFMPEG_VIDEOPLAYER_LIBRARY} ${FFMPEG_LIBRARIES} ${Boost_THREAD_LIBRARY}) +target_link_libraries(${OSG_FFMPEG_VIDEOPLAYER_LIBRARY} ${FFMPEG_LIBRARIES}) link_directories(${CMAKE_CURRENT_BINARY_DIR}) diff --git a/extern/osg-ffmpeg-videoplayer/videostate.cpp b/extern/osg-ffmpeg-videoplayer/videostate.cpp index 98f3decc6..303411b90 100644 --- a/extern/osg-ffmpeg-videoplayer/videostate.cpp +++ b/extern/osg-ffmpeg-videoplayer/videostate.cpp @@ -1,6 +1,9 @@ #include "videostate.hpp" #include +#include +#include +#include #include @@ -116,7 +119,7 @@ void PacketQueue::put(AVPacket *pkt) int PacketQueue::get(AVPacket *pkt, VideoState *is) { - boost::unique_lock lock(this->mutex); + std::unique_lock lock(this->mutex); while(!is->mQuit) { AVPacketList *pkt1 = this->first_pkt; @@ -240,7 +243,7 @@ void VideoState::video_display(VideoPicture *vp) void VideoState::video_refresh() { - boost::mutex::scoped_lock lock(this->pictq_mutex); + std::lock_guard lock(this->pictq_mutex); if(this->pictq_size == 0) return; @@ -293,9 +296,9 @@ int VideoState::queue_picture(AVFrame *pFrame, double pts) /* wait until we have a new pic */ { - boost::unique_lock lock(this->pictq_mutex); + std::unique_lock lock(this->pictq_mutex); while(this->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE && !this->mQuit) - this->pictq_cond.timed_wait(lock, boost::posix_time::milliseconds(1)); + this->pictq_cond.wait_for(lock, std::chrono::milliseconds(1)); } if(this->mQuit) return -1; @@ -508,7 +511,7 @@ void VideoState::decode_thread_loop(VideoState *self) if((self->audio_st && self->audioq.size > MAX_AUDIOQ_SIZE) || (self->video_st && self->videoq.size > MAX_VIDEOQ_SIZE)) { - boost::this_thread::sleep(boost::posix_time::milliseconds(10)); + std::this_thread::sleep_for(std::chrono::milliseconds(10)); continue; } @@ -591,7 +594,7 @@ int VideoState::stream_open(int stream_index, AVFormatContext *pFormatCtx) codecCtx->get_buffer = our_get_buffer; codecCtx->release_buffer = our_release_buffer; - this->video_thread = boost::thread(video_thread_loop, this); + this->video_thread = std::thread(video_thread_loop, this); break; default: @@ -673,7 +676,7 @@ void VideoState::init(std::shared_ptr inputstream, const std::stri } - this->parse_thread = boost::thread(decode_thread_loop, this); + this->parse_thread = std::thread(decode_thread_loop, this); } void VideoState::deinit() @@ -783,7 +786,7 @@ ExternalClock::ExternalClock() void ExternalClock::setPaused(bool paused) { - boost::mutex::scoped_lock lock(mMutex); + std::lock_guard lock(mMutex); if (mPaused == paused) return; if (paused) @@ -797,7 +800,7 @@ void ExternalClock::setPaused(bool paused) uint64_t ExternalClock::get() { - boost::mutex::scoped_lock lock(mMutex); + std::lock_guard lock(mMutex); if (mPaused) return mPausedAt; else @@ -806,7 +809,7 @@ uint64_t ExternalClock::get() void ExternalClock::set(uint64_t time) { - boost::mutex::scoped_lock lock(mMutex); + std::lock_guard lock(mMutex); mTimeBase = av_gettime() - time; mPausedAt = time; } diff --git a/extern/osg-ffmpeg-videoplayer/videostate.hpp b/extern/osg-ffmpeg-videoplayer/videostate.hpp index 0621b6dee..6816051c8 100644 --- a/extern/osg-ffmpeg-videoplayer/videostate.hpp +++ b/extern/osg-ffmpeg-videoplayer/videostate.hpp @@ -3,7 +3,10 @@ #include -#include +#include +#include +#include +#include #include namespace osg @@ -43,7 +46,7 @@ struct ExternalClock uint64_t mPausedAt; bool mPaused; - boost::mutex mMutex; + std::mutex mMutex; void setPaused(bool paused); uint64_t get(); @@ -62,8 +65,8 @@ struct PacketQueue { int nb_packets; int size; - boost::mutex mutex; - boost::condition_variable cond; + std::mutex mutex; + std::condition_variable cond; void put(AVPacket *pkt); int get(AVPacket *pkt, VideoState *is); @@ -141,11 +144,11 @@ struct VideoState { VideoPicture pictq[VIDEO_PICTURE_ARRAY_SIZE]; AVFrame* rgbaFrame; // used as buffer for the frame converted from its native format to RGBA int pictq_size, pictq_rindex, pictq_windex; - boost::mutex pictq_mutex; - boost::condition_variable pictq_cond; + std::mutex pictq_mutex; + std::condition_variable pictq_cond; - boost::thread parse_thread; - boost::thread video_thread; + std::thread parse_thread; + std::thread video_thread; volatile bool mSeekRequested; uint64_t mSeekPos;