示例#1
0
 protected FABChannel(IFABChannel parent, FABChannelId id)
 {
     this.Parent        = parent;
     this.Id            = id;
     this.channelUnsafe = this.NewUnsafe();
     this.pipeline      = this.NewChannelPipeline();
 }
示例#2
0
 public bool Matches(IFABChannel channel)
 {
     IFABChannelMatcher[] matchers = this.matchers;
     for (int i = 0; i < matchers.Length; i++)
     {
         if (!matchers[i].Matches(channel))
         {
             return(false);
         }
     }
     return(true);
 }
示例#3
0
        protected FABSocketChannel(IFABChannel parent, Socket socket)
            : base(parent)
        {
            this.Socket = socket;
            this.state  = StateFlags.Open;

            try
            {
                this.Socket.Blocking = false;
            }
            catch (SocketException ex)
            {
                try
                {
                    socket.Dispose();
                }
                catch (SocketException ex2)
                {
                    throw ex2;
                }

                throw new FABChannelException("Failed to enter non-blocking mode.", ex);
            }
        }
示例#4
0
 public void Add(IFABChannel item)
 {
     this.Add(item);
 }
示例#5
0
文件: Util.cs 项目: MrPoP/FABSolution
 public static void CloseSafe(this IFABChannel channel)
 {
     CompleteChannelCloseTaskSafely(channel, channel.CloseAsync());
 }
示例#6
0
 public int CompareTo(IFABChannel o)
 {
     return(ReferenceEquals(this, o) ? 0 : this.Id.CompareTo(o.Id));
 }
示例#7
0
 internal FABChannelOutboundBuffer(IFABChannel channel)
 {
     this.channel = channel;
 }
示例#8
0
 public Task Find(IFABChannel channel)
 {
     return(this.futures[channel]);
 }
示例#9
0
 public bool Matches(IFABChannel ch)
 {
     return(this.channel == ch);
 }
示例#10
0
 public static IFABChannelMatcher IsNot(IFABChannel channel)
 {
     return(Invert(Is(channel)));
 }
示例#11
0
 public bool Matches(IFABChannel channel)
 {
     return(true);
 }
示例#12
0
 public static IFABChannelMatcher Is(IFABChannel channel)
 {
     return(new InstanceMatcher(channel));
 }
示例#13
0
 public bool Matches(IFABChannel channel)
 {
     return(this.type.IsInstanceOfType(channel));
 }
示例#14
0
 public bool Matches(IFABChannel channel)
 {
     return(!this.matcher.Matches(channel));
 }
示例#15
0
 public bool Contains(IFABChannel item)
 {
     return(this.Contains(item));
 }
示例#16
0
        public FABChannelGroupCompletionSource(IFABChannelGroup sgroup, Dictionary <IFABChannel, Task> futures /*, IEventExecutor executor*/, object state)
            : base(state)
        {
            Contract.Requires(sgroup != null);
            Contract.Requires(futures != null);

            this.groub   = sgroup;
            this.futures = new Dictionary <IFABChannel, Task>();
            foreach (KeyValuePair <IFABChannel, Task> pair in futures)
            {
                this.futures.Add(pair.Key, pair.Value);
                pair.Value.ContinueWith(x =>
                {
                    bool success = x.Status == TaskStatus.RanToCompletion;
                    bool callSetDone;
                    lock (this)
                    {
                        if (success)
                        {
                            this.successCount++;
                        }
                        else
                        {
                            this.failureCount++;
                        }

                        callSetDone = this.successCount + this.failureCount == this.futures.Count;
                        Contract.Assert(this.successCount + this.failureCount <= this.futures.Count);
                    }

                    if (callSetDone)
                    {
                        if (this.failureCount > 0)
                        {
                            var failed = new List <KeyValuePair <IFABChannel, Exception> >();
                            foreach (KeyValuePair <IFABChannel, Task> ft in this.futures)
                            {
                                IFABChannel c = ft.Key;
                                Task f        = ft.Value;
                                if (f.IsFaulted || f.IsCanceled)
                                {
                                    if (f.Exception != null)
                                    {
                                        failed.Add(new KeyValuePair <IFABChannel, Exception>(c, f.Exception.InnerException));
                                    }
                                }
                            }
                            this.TrySetException(new FABChannelGroupException(failed));
                        }
                        else
                        {
                            this.TrySetResult(0);
                        }
                    }
                });
            }

            // Done on arrival?
            if (futures.Count == 0)
            {
                this.TrySetResult(0);
            }
        }
示例#17
0
 public bool Remove(IFABChannel item)
 {
     return(this.Remove(item));
 }
示例#18
0
 public InstanceMatcher(IFABChannel channel)
 {
     this.channel = channel;
 }