102void ris::Pool::setup_python() {
104 bp::class_<ris::Pool, ris::PoolPtr, boost::noncopyable>(
"Pool", bp::init<>())
105 .def(
"getAllocCount", &ris::Pool::getAllocCount)
106 .def(
"getAllocBytes", &ris::Pool::getAllocBytes)
107 .def(
"setFixedSize", &ris::Pool::setFixedSize)
108 .def(
"getFixedSize", &ris::Pool::getFixedSize)
109 .def(
"setPoolSize", &ris::Pool::setPoolSize)
110 .def(
"getPoolSize", &ris::Pool::getPoolSize);
152 std::lock_guard<std::mutex> lock(mtx_);
153 if (fixedSize_ > 0) {
155 if (bSize > bAlloc) bSize = bAlloc;
158 if (dataQ_.size() > 0) {
159 data = dataQ_.front();
161 }
else if ((data =
reinterpret_cast<uint8_t*
>(malloc(bAlloc))) == NULL) {
170 allocMeta_ &= 0xFFFFFF;
171 allocBytes_ += bAlloc;
173 if (total != NULL) *total += bSize;
174 return (ris::Buffer::create(shared_from_this(), data, meta, bSize, bAlloc));
178ris::BufferPtr ris::Pool::createBuffer(
void* data, uint32_t meta, uint32_t size, uint32_t alloc) {
182 std::lock_guard<std::mutex> lock(mtx_);
184 buff = ris::Buffer::create(shared_from_this(), data, meta, size, alloc);
186 allocBytes_ += alloc;