Skip to content

Instantly share code, notes, and snippets.

View ericthorsen's full-sized avatar

Eric Thorsen ericthorsen

View GitHub Profile

Keybase proof

I hereby claim:

  • I am ericthorsen on github.
  • I am thorseneric (https://keybase.io/thorseneric) on keybase.
  • I have a public key ASBYZmrm4i8k_qQMO6bQRG-sxbxRlKKqIJT20TTPkSYesgo

To claim this, I am signing this object:

@ericthorsen
ericthorsen / OVN need
Created January 19, 2012 23:06
OVN need by strata
[TestModuleAttribute("calc_NEED_VCPj2_h", "calc_NEED_VCPj2_h", ModuleType.MathModule)]
static public MKMap calc_NEED_VCPj2_h
(
String stratasuffix
, Object j2
, MKMap TAB_VCPj2_h
, Double ADD_DIF_VCPj2
)
{
MKMap NEED_VCP2j_h = new MKMap(String.Format("NEED_VCPj2_{0}", stratasuffix), stratasuffix);
@ericthorsen
ericthorsen / gist:1460532
Created December 11, 2011 13:12
routing a MIP record
private void server_MIPRecordDequeued(MIPQueueRecord record)
{
try
{
if (record.OutBoundDocQueueID != -1)
_lastDocumentID = record.OutBoundDocQueueID;
//Profile list exists for private sweep or retran
if (record.ProfileList != null)
{
@ericthorsen
ericthorsen / gist:1455049
Created December 10, 2011 12:26
doWork with blocking collection
private void doWork(MIPQueueRecord record)
{
if (!IsStopped)
{
//ET this is the old code...it waits to get an ack before moving on to the next record???
//waitForAck();
if (profile_.Ack)
{//ET keep trying to add the item until the client times out (in case they stop acking)
TimeSpan tenMinutes = TimeSpan.FromMilliseconds(10 * 60 * 1000);
Int32 soFar = 0;
@ericthorsen
ericthorsen / gist:1455039
Created December 10, 2011 12:21
ack receive code - blocking collection
MIPMessage msg = protocol_.ReadNextMessage(null);
if (msg.IsAcknowledgement)
{
//if this profile is not set for acknowledgement than we just log warning
if (profile_.Ack)
{
MIPQueueRecord mipQRec;
if(_ackQueue.TryTake(out mipQRec))
OnClientAckReceived(this.profile_.ProfileID, mipQRec);
else
@ericthorsen
ericthorsen / gist:1455011
Created December 10, 2011 12:10
blocking collection - ack window
if (profile_.Ack)
{//ET keep trying to add the item until the client times out (in case they stop acking)
TimeSpan tenMinutes = TimeSpan.FromMilliseconds(10*60*1000);
Int32 soFar = 0;
while (!_ackQueue.TryAdd(record, 20) && soFar < tenMinutes.TotalMilliseconds) ;
if (soFar >= tenMinutes.TotalMilliseconds)
{
Stop();
throw new ApplicationException(String.Format("Acknowledgement not received in 10 minutes. Disconnecting client {0}.",this.Profile.Name));
}