MCPcopy Create free account
hub / github.com/esengine/esengine / obtain

Method obtain

packages/core/src/Utils/Pool/Pool.ts:63–78  ·  view source on GitHub ↗

* 从池中获取对象 * @returns 对象实例

()

Source from the content-addressed store, hash-verified

61 * @returns 对象实例
62 */
63 public obtain(): T {
64 this._stats.totalObtained++;
65
66 if (this._objects.length > 0) {
67 const obj = this._objects.pop()!;
68 this._stats.size--;
69 this._updateHitRate();
70 this._updateMemoryUsage();
71 return obj;
72 }
73
74 // 池中没有可用对象,创建新对象
75 this._stats.totalCreated++;
76 this._updateHitRate();
77 return this._createFn();
78 }
79
80 /**
81 * 释放对象回池中

Callers 3

queryMultipleAndMethod · 0.45
queryMultipleOrMethod · 0.45

Calls 3

_updateHitRateMethod · 0.95
_updateMemoryUsageMethod · 0.95
popMethod · 0.80

Tested by

no test coverage detected