QGIS/external/untwine/epf/BufferCache.hpp
Martin Dobias d76ec1cecb Update untwine to match the current hobu/untwine main branch
Added a minor update to the untwine_to_qgis.bash script as it was
getting confused about the "untwine" subfolders and copying sources
one level deeper as supposed to
2020-12-16 16:16:55 +01:00

45 lines
1.4 KiB
C++

/*****************************************************************************
* Copyright (c) 2020, Hobu, Inc. (info@hobu.co) *
* *
* All rights reserved. *
* *
* This program 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 3 of the License, or *
* (at your option) any later version. *
* *
****************************************************************************/
#pragma once
#include <deque>
#include <mutex>
#include <condition_variable>
#include "EpfTypes.hpp"
namespace untwine
{
namespace epf
{
// This is simply a cache of data buffers to avoid continuous allocation and deallocation.
class BufferCache
{
public:
BufferCache() : m_count(0)
{}
DataVecPtr fetch(std::unique_lock<std::mutex>& lock, bool nonblock);
void replace(DataVecPtr&& buf);
private:
std::deque<DataVecPtr> m_buffers;
std::condition_variable m_cv;
int m_count;
};
} // namespace epf
} // namespace untwine