|
Brian R wrote:
it is an artifact of bad design
It is a tool that makes it easier to use and then dispose of one time objects without having to keep track of the pointers and memory yourself. Using it is a design decision, not "bad design". Abusing it is bad design, but then abusing anything is.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
PJ Arends wrote:
Using it is a design decision, not "bad design". Abusing it is bad design, but then abusing anything is
I am in 100% agreement with you. Even the infamous 'goto' is cursed as a bad design paradigm. But circumstances govern their use in a few specialized cases. After all 'delete this' has certainly come to my rescue when I had to monitor the lifetime of an object using a reference counter similar to the COM classes. I seem a fair use of 'delete this' in such case. Also there are so many things in C++ that if abused screw up the program, better curse programming skill than curse a language
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
Mayur Mahajan wrote:
But circumstances govern their use in a few specialized cases.
A paper put together in 1966 by BÖhm, Corrado, and Guiseppe proved theoretically that the GOTO statement was unnecessary; Dijkstra considered it harmful; and Knuth said it might be useful in some circumstances.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Well, the main point here is:
We have razor sharp tools in the kit. If you can handle them, use it...else they'll hurt you bad
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
thanks all I now have a better understanding of this topic.
|
|
|
|
|
You can use it in exception classes, which may be created on the stack or dynamically on the heap. When you call some Delete function, you can delete this if the object is created on the heap.
I also got the blogging virus..[^]
|
|
|
|
|
Hi
Can somebody please guide me how to wite an ISR in visual c++ 6.0. I need to handle some interrupts
Thanks
Leelanga
|
|
|
|
|
To my knowledge, ISRs haven't been used since DOS and 16-bit Windows. What exactly is it that you are trying to do?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I don't think that windows is polling for mouse, keyboard or any other hardware events...
But if you mean that the programmer has to use ISR's, you can't. I don't know since what OS version, but at least since Win2K those instuctions are "priviliged", meaning that they can only be executed in supervisor mode. Thats where device drivers come in.
I also got the blogging virus..[^]
|
|
|
|
|
Having never delved into a device driver project before, this is unfamilar territory for me. Thanks for the heads-up.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
You're welcome!
To be honest, I didn't work on a device driver project either, but I've worked on small embedded systems. Also I had a subject in college recently that focused on hardware and Windows.
I also got the blogging virus..[^]
|
|
|
|
|
Actualy I've developed a small h/w device to control telephone line. I use the paralell port to interface the device. So i need to hadle interrupts generated by it
Thanks a lot
Leelanga
|
|
|
|
|
|
Hi,
I need to get the absolute path for the given virtual folder path.
Consider an example given below. Windows has a virtual folder "My Documents" placed in Desktop.
So by using the path "C:\Documents and Settings\Administrator\Desktop\My Documents" can we get the Absolute ( Physical) path for the "My Documents"?
In my case the physical path for the "My Documents" is "C:\Documents and Settings\Administrator\My Documents".
Please send me the answer as soon as possible.
Thanks in Advance
vaidya
|
|
|
|
|
Check out the help on SHGetSpecialFolderPath() and SHGetFolderPath(); I've not used these in a while, but they fit the bill.
: Dean Michaud
|
|
|
|
|
For SHGetSpecialFolderPath() we need to give the CSIDL constants. I will not come to know which folder it is. We can even rename the My documents special folder in the desktop. So there is no way of knowing it is my documents or something else.
Regarding the SHGetFolderPath(), it wont accept the virtual folder. It works only for the real folder.
|
|
|
|
|
I get a strange error when I try to create a second dialog window from my main dialog. I do a simple new MyDialogClass (which inherits from the Window's dialog class) and call the create function with the resource ID number. I get a window which only exists inside my original app's window. I can move it inside my app window. Did I forget to set a resource property?
|
|
|
|
|
May be you somewere set WS_CHILD flag either in resources or explicitly?
|
|
|
|
|
If I have 15 UI threads where each of them depends of each other. (If one hang other will hang). What could be efficient way to find which hang first.
Thanks.
Alex
|
|
|
|
|
Are you calling locks in your code?
If so, are you calling the locks to synchronize access to a shared resource?
If so, consider using the following wrapper class that can automate the locking for you in a thread safe object orientated manner.
http://code.axter.com/ThreadSafeObject.h
Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Cplusplus
|
|
|
|
|
There is only one question how to find which thread hang first. Bad solution is to monitor threads with high frequancy just call WaitForSingleObject or PostMessage to thread and get reply. Solution is bad because inefficient and inaccurate. There is very high possibilty that you detect second hanged thread instead of first (initiator of hang). So if you increase frequancy and make time out (in waitforsingleobject) shorter you basicly wasting CPU on detection. Imagine if number of threads grow to 100.
|
|
|
|
|
I don't know what you are doing with 15 UI threads, that ask for a deadlock??? Consider using worker threads and polling using a timer.
But if you really need that, you can always consider using a map, where a thread 'registers' itself before asking for a lock and 'removing' itself when the lock is aquired or released. You can use the value returned by the GetTickCount function as the key.
I also got the blogging virus..[^]
|
|
|
|
|
I mean lock when thread hang for some unimportant reason. Keep in mind that if thread(UI thread) hang you are not be able to continue recieving WM_TIMER.
I just need to know which of the thread in chain of the threads hanged first.
Example
A thread -> connected to B -> to C -> to D
If D hangs C hangs, than B than A
Plus you don't know how intensive those thread has been consuming CPU. What I mean you can't rely that A strarted first and D hanged last that's means that CPU time for A > B.
Thanks.
Alex
|
|
|
|
|
A thread doesn't 'hang' for some unimportant reason! Either you requested a lock that one thread didn't release for some reason (maybe deadlock), or you made a little error and one thread got stuck in a infinite loop consuming all CPU time.
I can't think about an other reason why a thread could 'hang'..
If a thread is 'hanging' because it is waiting for a lock, you know where the thread is going to hang. If you just log some messages when a thread is going to request a lock and when a thread is releasing the lock, than you know which thread hangs first. All you have to do is figure out a way so that the program also 'knows' which thread hangs first.
This isn't a concrete code solution, but since I don't know exactly what you are trying to achieve, I can't give you one.
I also got the blogging virus..[^]
|
|
|
|
|
You know what is funny part. This is not my thread this is third party component. For me is not important why something happend with component what I need to do. I need to detect which hang first and kill it. If kill inocent thread which part of the chain it will be bad. Thats why I need to know which thread is hang first. I have wrapper thread around component which communicates with componet. So if my wrapper hand I need to kill it. Problem is that other wrapper thread connected to each other. So since one componet hung all my wrapper thread hang. I have some solution which is not so elegant.
Create global map key: thread ID value cpu tick count.
Than put in the wrapper thread waitforsingleobject with timeout 1 s.
After waitforsingleobject call GetTickCount and save value in the map.
After some threads hang I will find IDs of hung threads and find which of them has minimal CPU count. Which means that tread was polled last. I need to play with timing. But that waht I have now.
Thanks a lot anyway.
Alex
|
|
|
|