Skip to content

Demonstration of a C module using the active object pattern in a faux RTOS environment

License

Notifications You must be signed in to change notification settings

covemountainsoftware/basicActiveObjectDemo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Basic Active Object Demo

This project demonstrates a basic C module using an active object pattern.

This project was created to provide an example code base supporting the following post: https://covemountainsoftware.com/2021/04/20/what-is-an-active-object/

The associated blog post details three elements required to implement an active object:

  • An external API or method to send asynchronous requests
  • A concurrency safe queue to hold the requests
  • A thread to receive and execute the requests

In this example, the C module hwLockCtrlService (HLCS) provides these three elements. In this module we find:

  • A C based external API providing an abstraction for external users, where primary requests are all async and push events onto the internal queue.
  • A private internal queue, modeled after FreeRTOS
  • A private internal thread, modeled after FreeRTOS

Like the original source project, the HLCS implements a simple flat state machine to process the events.

This earlier post provided the origin for this repository and the example active object behavior. https://covemountainsoftware.com/2020/04/17/unit-testing-active-objects-and-state-machines/

Platform

This project should build and execute on any reasonable modern PC with the following:

  • Toolchain supporting C11 and C++17.
  • CMake VERSION 3.16 or newer.
  • Installation of CppUTest version 3.8.

This project was confirmed in the following environments:

  • macOS Catalina Version 10.15.7
  • Ubuntu 20.04

Build Targets

HwLockCtrlServiceTests

Project demonstrating my approach to unit testing an event driven active object.

demoPcApp

This target is a trivial terminal demo app showing the target service in action "for real."

References and Inspiration

Questions?

Contact information is available here: https://covemountainsoftware.com/services/consulting/

About

Demonstration of a C module using the active object pattern in a faux RTOS environment

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published