Skip to content

C++17 concurrency examples: thread pool, producer-consumer, concurrent LRU cache

Notifications You must be signed in to change notification settings

rishitgrg/cpp-concurrency-project

Repository files navigation

C++ Concurrency Projects (C++17)

This repository contains a collection of small but practical C++17 projects focused on multithreading, synchronization, and thread-safe data structures.
The goal is to demonstrate clean, maintainable, and production-style C++ code using standard library concurrency primitives.

These projects are intentionally lightweight, dependency-free, and written in a style commonly used in real-world backend systems.


Projects Overview

1. Thread Pool

A fixed-size thread pool implementation that:

  • Manages a pool of worker threads
  • Executes submitted tasks asynchronously
  • Uses a task queue with proper synchronization

Concepts covered

  • std::thread
  • std::mutex, std::condition_variable
  • Task queues
  • RAII-based resource management

2. Producer–Consumer (Bounded Buffer)

A classic producer–consumer problem implementation with:

  • A bounded shared buffer
  • Proper blocking using condition variables
  • Safe access to shared state

Concepts covered

  • Mutex locking
  • Condition variables
  • Thread coordination
  • Avoiding busy waiting

3. Concurrent LRU Cache

A thread-safe LRU (Least Recently Used) cache that:

  • Supports concurrent get and put operations
  • Maintains eviction order using a doubly linked list
  • Ensures correctness under multi-threaded access

Concepts covered

  • Thread-safe data structures
  • Cache eviction policies
  • Lock-based concurrency control
  • STL containers (unordered_map, list)

Repository Structure

About

C++17 concurrency examples: thread pool, producer-consumer, concurrent LRU cache

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages