Skip to content

Instantly share code, notes, and snippets.

View odeheurles's full-sized avatar

Olivier Deheurles odeheurles

View GitHub Profile
public unsafe int Int32GetLittleEndian(int index)
{
return *(int*)(_pBuffer + index);
}
public int getInt(final int index, final ByteOrder byteOrder)
{
int bits = UNSAFE.getInt(byteArray, baseOffset + index);
if (NATIVE_BYTE_ORDER != byteOrder)
{
bits = Integer.reverseBytes(bits);
}
return bits;
}
sbe_uint32_t serialNumber(void) const
{
return SBE_LITTLE_ENDIAN_ENCODE_32(*((sbe_uint32_t *)(buffer_ + offset_ + 0)));
}
order.orderId(72);
private static int Encode(Car car, DirectBuffer directBuffer, int bufferOffset)
{
...
car.SerialNumber = 1234;
car.ModelYear = 2013;
car.Available = BooleanType.TRUE;
car.Code = Model.A;
...
}
80: car.SerialNumber = 1234;
mov rax,qword ptr [rbp+100h]
cmp byte ptr [rax],0
mov rcx,qword ptr [rbp+100h]
mov edx,4D2h
call 000007FE8C96CB40 // function call
nop
81: car.ModelYear = 2013;
mov rax,qword ptr [rbp+100h]
cmp byte ptr [rax],0
80: car.SerialNumber = 1234;
mov edx,dword ptr [esi+8]
mov ecx,dword ptr [esi+18h]
mov eax,dword ptr [edx+8]
mov dword ptr [eax+ecx],4D2h
81: car.ModelYear = 2013;
mov edx,dword ptr [esi+8]
mov ecx,dword ptr [esi+18h]
add ecx,4
mov eax,dword ptr [edx+8]
@odeheurles
odeheurles / Assembly optimized
Created December 14, 2013 10:49
Example of inlining with Simple Binary Encoding
80: car.SerialNumber = 1234;
mov edx,dword ptr [esi+8]
mov ecx,dword ptr [esi+18h]
mov eax,dword ptr [edx+8]
mov dword ptr [eax+ecx],4D2h
81: car.ModelYear = 2013;
mov edx,dword ptr [esi+8]
mov ecx,dword ptr [esi+18h]
add ecx,4
mov eax,dword ptr [edx+8]
@odeheurles
odeheurles / FireEvent
Created June 25, 2014 10:45
Fire an event to the state machine
// for an event without parameters
_stateMachine.Fire(RfqEvent.ServerQuoteStreamComplete)
// for a strongly typed event
_stateMachine.Fire(_rfqEventServerSendsExecutionReport, executionReport)
@odeheurles
odeheurles / DefiningActions
Created June 25, 2014 10:47
Defining actions
_stateMachine.Configure(RfqState.Requesting)
.OnEntry(LogTransition)
.OnEntryFrom(_rfqEventUserRequests, OnEntryRequesting)
.Permit(RfqEvent.ServerNewQuote, RfqState.Quoted)
.Permit(RfqEvent.UserCancels, RfqState.Cancelling)
.Permit(RfqEvent.InternalError, RfqState.Error);
private void OnEntryRequesting(IQuoteRequest quoteRequest)
{
// here goes the code to send a quote request to the server