/** * Method that will try to create a {@link ChunkyMemBuffer} with configured allocator, * using specified arguments. * If construction fails (due to allocation limits), * null will be returned. */ @SuppressWarnings("resource") public final CB tryCreateChunkyBuffer(int minSegmentsForBuffer, int maxSegmentsForBuffer) { S initialSegments = _segmentAllocator.allocateSegments(minSegmentsForBuffer, null); // may not be able to allocate segments; if so, need to fail if (initialSegments == null) { return null; } CB buffer = _createChunkyBuffer(minSegmentsForBuffer, maxSegmentsForBuffer, initialSegments); // Need to decorate it? if (_chunkyDecorator != null) { buffer = _chunkyDecorator.decorateMemBuffer(buffer); } return buffer; }
/** * Method that will try to create a {@link StreamyMemBuffer} with configured allocator, * using specified arguments. * If construction fails (due to allocation limits), * null will be returned. */ @SuppressWarnings("resource") public final SB tryCreateStreamyBuffer(int minSegmentsForBuffer, int maxSegmentsForBuffer) { S initialSegments = _segmentAllocator.allocateSegments(minSegmentsForBuffer, null); // may not be able to allocate segments; if so, need to fail if (initialSegments == null) { return null; } SB buffer = _createStreamyBuffer(minSegmentsForBuffer, maxSegmentsForBuffer, initialSegments); if (_streamyDecorator != null) { buffer = _streamyDecorator.decorateMemBuffer(buffer); } return buffer; }
/** * Method that will try to create a {@link ChunkyMemBuffer} with configured allocator, * using specified arguments. * If construction fails (due to allocation limits), * null will be returned. */ @SuppressWarnings("resource") public final CB tryCreateChunkyBuffer(int minSegmentsForBuffer, int maxSegmentsForBuffer) { S initialSegments = _segmentAllocator.allocateSegments(minSegmentsForBuffer, null); // may not be able to allocate segments; if so, need to fail if (initialSegments == null) { return null; } CB buffer = _createChunkyBuffer(minSegmentsForBuffer, maxSegmentsForBuffer, initialSegments); // Need to decorate it? if (_chunkyDecorator != null) { buffer = _chunkyDecorator.decorateMemBuffer(buffer); } return buffer; }
/** * Method that will try to create a {@link StreamyMemBuffer} with configured allocator, * using specified arguments. * If construction fails (due to allocation limits), * null will be returned. */ @SuppressWarnings("resource") public final SB tryCreateStreamyBuffer(int minSegmentsForBuffer, int maxSegmentsForBuffer) { S initialSegments = _segmentAllocator.allocateSegments(minSegmentsForBuffer, null); // may not be able to allocate segments; if so, need to fail if (initialSegments == null) { return null; } SB buffer = _createStreamyBuffer(minSegmentsForBuffer, maxSegmentsForBuffer, initialSegments); if (_streamyDecorator != null) { buffer = _streamyDecorator.decorateMemBuffer(buffer); } return buffer; }