Solved

parallel programming concept

Posted on 2002-05-07
4
161 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
Comment Utility
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
Comment Utility
0
 
LVL 22

Accepted Solution

by:
ambience earned 33 total points
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now