473,325 Members | 2,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Sharing of objects across threads ?

Trying to write an application in linux where two threads share the
same object ( primarily a double linked list ) . How do i implement
such an object ? Or is there a better way to do this ?

Thanks

Nov 22 '05 #1
3 2940
vivekian wrote:
Trying to write an application in linux where two threads share the
same object ( primarily a double linked list ) . How do i implement
such an object ? Or is there a better way to do this ?


This is not really a question for this group since threads are off topic
here.

However, if your target system had a shared memory model (most machines)
then it's simply a case of making sure that you don't have both threads
calling methods on the list at the same time (including traversal,
object deletion etc).
Nov 22 '05 #2
vivekian wrote:
Trying to write an application in linux where two threads share the
same object ( primarily a double linked list ) . How do i implement
such an object ? Or is there a better way to do this ?


In plain computer science terms you have two choices, build
serialization (locking) into the list manipulators. (insert, delete,
update, traversal) Or use an external lock to control any/all access to
the list.

In real-world terms on Linux it is probably easiest to go the secound
route with std::list and pthreads. Why re-invent the wheel when such
nice, usable wheels are already available? ;-)

Nov 22 '05 #3
vivekian wrote:
Trying to write an application in linux where two threads share the
same object ( primarily a double linked list ) . How do i implement
such an object ? Or is there a better way to do this ?

Thanks


Consider using a synchronized smart pointer like that in the following
link:
http://code.axter.com/sync_ptr.h
http://code.axter.com/sync_ctrl.h

By wrapping your object in the synchronized smart pointer you make your
object synchronize automatically.

Nov 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Alex | last post by:
Hi all, I want to write a "File sharing system". Is posssible with socket and thread create multisuer connection at the same time ? or is wrong my idea?? thanks
0
by: Nadav | last post by:
Hi, I could not find any info about this. I am writing a C application that embeds Python. The application starts several python threads, each one in its own sub-interpreter. Is it...
1
by: Dennis Gavrilov | last post by:
Hi, All! I have two questions: strategic and technical. Technical one first: I need to share an array of objects (implemented as hashes, having references to other objects and hashes, sharing...
2
by: Evan | last post by:
Hi, What is the best method to share objects (such as a SqlConnection) across many forms. I am currently passing the SqlConnection in to other forms from the main form through the other forms'...
0
by: Nashat Wanly | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaskdr/html/askgui06032003.asp Don't Lock Type Objects! Why Lock(typeof(ClassName)) or SyncLock GetType(ClassName) Is Bad Rico...
2
by: Mel | last post by:
This may be a stupid question, but here goes... I have created a NameValueCollection in my website's application state. If, during a page request, I add a string key and string value to the...
4
by: Martin Ehrlich | last post by:
Hello NG. I've got a little problem with sharing types between webservices and clients. I've created a business class with public fields within a shared assembly like: public class Item {
6
by: Rajesh | last post by:
Hi, We are tyring to build a DLL which will write the log data to a text file. Multiple executables should use this dll to write data to same text file. We are using a synchronized method...
45
by: =?Utf-8?B?QmV0aA==?= | last post by:
Hello. I'm trying to find another way to share an instance of an object with other classes. I started by passing the instance to the other class's constructor, like this: Friend Class...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.