473,503 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to limit access to common objects shared among multiple threads

Lets say I have two threads which "communicate" via a shared object (passed
to them as a reference when they are created). The shared object is primarily
composed of getters and setters. In quite a few instances the two threads need
access to both types of methods. However, in some only one of the threads
should access the setter method. Eg, the control thread should be the only one
able to call the method set_LimitSwitchStautus(true); it makes no sense (nor
would it be desirable) for the GUI thread to do so. The basic structure of
the program is something like:

class Limits {
bool fLimit;
bool get_Limit() const;
void set_Limit(bool);
}

class Common {
Limits Limit;
plus a whole bunch more such contained objects
}

main {
Common blotz;
CntrlThread tCntrl(blotz);
GuiThread tGui(blotz);

tCntrl.start(); << I am using ZThreads
tGui.start();
}

where I'd like code to fail to compile (or at least do nothing) if the
GUI thread were to call set_Limit.

TIA

Ken
Jul 19 '05 #1
1 2211

"K Gibbs" <gi***@egret.sao.arizona.edu> wrote in message
news:32**************************@posting.google.c om...
Lets say I have two threads which "communicate" via a shared object (passed to them as a reference when they are created). The shared object is primarily composed of getters and setters. In quite a few instances the two threads need access to both types of methods. However, in some only one of the threads
should access the setter method. Eg, the control thread should be the only one able to call the method set_LimitSwitchStautus(true); it makes no sense (nor would it be desirable) for the GUI thread to do so. The basic structure of the program is something like:

class Limits {
bool fLimit;
bool get_Limit() const;
void set_Limit(bool);
}

class Common {
Limits Limit;
plus a whole bunch more such contained objects
}

main {
Common blotz;
CntrlThread tCntrl(blotz);
GuiThread tGui(blotz);

tCntrl.start(); << I am using ZThreads
tGui.start();
}

where I'd like code to fail to compile (or at least do nothing) if the
GUI thread were to call set_Limit.


It does fail. set_Limit is private and cannot be accessed.
--
MiniDisc_2k2
To reply, replace nospam.com with cox dot net.
Jul 19 '05 #2

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

Similar topics

6
2282
by: Garma | last post by:
According to what I have learnt so far, instantiating global objects should be the last resort. Is there any reasons why so? Sometimes some objects or their pointers have to be shared among...
6
4712
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
49
14282
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
9
4146
by: Clint | last post by:
Hey all - Excuse the cross-post ... I'm not sure what the appropriate newsgroup would be for this question. I have a question that I'm not quite sure how to ask. For all I know, I have the...
2
1177
by: cFleury | last post by:
The forms in my application are retaining the values objects have (text box, datagrid, public vars, etc…) among different computers in the network, for example if you as result of entering a...
5
1551
by: Ron Mexico | last post by:
I have written a graphing engine (very similar to what BigCharts.com offers). Basically, it's an ASPX page that accepts parameters and calls back-end business objects (dlls) to create a graph. ...
18
4542
by: jess.austin | last post by:
hi, This seems like a difficult question to answer through testing, so I'm hoping that someone will just know... Suppose I have the following generator, g: def f() i = 0 while True: yield...
16
4380
by: google | last post by:
Hello, I am working on an Acc2003 app for my company. In the interest of reducing chances of corruption due to unstable network connectivity, I would like to either prevent users from running it...
167
8156
by: darren | last post by:
Hi I have to write a multi-threaded program. I decided to take an OO approach to it. I had the idea to wrap up all of the thread functions in a mix-in class called Threadable. Then when an...
0
7074
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7273
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6982
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5572
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4667
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3161
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
374
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.