diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-05-18 22:55:46 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-05-28 00:33:55 +0200 |
| commit | 6b505562cc242ef7c38b1e502f2504883c2fe9fe (patch) | |
| tree | ee1f38110156925b2edb91b68fcd8a37d92da592 /src/lib/grok | |
| parent | 5d72e234bfe29b14a937d4095a374ae5e62adc1a (diff) | |
Cleanup: move ScheduledFrames into its own .cc/.h.
Diffstat (limited to 'src/lib/grok')
| -rw-r--r-- | src/lib/grok/messenger.h | 32 | ||||
| -rw-r--r-- | src/lib/grok/scheduled_frames.cc | 51 | ||||
| -rw-r--r-- | src/lib/grok/scheduled_frames.h | 41 |
3 files changed, 92 insertions, 32 deletions
diff --git a/src/lib/grok/messenger.h b/src/lib/grok/messenger.h index 9e8cb9e4d..e52a1b7ea 100644 --- a/src/lib/grok/messenger.h +++ b/src/lib/grok/messenger.h @@ -365,38 +365,6 @@ private: }; -class ScheduledFrames -{ -public: - void store(DCPVideo const& val) - { - std::unique_lock<std::mutex> lk(_mutex); - auto it = _map.find(val.index()); - if (it == _map.end()) { - _map.emplace(std::make_pair(val.index(), val)); - } - } - - boost::optional<DCPVideo> retrieve(size_t index) - { - std::unique_lock<std::mutex> lk(_mutex); - auto it = _map.find(index); - if (it == _map.end()) { - return {}; - } - - DCPVideo val = it->second; - _map.erase(index); - - return val; - } - -private: - std::mutex _mutex; - std::map<size_t, DCPVideo> _map; -}; - - class Messenger { public: diff --git a/src/lib/grok/scheduled_frames.cc b/src/lib/grok/scheduled_frames.cc new file mode 100644 index 000000000..25f07d668 --- /dev/null +++ b/src/lib/grok/scheduled_frames.cc @@ -0,0 +1,51 @@ +/* + Copyright (C) 2023 Grok Image Compression Inc. + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + + +#include "scheduled_frames.h" +#include "../dcp_video.h" + + +void +ScheduledFrames::store(DCPVideo const& val) +{ + std::unique_lock<std::mutex> lk(_mutex); + auto it = _map.find(val.index()); + if (it == _map.end()) { + _map.emplace(std::make_pair(val.index(), val)); + } +} + + +boost::optional<DCPVideo> +ScheduledFrames::retrieve(size_t index) +{ + std::unique_lock<std::mutex> lk(_mutex); + auto it = _map.find(index); + if (it == _map.end()) { + return {}; + } + + DCPVideo val = it->second; + _map.erase(index); + + return val; +} + diff --git a/src/lib/grok/scheduled_frames.h b/src/lib/grok/scheduled_frames.h new file mode 100644 index 000000000..509718d18 --- /dev/null +++ b/src/lib/grok/scheduled_frames.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2023 Grok Image Compression Inc. + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + + +#include <map> +#include <mutex> +#include <boost/optional.hpp> + + +class DCPVideo; + + +class ScheduledFrames +{ +public: + void store(DCPVideo const& val); + boost::optional<DCPVideo> retrieve(size_t index); + +private: + std::mutex _mutex; + std::map<size_t, DCPVideo> _map; +}; + + |
