|
Hi.
By using a simple mutex, access and update can be synchonised very easily.
When the list needs to be updated, the mutex is 'set', the update is performed, this excludes all access's, the update is complete and the mutex is 'released'.
Since the majority of the operations, as per the 'poster' are accesses, waiting for the mutex is infrequent.
Since for the majority of the time, the mutex is 'released' the wait for reads' is satisfied 'immediately'
James.
|
|
|
|
|
I'm still not getting you. AFAIK the only way to set a Win32 mutex is by waiting on it; releasing is done via ReleaseMutex . So your proposal is that the update function properly waits for the mutex and releases it after updating is completed, right? So, what should the access (i.e. read-only) function do?- if the access function also waits for the object, then there cannot be more than one thread either updating or reading at a time, exactly the same way as it happens with using a
CRITICAL_SECTION . - if the access function does not wait for the mutex, the list is not thread safe, as when the update method enters there could be other threads performing read-only acess at that time, and corruption of the data structure can hence ensue.
Maybe I am not getting your proposal right
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi.
Sorry, I assumed that there were multiple threads waiting on 'access and/or update', otherwise the question is void.
There can be as many threads waiting on the mutex as there is.
The idea is that only an update 'locks' the mutex, 'reads', 'fall through'. Otherwise we might be talking about a DOS program.
James.
|
|
|
|
|
Given:
Write the following code and discuss what exactly results.
1. enum logical { no, maybe, yes };
2. logical operator ! (logical x);
-------
So this gives me a set called logical. An I can define a variable like
logical x(no);
Item 2 is a template that takes x and returns NOT X. It is my opinion the template is meaningless. Not FALSE is TRUE, but NOT MAYBE is NO and NOT YES is also NO. Not NO is undefined.
Anyway, how can I use this template?
x = !(x);
Will just yeild a linker error? How do I define a usage of item #2?
|
|
|
|
|
Have you implemented the operator?
logical operator ! (logical x)
{
...
return ... ;
}
If not, you will have of course a linker error!
Hardy
|
|
|
|
|
First: an enum autoconverts in int , !1 is 0 and !0 is 1, hence - to avoid confusion, it is better use
{ no, yes, maybe } (maybe = 2)
now, if x is yes or no, already works.
The problem is !maybe = no (by definitionm in C++).
If this is unacceptable,
do an operator like
logical operator!(logical a)
{
return (a==maybe)? maybe: (logical)!(int)a;
}
please note the casts! (or you go in an infinite recursion !)
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Thank you both. I was not casting properly.
My work product follows for anyone concerned.
//In C or C++ the following is true
//1. !0 is true and 0 is false
//2. !1 is false and 1 is true
//3. !Any number other than 0 is false and !0 is always true
enum logical { no, maybe, yes };
// no = 0 and !no is true
// maybe = 1 and !maybe is false
// yes = 2 and !yes is the same as !maybe
logical operator ! (logical x)
{
x = (logical)!(int)x;
return x;
}
logical operator &&(logical a, logical b)
{
logical x = no;
if(a &&(int) b)
{
x = yes;
}
return x;
}
void CTestinistuffDlg::OnCancel()
{
logical x(no);
logical a(maybe), b(yes);
//the Not operator
x = operator!(no); //returns maybe
x = operator!(maybe); //returns no
x = operator!(yes); //returns no
x = operator&&(no,no); //returns no
x = operator&&(no,maybe); //returns no
x = operator&&(no,yes); //returns no
x = operator&&(maybe,maybe); //returns yes
x = operator&&(maybe,no); //returns no
x = operator&&(maybe,yes); //returns yes
x = operator&&(yes,yes); //returns yes
x = operator&&(yes,no); //returns no
x = operator&&(yes,maybe); //returns yes
}
|
|
|
|
|
Hi,
I'm having some troubles with my MFC multi document application. When I create a new document, I would like it to fill the hole frame area. Is that possible, and how do I do it ?
With regards
jens Christiansen
|
|
|
|
|
Hi all,
I've created an ActiveX control using Visual C++ .NET.
When I add this control to a container created with Visual C++ .NET (or a Visual C++ 6.0) everything works and there is no apparently problem. But now, I'm trying to test this ActiveX with an application created with Visual Basic 6.0. The problem is that the ActiveX control does not appear in the list of registered components from the Visual Basic 6.0 (Menu -> Project -> Components, or Ctrl+T). So, I can't add my ActiveX to the Visual Basic 6.0 container.
When I try to make the same operation with a Visual Basic .NET container, I find the same situation, this is, the ActiveX control is not in the registered components list. But the ActiveX control is already registered.
I use the OleView application in order to ensure that the control is registered.
Due to my ActiveX control perfectly works with a Visual C++ .NET (and a Visual C++ 6.0) container, I suppose there is any bad chosen compiler option (by the time, everything is by default). Does anybody experimented the same situation testing his/her ActiveX in a Visual Basic container?
Thanks in advance.
|
|
|
|
|
I need to draw a chart (in 2D) and I'm programming in Visual C++ (.NET version 2003). I can´t use the controls in: http://www.codeproject.com/miscctrl/#Charting+Controls
because I'm not using MFC.
I've read that there is an ActiveX control called Microsoft chart Control but I don´t know how to use an ActiveX control in visual c++.
Please help me!!!
|
|
|
|
|
I've recently been tasked to write a number of C++ class that can be, with minimal effort, used with any of the Win32 C++ Compilers.
I have a question regarding raising events in the classes that I write. I'm curious to know how I would declare these events and assign handlers. My first guess would be function pointers, but I would like to know where there is a best practice way of doing this.
Also, if I use or develop an MFC specific class, do I have to register or assign event handlers through the Message Mapping macros?
Any tips or additional resources would be greatly appreciated.
Thanks in advance
|
|
|
|
|
may be this[^] can help ?!?
ooppss ... CP moved the article!
new location[^]
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Great. This will help quite a lot. Thanks!
|
|
|
|
|
Most of us know a lot of games,Especially Like Red Alert 2 or any Command & Conquer Game,There are also
Games where the Player Have Guns and armor,There are some programs called "Trainers" That Can access the
memory of the game and modify the value of the Money,Armor,etc....
This "Trainer" knows the adress of the variable and knows its length (2-4-8-...)bytes so it can modify it.
Now,My question is -----> how do they do that ?
I'm Sure C++ Can do that.
In short,I want an Example of Two programs(Source Code C++) In the First there is a variable which I want to make the second program able to modify at runtime and check if the first program was running before trying to modify that variable.
|
|
|
|
|
|
Hello to all
I want to know if what is c++? I have an experience regarding programming but I am only using mini-compiler like debug command from MS-Dos Prompt. I am creating com,bat files.
Dark Angel
|
|
|
|
|
Debug Master wrote:
I want to know if what is c++?
Why not go straight to the source?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Is it possible to use MFC in an Add-In for Visual Studio .NET 2003 after one has chosen C++/ATL as the language to write the Add-In in? I have tried using MFC but I always get an error about have the Main function being defined twice.
Does anybody know of a solution?
I am the handsome one in the crowd.
|
|
|
|
|
As much as I love C++ it just isn't the right language to try to write add-ins with. Use C# or some other .NET language with managed C++ extensions if you have to.
During my first experiment with add-ins I learnt enough C# to be able to build a fairly reasonable build logger, with a lot less code than an equivalent C++ project, mainly because of all the interfaces that have to be implemented.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts your aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Here is my problem
The program should simply read the webpage that the user is looking at and grab the 'Title', the 'keywords' meta tags and the URL of the page being looked at.
Here is an example:
1a user visits http://www.insure.com/
2.The software grabs the title, keywords and URL.
3.The software makes a list of the keywords and phrases found.
4. an add to file
please some one help i requiredit immediately
-----------------------------
"I Think It will Work"
Formerly Known As "Alok The Programmer" at CP
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hello,
You should try this[^] article. It should fit your needs.
Besides that, try googling first next time...
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
thanks for reply,but that is not what i need,let me explain it to u.
Let you open any webbrowser and type a url for serach and from there i have to gather the title or url or meta tag thanks
-----------------------------
"I Think It will Work"
Formerly Known As "Alok The Programmer" at CP
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hello,
I think that you want something like an add-in. I don't know how to help you on the add-in part, but I know that you can do almost anything you want from there...
Good luck!
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
What you are after is IE Automation. I have dozens of little VBS files on my computer that do various things with Web sites. Some I have even added as a scheduled task if I want to do them regularly. For example, here is one that gets the current security threat level. It's not finished (I was just testing az theory), nor is it as "pretty" as the XML version that is floating around.
Dim objIE
Set objIE = WScript.CreateObject("InternetExplorer.Application")
objIE.Navigate "http://www.whitehouse.gov/homeland/"
objIE.Visible = true
While objIE.Busy = true
Wend
Dim objTables
Set objTables = objIE.Document.all.tags("TABLE")
Dim objTable
Set objTable = objTables(12) ' get the 13th <TABLE> tag
Dim objRow
Set objRow = objTable.rows(0) ' get the 1st <TR> tag
Dim objCol
Set objCol = objRow.cells(0) ' get the 1st <TD> tag
Dim objImg
Set objImg = objCol.all(0) ' get the 1st <IMG> tag
MsgBox objImg.src Here's one I made for a friend a few years back to help him enter a sweepstakes contest:
Dim IE
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "http://www.nralive.com/sweeps/enter.cfm", NULL, NULL, NULL, NULL
' wait until the page is fully loaded
While IE.Busy = true
Wend
' assuming there are 4 radio buttons named "enteringBy", operate on the 4th (index 3) one
IE.Document.all("enteringBy", 3).checked = true
IE.Document.all.fname.Value = "J"
IE.Document.all.lname.Value = "S"
IE.Document.all.email.Value = "j"
IE.Document.all.address.Value = "2"
IE.Document.all.city.Value = "S"
IE.Document.all.state.Value = "O"
IE.Document.all.zip.Value = "7"
IE.Document.all.phone.Value = "4"
' click the "next" button
IE.Document.all.tags("INPUT").item(12).click()
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi,
I'd like to know what is GNU C++ and which compilers doing this?
I really don't know what is this?
Regards,
-
When in doubt, push a pawn!
-
|
|
|
|