Exemplo n.º 1
0
        /// <summary>
        /// Creates an asynchronous channel group with a given thread pool.
        ///
        /// <para> The {@code executor} parameter is an {@code ExecutorService} that
        /// executes tasks submitted to dispatch completion results for operations
        /// initiated on asynchronous channels in the group.
        ///
        /// </para>
        /// <para> Care should be taken when configuring the executor service. It
        /// should support <em>direct handoff</em> or <em>unbounded queuing</em> of
        /// submitted tasks, and the thread that invokes the {@link
        /// ExecutorService#execute execute} method should never invoke the task
        /// directly. An implementation may mandate additional constraints.
        ///
        /// </para>
        /// <para> The executor is intended to be used exclusively by the resulting
        /// asynchronous channel group. Termination of the group results in the
        /// orderly  <seealso cref="ExecutorService#shutdown shutdown"/> of the executor
        /// service. Shutting down the executor service by other means results in
        /// unspecified behavior.
        ///
        /// </para>
        /// <para> The group is created by invoking the {@link
        /// AsynchronousChannelProvider#openAsynchronousChannelGroup(ExecutorService,int)
        /// openAsynchronousChannelGroup(ExecutorService,int)} method of the system-wide
        /// default <seealso cref="AsynchronousChannelProvider"/> object with an {@code
        /// initialSize} of {@code 0}.
        ///
        /// </para>
        /// </summary>
        /// <param name="executor">
        ///          The thread pool for the resulting group
        /// </param>
        /// <returns>  A new asynchronous channel group
        /// </returns>
        /// <exception cref="IOException">
        ///          If an I/O error occurs </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static AsynchronousChannelGroup withThreadPool(java.util.concurrent.ExecutorService executor) throws java.io.IOException
        public static AsynchronousChannelGroup WithThreadPool(ExecutorService executor)
        {
            return(AsynchronousChannelProvider.Provider().OpenAsynchronousChannelGroup(executor, 0));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates an asynchronous channel group with a given thread pool that
        /// creates new threads as needed.
        ///
        /// <para> The {@code executor} parameter is an {@code ExecutorService} that
        /// creates new threads as needed to execute tasks that are submitted to
        /// handle I/O events and dispatch completion results for operations initiated
        /// on asynchronous channels in the group. It may reuse previously constructed
        /// threads when they are available.
        ///
        /// </para>
        /// <para> The {@code initialSize} parameter may be used by the implementation
        /// as a <em>hint</em> as to the initial number of tasks it may submit. For
        /// example, it may be used to indicate the initial number of threads that
        /// wait on I/O events.
        ///
        /// </para>
        /// <para> The executor is intended to be used exclusively by the resulting
        /// asynchronous channel group. Termination of the group results in the
        /// orderly  <seealso cref="ExecutorService#shutdown shutdown"/> of the executor
        /// service. Shutting down the executor service by other means results in
        /// unspecified behavior.
        ///
        /// </para>
        /// <para> The group is created by invoking the {@link
        /// AsynchronousChannelProvider#openAsynchronousChannelGroup(ExecutorService,int)
        /// openAsynchronousChannelGroup(ExecutorService,int)} method of the system-wide
        /// default <seealso cref="AsynchronousChannelProvider"/> object.
        ///
        /// </para>
        /// </summary>
        /// <param name="executor">
        ///          The thread pool for the resulting group </param>
        /// <param name="initialSize">
        ///          A value {@code >=0} or a negative value for implementation
        ///          specific default
        /// </param>
        /// <returns>  A new asynchronous channel group
        /// </returns>
        /// <exception cref="IOException">
        ///          If an I/O error occurs
        /// </exception>
        /// <seealso cref= java.util.concurrent.Executors#newCachedThreadPool </seealso>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static AsynchronousChannelGroup withCachedThreadPool(java.util.concurrent.ExecutorService executor, int initialSize) throws java.io.IOException
        public static AsynchronousChannelGroup WithCachedThreadPool(ExecutorService executor, int initialSize)
        {
            return(AsynchronousChannelProvider.Provider().OpenAsynchronousChannelGroup(executor, initialSize));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates an asynchronous channel group with a fixed thread pool.
        ///
        /// <para> The resulting asynchronous channel group reuses a fixed number of
        /// threads. At any point, at most {@code nThreads} threads will be active
        /// processing tasks that are submitted to handle I/O events and dispatch
        /// completion results for operations initiated on asynchronous channels in
        /// the group.
        ///
        /// </para>
        /// <para> The group is created by invoking the {@link
        /// AsynchronousChannelProvider#openAsynchronousChannelGroup(int,ThreadFactory)
        /// openAsynchronousChannelGroup(int,ThreadFactory)} method of the system-wide
        /// default <seealso cref="AsynchronousChannelProvider"/> object.
        ///
        /// </para>
        /// </summary>
        /// <param name="nThreads">
        ///          The number of threads in the pool </param>
        /// <param name="threadFactory">
        ///          The factory to use when creating new threads
        /// </param>
        /// <returns>  A new asynchronous channel group
        /// </returns>
        /// <exception cref="IllegalArgumentException">
        ///          If {@code nThreads <= 0} </exception>
        /// <exception cref="IOException">
        ///          If an I/O error occurs </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static AsynchronousChannelGroup withFixedThreadPool(int nThreads, java.util.concurrent.ThreadFactory threadFactory) throws java.io.IOException
        public static AsynchronousChannelGroup WithFixedThreadPool(int nThreads, ThreadFactory threadFactory)
        {
            return(AsynchronousChannelProvider.Provider().OpenAsynchronousChannelGroup(nThreads, threadFactory));
        }
Exemplo n.º 4
0
 /// <summary>
 /// Initialize a new instance of this class.
 /// </summary>
 /// <param name="provider">
 ///          The asynchronous channel provider for this group </param>
 protected internal AsynchronousChannelGroup(AsynchronousChannelProvider provider)
 {
     this.Provider_Renamed = provider;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Opens an asynchronous socket channel.
        ///
        /// <para> The new channel is created by invoking the {@link
        /// AsynchronousChannelProvider#openAsynchronousSocketChannel
        /// openAsynchronousSocketChannel} method on the {@link
        /// AsynchronousChannelProvider} that created the group. If the group parameter
        /// is {@code null} then the resulting channel is created by the system-wide
        /// default provider, and bound to the <em>default group</em>.
        ///
        /// </para>
        /// </summary>
        /// <param name="group">
        ///          The group to which the newly constructed channel should be bound,
        ///          or {@code null} for the default group
        /// </param>
        /// <returns>  A new asynchronous socket channel
        /// </returns>
        /// <exception cref="ShutdownChannelGroupException">
        ///          If the channel group is shutdown </exception>
        /// <exception cref="IOException">
        ///          If an I/O error occurs </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static AsynchronousSocketChannel open(AsynchronousChannelGroup group) throws java.io.IOException
        public static AsynchronousSocketChannel Open(AsynchronousChannelGroup group)
        {
            AsynchronousChannelProvider provider = (group == null) ? AsynchronousChannelProvider.Provider() : group.Provider();

            return(provider.OpenAsynchronousSocketChannel(group));
        }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of this class.
 /// </summary>
 /// <param name="provider">
 ///         The provider that created this channel </param>
 protected internal AsynchronousSocketChannel(AsynchronousChannelProvider provider)
 {
     this.Provider_Renamed = provider;
 }