[][src]Module sealrs::executors::thread_pinned_executor

'One queue per thread' implementation of executor

In this implementation of executor, each thread has its own task queue. Caller code may explicitly specify thread number on which task will be executed. If thread number does not set, thread selection strategy will be used. Should pay attention on that selection of thread number by the executor is always slowly than his explicitly setting, because thread selecting algorithm is always perform some more heavy work, compared to direct task loading.

Examples

let mut executor = ThreadPinnedExecutor::new()
    .set_threads_count(8)
    .set_distribution_strategy(DistributionStrategy::Load)
    .run();

let f0 = Box::new( || { println!("Task on implicitly selected thread") });
executor.execute(f0, None);

let f1 = Box::new( || { println!("Task on explicitly selected thread with id 6") });
executor.execute(f1, Some( Box::new(TaskOptions { thread_id: Some(6) } )));

Structs

TaskOptions

Options which will may be passed with task

ThreadPinnedExecutor

Enums

DistributionStrategy

Automatically thread selection strategy