Recalculating a spreadsheet in multil-processor environment - design pattern?

C

Chris

I have a problem which is quite similar to the problem of
recalculating a spreadsheet.

I have a collection of cells (actually individual objects in my
problem). Some cells contain data, but many are formulas that must be
calculated, so they depend on other cells (which may contain data or
may require calculation themselves). A cell might depend on any number
of other cells, from 0 to all the other cells in the spreadsheet. The
user might accidentally create circular links, so I should detect that
situation.

The calculation time can be relatively long (seconds for some cells),
so I want to do the calculation in a background thread, leaving the UI
responsive. To take advantage of multiple processors, I want to use
multiple threads for the calculation.

A subset of the cells are currently visible, so I would prefer to
calculate that subset, and the cells they depend on, first.

The user can change the value of a cell (either the basic data, or a
formula) -- when they do, we need to restart the calculation. They
might do this in the middle of a previous calculation, at which point
I would like to start over.

I see a couple of ways to do this, but before I start digging into the
design details (and the code), I would like to ask if there are any
design patterns that would apply to this problem. Seems like other
people must have solved this before. If not design patterns, sample
code?, or even a discussion of the problem?

TIA,

Chris
 
A

Alf P. Steinbach

* Chris:
[off-topic]

AFAICS there's no C++ question.

Better ask in [comp.programming].

Where perhaps you'll be redirected to even more appropriate groups.
 
S

Satish

I have a problem which is quite similar to the problem of
recalculating a spreadsheet.

I have a collection of cells (actually individual objects in my
problem). Some cells contain data, but many are formulas that must be
calculated, so they depend on other cells (which may contain data or
may require calculation themselves). A cell might depend on any number
of other cells, from 0 to all the other cells in the spreadsheet. The
user might accidentally create circular links, so I should detect that
situation.

The calculation time can be relatively long (seconds for some cells),
so I want to do the calculation in a background thread, leaving the UI
responsive. To take advantage of multiple processors, I want to use
multiple threads for the calculation.

A subset of the cells are currently visible, so I would prefer to
calculate that subset, and the cells they depend on, first.

The user can change the value of a cell (either the basic data, or a
formula) -- when they do, we need to restart the calculation. They
might do this in the middle of a previous calculation, at which point
I would like to start over.

I see a couple of ways to do this, but before I start digging into the
design details (and the code), I would like to ask if there are any
design patterns that would apply to this problem. Seems like other
people must have solved this before. If not design patterns, sample
code?, or even a discussion of the problem?

TIA,

Chris

It depends on what technology you are using. If windows posting to
microsoft.public.vc.mfc will be helpful. As of design pattern I would
have used MVC so that controller can handle updates on the grid and
keep the refresh the related cells.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top