diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-05-01 21:36:04 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-05-08 12:16:21 +0200 |
commit | 42953944da1261584d56405128c6eb3c0e9e7da0 (patch) | |
tree | 1f150ce606457a0bea5647374e0719ecd9646f01 /src/midimapper.cc | |
parent | f8feb953c6d86bee12747679e5e4dac7795a65d0 (diff) |
The last loader thread stuff.
Diffstat (limited to 'src/midimapper.cc')
-rw-r--r-- | src/midimapper.cc | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/midimapper.cc b/src/midimapper.cc index 05f69e5..ab3d8d7 100644 --- a/src/midimapper.cc +++ b/src/midimapper.cc @@ -28,20 +28,26 @@ int MidiMapper::lookup(int note) { + std::lock_guard<std::mutex> guard(mutex); + if(midimap.find(note) == midimap.end()) { return -1; } - std::string instr = midimap[note]; + + const std::string& instr = midimap[note]; if(instrmap.find(instr) == instrmap.end()) { return -1; } + return instrmap[instr]; } -void MidiMapper::clear() +void MidiMapper::swap(instrmap_t& instrmap, midimap_t& midimap) { - midimap.clear(); - instrmap.clear(); + std::lock_guard<std::mutex> guard(mutex); + + std::swap(this->instrmap, instrmap); + std::swap(this->midimap, midimap); } |