Skip to content

Mirror::SimpleWeb::BufferPool

Collection of different sized buffers More...

Public Functions

Name
BufferPool(int bucketCount, int smallest, int largest)
ArrayBuffer Take(int size)

Detailed Description

class Mirror::SimpleWeb::BufferPool;

Collection of different sized buffers

Problem:

  • Need to cached byte[] so that new ones arn't created each time
  • Arrays sent are multiple different sizes
  • Some message might be big so need buffers to cover that size
  • Most messages will be small compared to max message size

Solution:

  • Create multiple groups of buffers covering the range of allowed sizes
  • Split range exponentially (using math.log) so that there are more groups for small buffers

Public Functions Documentation

function BufferPool

inline BufferPool(
    int bucketCount,
    int smallest,
    int largest
)

function Take

inline ArrayBuffer Take(
    int size
)

Updated on 25 January 2021 at 08:57:32 UTC