コード例 #1
0
ファイル: ChannelEnd.cs プロジェクト: bbants/cocol
 /// <summary>
 /// Initializes a new instance of the <see cref="CoCoL.ChannelEndBase"/> class.
 /// </summary>
 public ChannelEndBase(IRetireAbleChannel target, bool isReader)
 {
     if (target == null)
     {
         throw new ArgumentNullException("target");
     }
     m_isReader = isReader;
     m_target   = target;
     JoinAsync().WaitForTaskOrThrow();
 }
コード例 #2
0
ファイル: ChannelEnd.cs プロジェクト: bbants/cocol
        /// <summary>
        /// Releases all resource used by the <see cref="CoCoL.ChannelEndBase"/> object.
        /// </summary>
        /// <param name="disposing"><c>true</c> if disposing, <c>false</c> otherwise</param>
        /// <remarks>Call <see cref="Dispose()"/> when you are finished using the <see cref="CoCoL.ChannelEndBase"/>. The
        /// <see cref="Dispose()"/> method leaves the <see cref="CoCoL.ChannelEndBase"/> in an unusable state. After calling
        /// <see cref="Dispose()"/>, you must release all references to the <see cref="CoCoL.ChannelEndBase"/> so the garbage
        /// collector can reclaim the memory that the <see cref="CoCoL.ChannelEndBase"/> was occupying.</remarks>
        public void Dispose(bool disposing)
        {
            if (!disposing)
            {
                GC.SuppressFinalize(this);
            }

            if (m_target != null)
            {
                LeaveAsync().WaitForTaskOrThrow();
            }
            m_target = null;
        }
コード例 #3
0
        /// <summary>
        /// Injects a channel into the current scope.
        /// </summary>
        /// <param name="name">The name of the channel to create.</param>
        /// <param name="channel">The channel to inject.</param>
        public void InjectChannel(string name, IRetireAbleChannel channel)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (channel == null)
            {
                throw new ArgumentNullException(nameof(channel));
            }

            lock (__lock)
                m_lookup[name] = channel;
        }
コード例 #4
0
ファイル: ChannelExtensions.cs プロジェクト: kenkendk/cocol
 /// <summary>
 /// Leave the channel in a blocking manner
 /// </summary>
 /// <param name="self">The channel to leave.</param>
 /// <param name="immediate">Set to <c>true</c> if the channel is retired immediately.</param>
 public static void Retire(this IRetireAbleChannel self, bool immediate = false)
 {
     self.RetireAsync(immediate).WaitForTaskOrThrow();
 }