Solved

parallel programming concept

Posted on 2002-05-07
4
168 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

691 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