Giter Site home page Giter Site logo

threadpool_bars's Introduction

Simple thread pool with progress bars in C++

This sample code showcases a simple canonical thread pool which can be tracked by progress bars shown in the terminal. Each thread can be associated with one progress bar, and an additional one accounts for all the tasks in the pool. A simple use case is when each task in the pool is long enough so it could benefit from user feedback while it's executing.

The 'jobs' in this sample are fake and don't do anything other than wait for a certain amount of time. Everything should finish running in about 40s.

It is assumed compilation with gcc, using c++20 (alias template deduction), and output should be fine as long as the terminal can draw the following nine characters in addition to ASCII:

│ ▏ ▎ ▍ ▌ ▋ ▊ ▉ █
(vertical line and 8 block chars gradually filling from left to right)

Finally, the terminal should also support the ANSI escape sequences:

CSI n F        Cursor previous line
CSI ? 25 l     Hide cursor (DECTCEM), VT220
CSI ? 25 h     Show cursor (DECTCEM), VT220
CSI ? 12 l     Stop blinking cursor (AT&T 610)

While the last three sequences are not strictly necessary, they make the output much cleaner ;), though they could be easily disabled, if there is a problem, in ThreadPool::Bars::start().

Compiling the code with the provided makefile and makedepend.py will generate the binary bin/sample.

threadpool_bars's People

Stargazers

ollydbg avatar

Watchers

Leila Alves avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.