103void ris::Pool::setup_python() {
105 bp::class_<ris::Pool, ris::PoolPtr, boost::noncopyable>(
"Pool", bp::init<>())
106 .def(
"getAllocCount", &ris::Pool::getAllocCount)
107 .def(
"getAllocBytes", &ris::Pool::getAllocBytes)
108 .def(
"setFixedSize", &ris::Pool::setFixedSize)
109 .def(
"getFixedSize", &ris::Pool::getFixedSize)
110 .def(
"setPoolSize", &ris::Pool::setPoolSize)
111 .def(
"getPoolSize", &ris::Pool::getPoolSize);
153 std::lock_guard<std::mutex> lock(mtx_);
154 if (fixedSize_ > 0) {
156 if (bSize > bAlloc) bSize = bAlloc;
159 if (dataQ_.size() > 0) {
160 data = dataQ_.front();
162 }
else if ((data =
reinterpret_cast<uint8_t*
>(malloc(bAlloc))) == NULL) {
171 allocMeta_ &= 0xFFFFFF;
172 allocBytes_ += bAlloc;
174 if (total != NULL) *total += bSize;
175 return (ris::Buffer::create(shared_from_this(), data, meta, bSize, bAlloc));
179ris::BufferPtr ris::Pool::createBuffer(
void* data, uint32_t meta, uint32_t size, uint32_t alloc) {
183 std::lock_guard<std::mutex> lock(mtx_);
185 buff = ris::Buffer::create(shared_from_this(), data, meta, size, alloc);
187 allocBytes_ += alloc;