Skip to content

A C++ library to support the active object concept.

Notifications You must be signed in to change notification settings

edinbura/threadit-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

threadit-cpp

A C++ library to support the active object concept.

Class CThreadIt supports the asynchronous model of an active object that can accept request to do work within a thread of control and return the result of the work processing. Work requests are accepted and stored in a buffer until the thread is able to perform the work associated with the request. Completed work requests (the result of the work) are buffered until the requestor is able to retrieve the result. The model requires the following classes:

CWorkPackIt      -   This class describes the work to be performed.
CWorkPackIt      -   This class describes the results of the work.
CThreadIt           -   Implements the model that defines how clients are able to execute work in separate thread.
Derived Class  -   Defines the processing to perform in response to work requests.

The class derived from CThreadIt creates work packages using CWorkPackIt. These work packages are associated with a given method that the class implements. When the CThreadIt class gets the work package it will invoke the method in it's own thread of control. The method implementation takes the input values from the work packages and peforms the necessary processing. When finished the results are compiled and placed in a given output queue. The next work package in the input queue is retrieved. The model also includes asynchronous notification to the requestor when work is completed. By following simple rules it is very easy for an application to utilise active objects using the model defined here.

As an example, class CThreadIt can be used to provide a separate thread of execution to perform processing on behalf of clients with a processing completion notification being sent to the client. This would find use when a User Interface must perform a lengthy process that may tie up the screen response. The processing may be delegated to an instance derived from this class for execution in separate thread thus not impacting on the user response. When work is complete the User Interface is notified and retrieves the work done from the work output queue.

Another use case on the server is to accept incoming requests with the ability to check the incoming queue size and then take action if the processing is taking to long and the request queue is increasing in size.

This project uses the following libraries:

Log for C++

Log for C++ is a library of C++ classes for flexible logging to files, syslog and other destinations. It is modeled after the Log for Java library (http://jakarta.apache.org/log4j/), staying as close to their API as is reasonable.

UnitTest++

UnitTest++ is a lightweight unit testing framework for C++. It was designed to do test-driven development on a wide variety of platforms. Simplicity, portability, speed, and small footprint are all very important aspects of UnitTest++. UnitTest++ is mostly standard C++ and makes minimal use of advanced library and language features, which means it should be easily portable to just about any platform. Out of the box, the following platforms are supported:
  • Windows
  • Linux
  • Mac OS X

About

A C++ library to support the active object concept.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published