This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IRfq : IDisposable | |
{ | |
void RequestQuote(IQuoteRequest quoteRequest); | |
void Cancel(long rfqId); | |
void Execute(IExecutionRequest quote); | |
IObservable<RfqUpdate> Updates { get; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_stateMachine.OnUnhandledTrigger(OnUnhandledTrigger); | |
private void OnUnhandledTrigger(RfqState state, RfqEvent trigger) | |
{ | |
var message = string.Format("State machine received an invalid trigger '{0}' in state '{1}'", trigger, state); | |
Console.WriteLine(message); | |
_rfqUpdateSubject.OnError(new ApplicationException(message)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for an event without parameters | |
_stateMachine.Fire(RfqEvent.ServerQuoteStreamComplete) | |
// for a strongly typed event | |
_stateMachine.Fire(_rfqEventServerSendsExecutionReport, executionReport) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_stateMachine.Configure(RfqState.Input) | |
.Permit(RfqEvent.UserRequests, RfqState.Requesting); | |
_stateMachine.Configure(RfqState.Requesting) | |
.Permit(RfqEvent.ServerNewQuote, RfqState.Quoted) | |
.Permit(RfqEvent.UserCancels, RfqState.Cancelling) | |
.Permit(RfqEvent.InternalError, RfqState.Error); | |
_stateMachine.Configure(RfqState.Quoted) | |
.PermitReentry(RfqEvent.ServerNewQuote) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_rfqEventServerSendsQuote = _stateMachine.SetTriggerParameters<IQuote>(RfqEvent.ServerNewQuote); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum RfqEvent | |
{ | |
UserRequests, | |
UserCancels, | |
UserExecutes, | |
ServerNewQuote, | |
ServerQuoteError, | |
ServerQuoteStreamComplete, | |
ServerSendsExecutionReport, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum RfqState | |
{ | |
Input, | |
Requesting, | |
Cancelling, | |
Cancelled, | |
Quoted, | |
Executing, | |
Error, | |
Done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public unsafe int Int32GetLittleEndian(int index) | |
{ | |
return *(int*)(_pBuffer + index); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
NewerOlder