Solved

parallel programming concept

Posted on 2002-05-07
4
165 Views
Last Modified: 2010-04-02
If I am gonna write a library, which has a base class...this base class will be inherited by many other classes in the main application. But only one thread will call object of this class, or the object which inherited this class...Do I need to add some thread synchronization mechanism to this  base class?
i.e.
a)FS_MyGenericClass is the generic class
b)FS_MyDerivedClass is the inherited class
But there will be many FS_MyDerivedClass running concurrently on their own threads

Also, please give me some URLs for materials about this kind of question as i am gonna write a thread-safe library, which has many generic classes.

0
Comment
Question by:martie
4 Comments
 
LVL 10

Expert Comment

by:makerp
ID: 6995935
it depends on what the generic classes do

you have to provide synchronization when your class accesses shared resources; for example if your base class accesses a file you may want to use synchronization to ensure only one thread writes at a time.

your question is very vauge you will need to provide some examples of exactly what you are doing

Paul
0
 
LVL 16

Expert Comment

by:AlexNek
ID: 6996363
0
 
LVL 22

Accepted Solution

by:
ambience earned 33 total points
ID: 6998099
In general if your base class has static data members, or uses globals, you may need to sync up things a bit.

>> a)FS_MyGenericClass is the generic class
b)FS_MyDerivedClass is the inherited class

For every other form of inheritance, each derived object will have its own copy of base class to work with and thus you do-not need any kind of synchronization, unless of course if theres something shared by all objects (globals and statics).

0
 
LVL 11

Expert Comment

by:griessh
ID: 7178642
Dear martie

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to split between  

     "ambience, ALexNek, makerp"

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points. The link to the Community Support area is: http://www.experts-exchange.com/commspt/


PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question