Represents a thread-safe Boolean value.
Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NetworkSession"/> class.
        /// </summary>
        public NetworkSession()
        {
            this.isActive = false;

            this.receiveDescriptor = new ReceiveDescriptor(this);
            this.sendDescriptor = new SendDescriptor(this);
        }
Esempio n. 2
0
        public void FlipIf_Should_Return_True_When_Flip_Is_Successful()
        {
            var b = new AtomicBoolean(true);

            var flipped = b.FlipIf(true);

            flipped.Should().BeTrue();
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SendDescriptor"/> class.
        /// </summary>
        /// <param name="container">The <see cref="IDescriptorContainer"/> containing this instance.</param>
        /// <exception cref="ArgumentNullException">
        /// Thrown if <paramref name="container" /> is <see langword="null"/>.
        /// </exception>
        public SendDescriptor(IDescriptorContainer container)
            : base(container)
        {
            this.SocketArgs.Completed += this.EndSendAsynchronous;

            this.isSending = new AtomicBoolean(false);
            this.queue = new ConcurrentQueue<byte[]>();
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ServerSession"/> class.
        /// </summary>
        public ServerSession(IPacketCodeTable packetCodeTable)
        {
            this.NetworkSessionId = RollingNetworkSessionId.Increment();

            this.isPushing = false;
            this.packets = new ConcurrentQueue<byte[]>();

            this.packetCodeTable = packetCodeTable;

            this.PacketReceived += this.HandlePacketReceived;
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ServerProcess"/> class.
        /// </summary>
        public ServerProcess(
            IServerSessionFactory sessionFactory,
            ISocketAcceptorFactory socketAcceptorFactory,
            IPacketScheduler packetScheduler,
            IRollingIvFactoryProvider rollingIvFactoryProvider,
            IvGenerator ivGenerator,
            ILogger logger)
        {
            this.sessionFactory = sessionFactory;
            this.socketAcceptorFactory = socketAcceptorFactory;
            this.packetScheduler = packetScheduler;
            this.rollingIvFactoryProvider = rollingIvFactoryProvider;
            this.ivGenerator = ivGenerator;
            this.logger = logger;

            this.isConfigured = false;
            this.isDisposed = false;
            this.isRunning = new AtomicBoolean(false);
        }
Esempio n. 6
0
        public void FlipIf_Should_Set_New_Value_When_Comparand_Matches()
        {
            var b = new AtomicBoolean(true);

            b.FlipIf(true);

            b.Value.Should().BeFalse();
        }
Esempio n. 7
0
 public void Explicit_Cast_Should_Cast_To_True()
 {
     var b = new AtomicBoolean(true);
     var cast = (bool)b;
     cast.Should().BeTrue();
 }
Esempio n. 8
0
 public void Explicit_Cast_Should_Cast_To_False()
 {
     var b = new AtomicBoolean(false);
     var cast = (bool)b;
     cast.Should().BeFalse();
 }
Esempio n. 9
0
 public void Constructor_Should_Set_Value_To_True()
 {
     var b = new AtomicBoolean(true);
     b.Value.Should().BeTrue();
 }
Esempio n. 10
0
 public void Constructor_Should_Set_Value_To_False()
 {
     var b = new AtomicBoolean(false);
     b.Value.Should().BeFalse();
 }
Esempio n. 11
0
 public void ToBoolean_Should_Return_True()
 {
     var b = new AtomicBoolean(true);
     b.ToBoolean().Should().BeTrue();
 }
Esempio n. 12
0
 public void ToBoolean_Should_Return_False()
 {
     var b = new AtomicBoolean(false);
     b.ToBoolean().Should().BeFalse();
 }
Esempio n. 13
0
 public void Static_ToBoolean_Should_Return_True()
 {
     var b = new AtomicBoolean(true);
     AtomicBoolean.ToBoolean(b).Should().BeTrue();
 }
Esempio n. 14
0
 public void Static_ToBoolean_Should_Return_False()
 {
     var b = new AtomicBoolean(false);
     AtomicBoolean.ToBoolean(b).Should().BeFalse();
 }
Esempio n. 15
0
        public void Set_Should_Set_New_Value()
        {
            var b = new AtomicBoolean(false);

            b.Set(true);

            b.Value.Should().BeTrue();
        }