?
Solved

parallel programming concept

Posted on 2002-05-07
4
Medium Priority
?
170 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 132 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…
Suggested Courses

650 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