views:

110

answers:

4

How would you name a class with the following public interface:

/// <summary>
///     Enqeues and exectutes actions synchronously on seperated threads using the <see cref="ThreadPool"/>. 
/// </summary>
/// <remarks>
///     Syncronism is guaranteed on a per-instance base in that each enqued action will be executed
///     after the previous action has completed execution for each instance of <see cref="ThreadPoolExectutor" /> 
/// </remarks>
internal class ThreadPoolExectutor
{
    /// <summary>
    /// Initializes a new instance of the <see cref="ThreadPoolExectutor"/> class.
    /// </summary>
    /// <param name="capacity">The absolute (not the initial) number of elements that the <see cref="ThreadPoolExectutor"/> can contain.</param>
    public ThreadPoolExectutor(int capacity)

    /// <summary>
    /// Occurs when exception occured during execution.
    /// </summary>
    public event EventHandler<ExceptionEventArgs> ExceptionOccurred;

    /// <summary>
    /// Enqueues a new action with a single parameter for execution on the thread pool.
    /// </summary>
    /// <param name="action">
    /// The action to enqueue for execution.
    /// </param>
    /// <param name="param">
    /// The parameter for the action.
    /// </param>
    /// <typeparam name="TArg">
    /// The type of the <paramref name="param"/>.
    /// </typeparam>
    public void Execute<TArg>(Action<TArg> action, TArg param)

    /// <summary>
    /// Enqueues a new action with no parameters for execution on the thread pool.
    /// </summary>
    /// <param name="action">
    /// The action to enqueue for execution.
    /// </param>
    public void Execute(Action action)
}
+5  A: 

Enqeues and exectutes actions

I would call it ThreadPoolDispatcher

Andrey
I was going to say something similar, but the name should indicate that there is a queuing mechanism at work so your Thread won't be dispatched immediately.
Justin Niessner
Well better than a "tutor" since I see no tutorial in the class, and it does not seem to be an "Exec" to nor does it "Execute" anyone :)
Mark Schultheiss
@Justin Niessner i disagree. queuing is internals of class and should not be exposed. i think Dispatcher is descriptive enough, it means that it *handles* threads the way it thinks it is best.
Andrey
I renamed it to `ThreadPoolDispatcher` and remaned the `Execute` methods to `Invoke`. This matches `System.Windows.Threading.Dispatcher`.
bitbonk
A: 

I would name it ThreadPoolManager

nrocha
manager is a bad name - it seems to indicate a God class and good design principles tell us to move away from those type of classes
PaulStack
I want all my classes to be God like and inspire awe in the beer holder :)
Mark Schultheiss
+1  A: 

personally id try and refactor the class into 2 smaller ones to follow the Single Responsibility Principal - therefore have a class for Executing actions

ThreadPoolDispatcher [as per the above suggestion that i agree with]

and then a ThreadPoolQueuer which will be responsible for queuing threads

just personal preference though

PaulStack
good single purpose note
Mark Schultheiss
Going with YAGNI, I will refactor it your way as soon as I need seprate queueing strategies. (I wonder if this way of thinking is wise though).
bitbonk
A: 

How about ThreadPoolAgent.

Chris