Skip to content

Crate for parallel task execution and building multithreading servers with scheduler

Notifications You must be signed in to change notification settings

gus3inov/multix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MultiX

Thread pool crate to execute a certain number of jobs on a fixed set of worker threads.

ThreadPool Module

When connecting thread pool is filled with a certain number of workers, which is specified in the constructor. In the context of each worker, certain job is done. Job is a closure that is passed to the execute thread pool. Workers communicate with each other through channels

Usage

extern crate multithread;

use multithread::ThreadPool;

fn main () {
    let pool = ThreadPool::new(4).unwrap();

    pool.execute(|| {
        // some closure body ...
    });
}

API

  • prop workers - vector of workers. Worker has a field id and thread in which executing closure

  • prop sender - message sender

  • fn new - constructor takes one argument of type usize, which specifies the maximum number of workers to create. The result of executing the constructor is a value of type Result<ThreadPool, &'static str>,depending on the first parameter passed

  • fn execute - The first argument is a closure of type FnOnce() + Send. When the call sends messages, receives the message and executes it.

About

Crate for parallel task execution and building multithreading servers with scheduler

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages