public bool ShouldDie(LifeTime o, int index) { LifeTimeENUM lifeTime = o.LifeTime; // short objects will live for 20 seconds, long objects will live for more. switch (lifeTime) { case LifeTimeENUM.Short: if (Environment.TickCount - _lastShortTickCount > 1) // this is in accureat enumber, since // we will be finsh iterating throuh the short life time object in less than 1 ms , so we need // to switch either to QueryPeroformanceCounter, or to block the loop for some time through // Thread.Sleep, the other solution is to increase the number of objects a lot. { _lastShortTickCount = Environment.TickCount; _lastShortIndex = index; return(true); } break; case LifeTimeENUM.Medium: if (Environment.TickCount - _lastMediumTickCount > 20) { _lastMediumTickCount = Environment.TickCount; _lastMediumIndex = index; return(true); } break; case LifeTimeENUM.Long: break; } return(false); }
public bool ShouldDie(LifeTime o, int index) { _counter++; LifeTimeENUM lifeTime = o.LifeTime; switch (lifeTime) { case LifeTimeENUM.Short: if (_counter % _shortLifeTime == 0) { return(true); } break; case LifeTimeENUM.Medium: if (_counter % _mediumLifeTime == 0) { return(true); } break; case LifeTimeENUM.Long: return(false); } return(false); }
public int NextObject(LifeTimeENUM lifeTime) { switch (lifeTime) { case LifeTimeENUM.Short: return(_lastShortIndex); case LifeTimeENUM.Medium: return(_lastMediumIndex); case LifeTimeENUM.Long: return(0); } return(0); }
public int NextObject(LifeTimeENUM lifeTime) { switch (lifeTime) { case LifeTimeENUM.Short: return rand.Next() % shortDataCount; case LifeTimeENUM.Medium: return (rand.Next() % mediumDataCount) + shortDataCount; case LifeTimeENUM.Long: return 0; } return 0; }
public int NextObject(LifeTimeENUM lifeTime) { switch (lifeTime) { case LifeTimeENUM.Short: return(_rand.Next() % _shortDataCount); case LifeTimeENUM.Medium: return((_rand.Next() % _mediumDataCount) + _shortDataCount); case LifeTimeENUM.Long: return(0); } return(0); }
public int NextObject(LifeTimeENUM lifeTime) { switch (lifeTime) { case LifeTimeENUM.Short: return lastShortIndex; case LifeTimeENUM.Medium: return lastMediumIndex; case LifeTimeENUM.Long: return 0; } return 0; }