473,320 Members | 1,821 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,320 software developers and data experts.

Accessing a thread's object

I'm using boost::threads and trying to access the members of the
functor that I start the thread on and can't find information on how to
do it anywhere.

It took me a while to even figure out what was going on but eventually
I determined that creating a new thread actually just COPIES your
functor object. Therefore changing the object's member values from
within the thread has NO effect whatsoever on the object you used to
initiate the thread.

Basically what I'm doing is I create object A. Object A has the ()
operator that boost threads automatically start runnning.

I tell boost I want to start A on it's own thread.

A does some stuff (in this case 'A' is a thread dedicated to serving a
client and my program creates a new A for every client that connects so
that it can cater to everyone at once).

The problem is, if I then call A.getWhatever() it returns null because
everything that has been changed, to my absolute delight, has been
changed on the boost::thread's copy of A and completely ignored the one
I passed into the thread() function.

Basically all I want to know is if there is any way to just access the
thread's local copy of the object. If not it looks like my only other
option is to pass in a pointer to another object that will hold all of
the state data which will mean rewriting a HUGE amount of code :(

Let me know if I've left anything out. I can barely comprehend most of
the stuff I'm doing in this program myself lol.

Aug 8 '06 #1
1 1279
Ryan wrote:
I'm using boost::threads and trying to access the members of the
functor that I start the thread on and can't find information on how
to do it anywhere.

[..]
You probably want to pass the address of the thread object to the
function you're using as the thread function. Unfortunately, boost
libraries are not really on topic here. Besides, don't they have
their own online forums?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 8 '06 #2

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

Similar topics

3
by: Alex | last post by:
I'm having a problem porting an ASP solution to ASPX. In the ASP solution I'm accessing a DCOM server, create sub DCOM objects and call functions from VB script on the ASP pages. The DCOM object...
2
by: Brian Mitchell | last post by:
I am sure this is pretty basic but I have never worked with ResetEvents before, but how do I signal a ManualResetEvent of a module that is spun off into several threads? For instance, if I have 5...
2
by: John | last post by:
Is there a safe way to gain access to the session object from inside a spawned thread, in ASP.NET? I'm familiar with the principle of creating a data storage object, passing a reference to the...
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
4
by: Tim | last post by:
An object 'X' is created inside a thread by object 'A'. The functionality of object 'X' is used only inside that thread. Inside the thread procedure, the object 'X's methods are called. That object...
3
by: Arv Carsen | last post by:
Im a beginner with C#, but as I try to access a textbox from a thread I get the error message : "An unhandled exception of type 'System.InvalidOperationException' occurred in...
1
by: Peter | last post by:
Hi, I have a Dictionary<key, valuewhich is accessed by three threads. One thread puts my value objects in the dictionary (occasionally), and also updates the contents of existing value objects -...
5
by: Mythran | last post by:
I've read some documentation about accessing objects created in other threads and the code below is similar to what I've gathered for what I have to do: private delegate void...
0
by: Roger Stoller | last post by:
Hello. I have developed a COM object using ATL. It seems to work fine when accessing it from VB.NET most of the time. However, I want to use a delegate in VB to asynchronously run a method in...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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.