C# Class HikariThreading.ThreadManager

Manages assignment of work for a pool of threads. All methods not marked unsafe are threadsafe. UnsafeUpdate must be called for ThreadManager to do any work, but ThreadManager will not call it.
Inheritance: ManagerBase, IDisposable
ファイルを表示 Open project: ReinAkane/Hikari Class Usage Examples

Private Properties

Property Type Description
DespawnThread void
DespawnThreadIfNeeded bool
EnqueueTask void
HandleDedicatedThreads void
Initialize void
SpawnDedicatedThread void
SpawnThread void
SpawnThreadIfNeeded bool
ThreadManager System
ThreadManager System
ThreadManager System
ThreadManager System
UnsafeHandleThreads void
UnsafeUpdate void
WaitForThreadSpawns void

Public Methods

Method Description
Dispose ( ) : void

Tells all threads managed by this manager to stop running once their Tasks finish up.

Private Methods

Method Description
DespawnThread ( ) : void

Despawns a thread.

DespawnThreadIfNeeded ( ) : bool

Checks if our situation calls for a thread to be despawned. If so, despawns one.

EnqueueTask ( ITask task ) : void

Enqueues a task to be run when the next thread is available.

HandleDedicatedThreads ( ) : void

Checks if any dedicated threads are finished, and if so adds them to the larger pool.

Initialize ( ) : void

Initializes the basic options for the ThreadManager.

SpawnDedicatedThread ( ITask task ) : void

Spawns a dedicated thread to run the passed task. Once the task is completed, the Thread will be recycled.

SpawnThread ( ) : void

Spawns a new thread and adds it to the thread pool.

SpawnThreadIfNeeded ( ) : bool

Checks if our situation calls for a new thread. If so, spawns one.

ThreadManager ( ) : System

Creates a ThreadManager with all the defaults.

ThreadManager ( System.TimeSpan min_ms_between_thread_spawn, System.TimeSpan max_ms_task_waiting_before_thread_spawn, uint max_queue_length_before_thread_spawn, System.TimeSpan max_boredom_time_before_thread_despawn ) : System

Creates a ThreadManager with customized logic on when to spawn and despawn threads.

ThreadManager ( int min_threads, int max_threads ) : System

Creates a very customized ThreadManager.

ThreadManager ( int min_threads, int max_threads, System.TimeSpan min_ms_between_thread_spawn, System.TimeSpan max_ms_task_waiting_before_thread_spawn, uint max_queue_length_before_thread_spawn, System.TimeSpan max_boredom_time_before_thread_despawn ) : System

Creates a very customized ThreadManager.

UnsafeHandleThreads ( ) : void

Assigns work and removed napping Task from their threads.

UnsafeUpdate ( ) : void

Checks for new work in the Queue and sends it out, checks for spawning and despawning threads.

WaitForThreadSpawns ( ) : void

Waits for all Threads to spawn. This is to make automated testing easier.

Method Details

Dispose() public method

Tells all threads managed by this manager to stop running once their Tasks finish up.
public Dispose ( ) : void
return void