Channels ▼


Multi-Core OO: Part 3

The Differences between Circuits and Classes

While class instances are passive entities that are "executed" by one or more explicitly created threads, circuit instances can be thought of as active entities that execute asynchronously and communicate through their connections. Synchronization is mostly achieved through the use of high level operations like collection, multiplexing, distribution, repetition and their reciprocal operations; splitting, de-multiplexing, competing and reduction. Explicit locking is provided but is seldom required.

Circuit member functions (methods) can be multi-dimensional, and each element can own its own individual state; this provides implicit concurrency and in many cases replaces constructs like parallel_for. It is also possible to specify the number of times that member function elements can be re-entered simultaneously without blocking (reentrancy).

There is no limit to the concurrency that a circuit component or circuit instance can have. If a multi-dimensional component has multi-dimensional member components then the resulting concurrency will be the product of the two component concurrencies. If the application's synchronization logic permits two or more components to execute simultaneously then the resulting concurrency will be the sum of the two or more component concurrencies, and so-on. This means that concurrency can be incrementally realized and accrued in a top-down manner, rather than starting with low-level loops; but both approaches will work interoperably as appropriate (methods can contain TPL, TBB, etc).

Building Applications from Components

Circuit components are intrinsically "self distributing" and so developer code doesn't typically need to know anything about their internals in order to re-use them; it's usually just a case of connecting the appropriate input and output pins (a prototyped operation). Since most user defined circuits are arbitrarily compose-able, they can be archived into "topic" libraries and re-used across projects. This means that applications can be created by domain experts using a drag-drop-and-connect metaphor.

The example below shows a simplified military sonar system constructed from re-usable components (circuit instances).


The object-oriented model is conceptually asynchronous in that its actors can invoke each other's methods concurrently. In single-core systems, the OO model can be mapped to classes and synchronous invocation, but this approach does not work for multi-core and distributed systems because of the limitations of the stack based call-and-return mechanism. Applications using synchronous invocation are doomed to spend the rest of their life executing in a single thread or suffer huge upheaval on each platform change as the code is modified to break the application into chunks appropriate for that platform.

Blueprint provides an alternative to a regular class, called a "circuit". Circuits have many of the desirable properties of classes that allow code to be encapsulated and re-used but they are self-propelled rather than relying on thread(s) to drive their execution and they use connections instead of calling to invoke each other's operations. This means that complex applications can be built from composing any number of circuit instances, as required, and the computation will be automatically distributed across the available hardware with an even load-balance.

For More Information

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.