Revision 995b7f4d server/src/Arbiter.cpp

View differences:

server/src/Arbiter.cpp
30 30
#include "AudioPlayerLibAO.h"
31 31
#include "AudioPlayerRSB.h"
32 32
#include <boost/algorithm/string/predicate.hpp>
33
#include <boost/thread/mutex.hpp>
33
#include <mutex>
34
#include <thread>
34 35
#include <iostream>
35 36

  
36 37
using namespace boost;
......
68 69

  
69 70
void Arbiter::set_default_emotion(EmotionState e){
70 71
    //lock access
71
    boost::mutex::scoped_lock scoped_lock(emotion_config_default_mutex);
72
    const std::lock_guard<std::mutex> lock(emotion_config_default_mutex);
72 73

  
73 74
    //update our config, ignore duration as this is the default emotion
74 75
    emotion_config_default.select_config(e.value);
......
81 82

  
82 83
void Arbiter::set_current_emotion(EmotionState e){
83 84
    //lock access
84
    boost::mutex::scoped_lock scoped_lock(emotion_config_current_mutex);
85
    const std::lock_guard<std::mutex> lock(emotion_config_current_mutex);
85 86

  
86 87
    //this will set a emotion override for a given time, after the timeout
87 88
    //we will return to the default emotion state:
......
96 97

  
97 98
void Arbiter::set_mouth_config(MouthConfig m){
98 99
    //lock access
99
    boost::mutex::scoped_lock scoped_lock(mouth_config_override_mutex);
100
    const std::lock_guard<std::mutex> lock(mouth_config_override_mutex);
100 101

  
101 102
    mouth_config = m;
102 103
}
103 104

  
104 105
void Arbiter::set_gaze_target(humotion::GazeState target){
105 106
    //lock access
106
    boost::mutex::scoped_lock scoped_lock(requested_gaze_state_mutex);
107
    const std::lock_guard<std::mutex> lock(requested_gaze_state_mutex);
107 108

  
108 109
    requested_gaze_state = target;
109 110
}
110 111

  
111 112
void Arbiter::set_mouth_target(humotion::MouthState target){
112 113
    //lock access
113
    boost::mutex::scoped_lock scoped_lock(requested_mouth_state_mutex);
114
    const std::lock_guard<std::mutex> lock(requested_mouth_state_mutex);
114 115

  
115 116
    requested_mouth_state = target;
116 117
}
......
119 120
void Arbiter::play_animation(boost::shared_ptr<Animation> incoming_animation){
120 121
    //incoming animation, check if this would conflict with any pending animations:
121 122
    //lock access & iterate over vector:
122
    boost::mutex::scoped_lock lock_av(active_animation_vector_mutex);
123
    std::unique_lock<std::mutex> lock_av(active_animation_vector_mutex);
123 124
    active_animation_vector_t::iterator it;
124 125
    for(it = active_animation_vector.begin(); it<active_animation_vector.end(); it++){
125 126
        boost::shared_ptr<Animation> current_ani = *it;
......
162 163

  
163 164
void Arbiter::speak(boost::shared_ptr<Utterance> u){ //, ao_sample_format audio_format, char *audio_data, unsigned int audio_len){
164 165
    //lock audio playback as such:
165
    boost::mutex::scoped_lock scoped_lock_audio(audio_player_mutex);
166
    const std::lock_guard<std::mutex> lock_audio(audio_player_mutex);
166 167

  
167
    //lock utterance & store data:
168
    boost::mutex::scoped_lock scoped_lock(utterance_mutex);
169
    utterance = u;
170
    scoped_lock.unlock();
168
    {
169
        //lock utterance & store data:
170
        const std::lock_guard<std::mutex> lock(utterance_mutex);
171
        utterance = u;
172
    }
171 173

  
172 174
    //start audio playback, this function returns once we started playback
173 175
    if (audio_player == NULL){
......
272 274
    }
273 275

  
274 276
    //lock access
275
    boost::mutex::scoped_lock scoped_lock1(emotion_config_default_mutex);
277
    const std::lock_guard<std::mutex> lock1(emotion_config_default_mutex);
276 278

  
277 279

  
278 280
    // did the current emotion time out?
......
344 346

  
345 347
void Arbiter::override_by_animation(){
346 348
    //lock access & iterate over vector:
347
    boost::mutex::scoped_lock lock_av(active_animation_vector_mutex);
349
    const std::lock_guard<std::mutex> lock_av(active_animation_vector_mutex);
348 350
    active_animation_vector_t::iterator it;
349 351
    for(it = active_animation_vector.begin(); it<active_animation_vector.end(); it++){
350 352
        boost::shared_ptr<Animation> current_ani = *it;

Also available in: Unified diff