hytopia
Version:
The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.
149 lines (70 loc) • 2.62 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [server](./server.md) > [TickAllocator](./server.tickallocator.md)
## TickAllocator class
High-performance tick-scoped allocator for temporary objects, arrays, and buffers. All allocations are automatically bulk-released when reset() is called.
**Signature:**
```typescript
export default class TickAllocator
```
## Remarks
TickAllocator maintains separate pools for different data types and tracks all allocations made during a tick cycle. Objects are reused across ticks to eliminate garbage collection overhead in hot paths like network synchronization.
## Example
```typescript
// Allocate during tick
const position = tickAllocator.getArray3Number();
const rotation = tickAllocator.getArray4Number();
const data = tickAllocator.getObject<EntitySchema>();
// At end of tick - bulk release everything
tickAllocator.reset();
```
## Methods
<table><thead><tr><th>
Method
</th><th>
Modifiers
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[getArray(copyFromA, copyFromB)](./server.tickallocator.getarray.md)
</td><td>
</td><td>
Gets a generic array from the pool. Array is reset to empty state and ready for use.
</td></tr>
<tr><td>
[getArray3Number(copyFrom)](./server.tickallocator.getarray3number.md)
</td><td>
</td><td>
Gets a 3-element number array from the pool. Array is reset to \[0, 0, 0\] and ready for use.
</td></tr>
<tr><td>
[getArray4Number(copyFrom)](./server.tickallocator.getarray4number.md)
</td><td>
</td><td>
Gets a 4-element number array from the pool. Array is reset to \[0, 0, 0, 0\] and ready for use.
</td></tr>
<tr><td>
[getObject(copyFromA, copyFromB)](./server.tickallocator.getobject.md)
</td><td>
</td><td>
Gets a plain object from the pool. Object is reset to empty state and ready for use.
</td></tr>
<tr><td>
[getSet(copyFromA, copyFromB)](./server.tickallocator.getset.md)
</td><td>
</td><td>
Gets a set from the pool. Set is reset to empty state and ready for use.
</td></tr>
<tr><td>
[map(array, callback)](./server.tickallocator.map.md)
</td><td>
</td><td>
Maps an array to a new array using a callback function.
</td></tr>
<tr><td>
[reset()](./server.tickallocator.reset.md)
</td><td>
</td><td>
Releases all allocated objects back to their respective pools. This is intended to be called at the end of a tick.
</td></tr>
</tbody></table>