A simple worker in rust

--

Creating a worker is too important when you want to execute a concurrent job.

src: https://salonegupta.wordpress.com/2017/12/28/internals-of-a-java-thread-pool/

Why queue a task instead of spawning thread for each job?

If your job is a short-lived process, You’ll end up in spending more time on creating and exiting the thread. So it is better to queue the task and execute the job sequentially in a sperate thread.

I’ve not used any queue and multiple threads, you can improve by adding FIFO queue and executing the task in multiple threads to get more concurrency.

Don’t use infinite for loops in the job, it’ll block the thread. For the long running process, it is better to create a separate thread.

PS: Code may not be idiomatic, still learning rust.

--

--