Example #1
0
        /// <summary>
        /// Creates new instance of <see cref="AtomicInteger"/>
        /// </summary>
        /// <param name="value">The value to store</param>
        /// <param name="order">Affects the way store operation occur. Load operations are always use <see cref="MemoryOrder.Acquire"/> semantics</param>
        /// <param name="align">True to store the underlying value aligned, otherwise False</param>
        public AtomicInteger(int value, MemoryOrder order = MemoryOrder.SeqCst, bool align = false)
        {
            if (!order.IsSpported())
            {
                throw new ArgumentException(string.Format("{0} is not supported", order));
            }

            _order        = order;
            this._storage = BoxedInt32.Create(value, align);
        }
        /// <summary>
        /// Creates new instance of <see cref="AtomicInteger"/>
        /// </summary>
        /// <param name="value">The value to store</param>
        /// <param name="order">Affects the way store operation occur. Load operations are always use <see cref="MemoryOrder.Acquire"/> semantics</param>
        /// <param name="align">True to store the underlying value aligned, otherwise False</param>
        public AtomicInteger(int value, MemoryOrder order = MemoryOrder.SeqCst, bool align = false)
        {
            order.ThrowIfNotSupported();

            _order = order;
            if (align)
            {
                this._storage = BoxedInt32.Create(value);
            }
            else
            {
                this.acqRelValue = value;
                this._storage    = BoxedInt32.Create(this);
            }
        }