Questions tagged «object-pools»

1
什么时候以及为什么需要一个Pool类来保存对象?
我一直在研究opengl es,我看到的一个示例是使用“ Pool”类来跟踪触摸和键盘事件。 有人可以解释为什么以及为什么需要泳池课程。从我阅读的内容来看,它与垃圾收集和限制输入类的数量有关。 这对我来说似乎有点抽象,所以如果有人可以解释发生了什么,我将不胜感激,我将在此处粘贴一些代码: public Pool(PoolObjectFactory < T > factory, int maxSize) { this.factory = factory; this.maxSize = maxSize; this.freeObjects = new ArrayList < T > (maxSize); } public T newObject() { T object = null ; if (freeObjects.isEmpty()) object = factory.createObject(); else object = freeObjects.remove(freeObjects.size() - 1); return …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.