GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - mporsch/switchbuffer: Producer/Consumer communication buffer

BranchesTags
Open more actions menu

Latest commit

 

History

49 Commits
49 Commits

Folders and files

NameName
Last commit message
Last commit date
CMakeLists.txt
CMakeLists.txt
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
switchbuffer-config.cmake
switchbuffer-config.cmake
 
 
switchbuffer.h
switchbuffer.h
 
 
switchbuffer_impl.h
switchbuffer_impl.h
 
 
switchbuffer_test.cpp
switchbuffer_test.cpp
 
 

Repository files navigation

switchbuffer

A generic producer/multi-consumer communication buffer implemented as C++11 header-only library without external dependencies.

Designed for use where a push-based producer meets pull-based consumers, e.g. a pollable interface to a network stream. The producer has non-blocking write access to the buffer while multiple consumers can access the last N most recent entries safely without interfering with one another or the producer.

ring

Design goals

  • The buffer slot type is given as template argument.
  • The single producer has non-blocking access to the buffer slots, independent of the state or number of consumers.
  • Multiple consumers can read the written buffer slots in parallel.
  • Multiple buffer slots stored as ring of user-defined size allow to compensate intermittent differences in producer and consumer performance without loss.
  • A consumer that is generally slower than the producer may skip to the most recently produced buffer slot.
  • If a consumer has read all buffer slots, the returned std::future allows waiting for fresh input from the producer.
  • Producer and consumers are given separate interfaces to remove any room for mishandling (interface segregation principle).
  • Interfaces are distributed via smart pointers to handle producer and consumer shutdown and final resource cleanup.
  • Consumers may empty the remaining buffer slots after the producer is gone.

Build

Build test using CMake or $ g++ -o switchbuffer_test switchbuffer_test.cpp -std=c++11 -lpthread

About

Producer/Consumer communication buffer

Topics

interfaceinterface-segregation-principlemultithreadingproducer-consumerring-buffer

Resources

Readme
GPL-3.0 license
Activity

Stars

3 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.