Пример #1
0
            public override object Generate(IAccessCallback callback)
            {
                using (_asyncLock.Lock())
                {
                    if (_lastSourceValue < 0)
                    {
                        _lastSourceValue = callback.GetNextValue();
                        while (_lastSourceValue <= 0)
                        {
                            _lastSourceValue = callback.GetNextValue();
                        }

                        // upperLimit defines the upper end of the bucket values
                        _upperLimit = (_lastSourceValue * IncrementSize) + 1;

                        // initialize value to the low end of the bucket
                        _value = _upperLimit - IncrementSize;
                    }
                    else if (_upperLimit <= _value)
                    {
                        _lastSourceValue = callback.GetNextValue();
                        _upperLimit      = (_lastSourceValue * IncrementSize) + 1;
                    }

                    return(Make(_value++));
                }
            }
Пример #2
0
            public override object Generate(IAccessCallback callback)
            {
                if (_hiValue < 0)
                {
                    _value = callback.GetNextValue();
                    if (_value < 1)
                    {
                        // unfortunately not really safe to normalize this
                        // to 1 as an initial value like we do the others
                        // because we would not be able to control this if
                        // we are using a sequence...
                        Log.Info("pooled optimizer source reported [" + _value + "] as the initial value; use of 1 or greater highly recommended");
                    }

                    if ((_initialValue == -1 && _value < IncrementSize) || _value == _initialValue)
                    {
                        _hiValue = callback.GetNextValue();
                    }
                    else
                    {
                        _hiValue = _value;
                        _value   = _hiValue - IncrementSize;
                    }
                }
                else if (_value >= _hiValue)
                {
                    _hiValue = callback.GetNextValue();
                    _value   = _hiValue - IncrementSize;
                }
                return(Make(_value++));
            }
Пример #3
0
 public override object Generate(IAccessCallback callback)
 {
     if (_lastSourceValue < 0 || _value >= (_lastSourceValue + IncrementSize))
     {
         _lastSourceValue = callback.GetNextValue();
         _value           = _lastSourceValue;
         // handle cases where initial-value is less than one (hsqldb for instance).
         while (_value < 1)
         {
             _value++;
         }
     }
     return(Make(_value++));
 }
Пример #4
0
            public override object Generate(IAccessCallback callback)
            {
                // We must use a local variable here to avoid concurrency issues.
                // With the local value we can avoid synchronizing the whole method.

                long val = -1;

                while (val <= 0)
                {
                    val = callback.GetNextValue();
                }

                // This value is only stored for easy access in test. Should be no
                // threading concerns there.
                _lastSourceValue = val;

                return(Make(val));
            }
Пример #5
0
			public override object Generate(IAccessCallback callback)
			{
				if (_lastSourceValue < 0 || _value >= (_lastSourceValue + IncrementSize))
				{
					_lastSourceValue = callback.GetNextValue();
					_value = _lastSourceValue;
					// handle cases where initial-value is less than one (hsqldb for instance).
					while (_value < 1)
						_value++;
				}
				return Make(_value++);
			}
Пример #6
0
			public override object Generate(IAccessCallback callback)
			{
				if (_hiValue < 0)
				{
					_value = callback.GetNextValue();
					if (_value < 1)
					{
						// unfortunately not really safe to normalize this
						// to 1 as an initial value like we do the others
						// because we would not be able to control this if
						// we are using a sequence...
						Log.Info("pooled optimizer source reported [" + _value + "] as the initial value; use of 1 or greater highly recommended");
					}

					if ((_initialValue == -1 && _value < IncrementSize) || _value == _initialValue)
						_hiValue = callback.GetNextValue();
					else
					{
						_hiValue = _value;
						_value = _hiValue - IncrementSize;
					}
				}
				else if (_value >= _hiValue)
				{
					_hiValue = callback.GetNextValue();
					_value = _hiValue - IncrementSize;
				}
				return Make(_value++);
			}
Пример #7
0
			public override object Generate(IAccessCallback callback)
			{
				// We must use a local variable here to avoid concurrency issues.
				// With the local value we can avoid synchronizing the whole method.

				long val = -1;
				while (val <= 0)
					val = callback.GetNextValue();

				// This value is only stored for easy access in test. Should be no
				// threading concerns there.
				_lastSourceValue = val;

				return Make(val);
			}
Пример #8
0
			public override object Generate(IAccessCallback callback)
			{
				if (_lastSourceValue < 0)
				{
					_lastSourceValue = callback.GetNextValue();
					while (_lastSourceValue <= 0)
					{
						_lastSourceValue = callback.GetNextValue();
					}

					// upperLimit defines the upper end of the bucket values
					_upperLimit = (_lastSourceValue * IncrementSize) + 1;

					// initialize value to the low end of the bucket
					_value = _upperLimit - IncrementSize;
				}
				else if (_upperLimit <= _value)
				{
					_lastSourceValue = callback.GetNextValue();
					_upperLimit = (_lastSourceValue * IncrementSize) + 1;
				}
				return Make(_value++);
			}