All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.javanut.pronghorn.pipe.FragmentWriter Maven / Gradle / Ivy

Go to download

Ring buffer based queuing utility for applications that require high performance and/or a small footprint. Well suited for embedded and stream based processing.

There is a newer version: 1.1.27
Show newest version
package com.javanut.pronghorn.pipe;

public class FragmentWriter {

    public static > void write(Pipe pipe, int msgIdx) {
    	assert(FieldReferenceOffsetManager.isValidMsgIdx(Pipe.from(pipe), msgIdx));
    	assert(2==Pipe.from(pipe).fragDataSize[msgIdx]) : "This constant does not this fragment size";
    	
    	int size = Pipe.addMsgIdx(pipe, msgIdx);
    	Pipe.confirmLowLevelWrite(pipe, size);
    	Pipe.publishWrites(pipe);        
    }
    
    public static > void writeL(Pipe pipe, int msgIdx, long field1) {
    	assert(FieldReferenceOffsetManager.isValidMsgIdx(Pipe.from(pipe), msgIdx));
    	assert(4==Pipe.from(pipe).fragDataSize[msgIdx]) : "This constant does not this fragment size";
    	
    	int size = Pipe.addMsgIdx(pipe, msgIdx);
    	Pipe.addLongValue(field1, pipe);
    	Pipe.confirmLowLevelWrite(pipe, size);
    	Pipe.publishWrites(pipe);        
    }
    
    public static > void writeLV(Pipe pipe, int msgIdx, long field1,
    		                                 byte[] field2Backing, int field2Position, int field2Length) {
    	assert(FieldReferenceOffsetManager.isValidMsgIdx(Pipe.from(pipe), msgIdx));
    	assert(4==Pipe.from(pipe).fragDataSize[msgIdx]) : "This constant does not this fragment size";
    	
    	int size = Pipe.addMsgIdx(pipe, msgIdx);
    	Pipe.addLongValue(field1, pipe);
    	Pipe.addByteArray(field2Backing, field2Position, field2Length, pipe);
    	Pipe.confirmLowLevelWrite(pipe, size);
    	Pipe.publishWrites(pipe);        
    }
    
    
    public static > void writeLL(Pipe pipe, int msgIdx, long field1, long field2) {
    	assert(FieldReferenceOffsetManager.isValidMsgIdx(Pipe.from(pipe), msgIdx));
    	assert(6==Pipe.from(pipe).fragDataSize[msgIdx]) : "This constant does not this fragment size";
    	
    	int size = Pipe.addMsgIdx(pipe, msgIdx);
    	Pipe.addLongValue(field1, pipe);
    	Pipe.addLongValue(field2, pipe);
    	Pipe.confirmLowLevelWrite(pipe, size);
    	Pipe.publishWrites(pipe);        
    }
    
    public static > void writeLI(Pipe pipe, int msgIdx, long field1, int field2) {
    	assert(FieldReferenceOffsetManager.isValidMsgIdx(Pipe.from(pipe), msgIdx));
    	assert(5==Pipe.from(pipe).fragDataSize[msgIdx]) : "This constant does not this fragment size";

    	int size = Pipe.addMsgIdx(pipe, msgIdx);
    	Pipe.addLongValue(field1, pipe);
    	Pipe.addIntValue(field2, pipe);
    	Pipe.confirmLowLevelWrite(pipe, size);
    	Pipe.publishWrites(pipe);        
    }
    
    public static > void writeII(Pipe pipe, int msgIdx, int field1, int field2) {
    	assert(FieldReferenceOffsetManager.isValidMsgIdx(Pipe.from(pipe), msgIdx));
    	assert(4==Pipe.from(pipe).fragDataSize[msgIdx]) : "This constant does not this fragment size";

    	int size = Pipe.addMsgIdx(pipe, msgIdx);
    	Pipe.addIntValue(field1, pipe);
    	Pipe.addIntValue(field2, pipe);
    	Pipe.confirmLowLevelWrite(pipe, size);
    	Pipe.publishWrites(pipe);        
    }
    
    public static > void writeLII(Pipe pipe, int msgIdx, long field1, int field2, int field3) {
    	assert(FieldReferenceOffsetManager.isValidMsgIdx(Pipe.from(pipe), msgIdx));
    	assert(6==Pipe.from(pipe).fragDataSize[msgIdx]) : "This constant does not this fragment size";
    	
    	int size = Pipe.addMsgIdx(pipe, msgIdx);
    	Pipe.addLongValue(field1, pipe);
    	Pipe.addIntValue(field2, pipe);
    	Pipe.addIntValue(field3, pipe);
    	Pipe.confirmLowLevelWrite(pipe, size);
    	Pipe.publishWrites(pipe);        
    }
    
    public static > void writeI(Pipe pipe, int msgIdx, int field1) {
    	assert(FieldReferenceOffsetManager.isValidMsgIdx(Pipe.from(pipe), msgIdx));
    	assert(3==Pipe.from(pipe).fragDataSize[msgIdx]) : "This constant does not this fragment size";
    	
    	int size = Pipe.addMsgIdx(pipe, msgIdx);
    	Pipe.addIntValue(field1, pipe);
    	Pipe.confirmLowLevelWrite(pipe, size);
    	Pipe.publishWrites(pipe);        
    }
}