Menu

A C++ serial task executor - influenced by earlier Android AsyncTask's serialexecutor...
📰

A C++ serial task executor - influenced by earlier Android AsyncTask's serialexecutor...

DEV Community: cpp·Somenath Mukhopadhyay·14 days ago
#vwvdp0NS
#devtocpp#devto#dev#pragma#include
Long article (1906 words) — no AI summary yet.
Reading 0:00
15s threshold

AI-generated content but worth the effort...

This project is a C++20 re-creation of early Android AsyncTask ( SERIAL_EXECUTOR ) : background work runs strictly one task at a time in FIFO order on a dedicated worker thread, while UI/progress/completion callbacks are marshaled back to a main/UI thread loop so you don't race on UI state.

High-Level Architecture & Threading Model

There are two distinct threads in the application:

Main / UI Thread ( main.cpp + MainThreadLoop )

Background Worker Thread ( SerialExecutor )

A. SerialExecutor ( SerialExecutor.h / SerialExecutor.cpp )

FIFO Queue + Synchronization: Protects queue_ and stopping_ with a std::mutex , using std::condition_variable ( cv_ ) so the worker sleeps with zero CPU spin when idle and wakes immediately when a task arrives or shutdown begins.

Why std::deque ?…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.