initialize
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2016 iTAC Software AG, Germany. All Rights Reserved.
|
||||
*
|
||||
* This software is protected by copyright. Under no circumstances may any part of this file in any form be copied,
|
||||
* printed, edited or otherwise distributed, be stored in a retrieval system, or be translated into another language
|
||||
* without the written permission of iTAC Software AG.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace com.itac.mes.commonsmt
|
||||
{
|
||||
class RequestIdGenerator
|
||||
{
|
||||
|
||||
protected static int MIN_REQUEST_ID = 0;
|
||||
protected static int MAX_REQUEST_ID = 1000000;
|
||||
|
||||
private int requestId;
|
||||
|
||||
static object lockObject = new object();
|
||||
|
||||
// creates an almost unique id
|
||||
public int getNextId()
|
||||
{
|
||||
lock (lockObject)
|
||||
{
|
||||
requestId += 1;
|
||||
if (requestId >= MAX_REQUEST_ID)
|
||||
{
|
||||
requestId = MIN_REQUEST_ID;
|
||||
}
|
||||
}
|
||||
return requestId;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user