|
In such scenario (one writer, multiple readers), you can avoid using critical section using guards 'around' your variable. Suppose you use two integers, m_iSeqId1 and m_iSeqId2 (both initialized to 0). Your writer thread will first increase m_iSeqId1, then update the new value, then increase m_iSeqId2 (so that it becomes equal to m_iSeqId1). Your reader threads first read m_iSeqId2 (yes m_iSeqId2 and not m_iSeqId1), read the value and then read m_iSeqId1. If both sequence Ids are the same, the value can be read and is not corrupted. If the Ids are different, the read should repeat the full operation until both Ids are the same.
But, this is only usefull when you are working with variables that cannot be set in one single instruction (e.g. an array, a string, an object, ...). Assignements of simple types (like int, char, ...) are atomic.
|
|
|
|
|
singh_nav wrote: Now my question is how to use the synchronization technique so that 9 threads should not wait if no writing is taking place.
Reader Writer Lock[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Can you please explain what you mean exactly by "pop_up interface" ?
|
|
|
|
|
do you mean a pop up window/menu?
Some things seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
Hi,
I used CreateFileMapping() to map a file. Will this work with drive handle to map a drive? I tried but not wotking.
|
|
|
|
|
Hi,
I m trying to load a resource dll to my application but its failing with error code 126(which says dll not found).
I have also checked the path manually as well as using CFileFind (and it shows that dll is there).
One more thing i have also checked the same code with normal dll(i.e. which has some code) and it works absolutely fine.
Does anyone has any idea or hint about this?
Is it related to trusted dll?
Thanks in Advance!
Tony
|
|
|
|
|
It might help if you showed some code and said where the file is located.
|
|
|
|
|
CString strPath = "C:\\Test\\SampleResource.dll";
CFileFind Ff;
bool bIsFilePresent = Ff.FindFile(strPath); // It returns true
HINSTANCE hTest = LoadLibrary(strPath); // It returns NULL
DWORD dwError = GetLastError();// It returns 126
I hope this piece of code is understandable.
Thanks.
|
|
|
|
|
The problem is most likely that the DLLMain() function in the DLL is returning FALSE.
When you build the resource DLL, set the "Entry Point" property to None - Resource DLL.
That ought to fix it.
The "Entry Point" property is on the "Linker" tab.
|
|
|
|
|
Entry point has been very correctly set and in fact it is working fine with WinXP and Win Vista. But same code is failing with Windows 7.
Any idea about it?
|
|
|
|
|
i want to display icon or bitmap on popup menu, as
ICON/BITMAP-->SOme text like this.
also i want to show tooltip when cursur is moved over popup menu.
thank you vm in advance
|
|
|
|
|
Did you look at Menus[^] section of CP.
Also CP has very good articles for tool tips.
I hope it helps.
Regards,
Sandip.
|
|
|
|
|
|
Hi all,
What is the use of declaring a private destructor?
Where we are using this? Can anybody tell an example
Thanks
San
|
|
|
|
|
The purpose of the private destructor is to avoid the deletion of the object while it is still referenced
Some things seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Could please send me some sample code
|
|
|
|
|
and other use could be if you want to stop the creation of the object on stack. Yes, you can not delete these object by using delete. Either you have to assume that you don't want to delete such objects or you have to overload the delete or delete these from any friend function.
class Test
{
public:
Test(){}
private:
~Test(){}
};
int _tmain(int argc, _TCHAR* argv[])
{
//Test tmp; // Compilation error;
Test *testP = new Test(); // work fine
return 0;
}
Manish Agarwal
manish.k.agarwal @ gmail DOT com
|
|
|
|
|
Test *testP = new Test();
what about delete?
|
|
|
|
|
for delete we have to create a friend function or we have to assume that we don't want to delete this
Manish Agarwal
manish.k.agarwal @ gmail DOT com
|
|
|
|
|
HI Manish,
How to write Friend Function to call Delete on Private Destructor.
Thanks,
Krishna.
|
|
|
|
|
here is a minimal example
class A
{
private:
~A(){};
public:
A(){};
friend void fn();
};
void fn()
{
A a;
}
In this case if you create a object of class A on stack in any other function other than fn() complier will give you an error C2248: 'A::~A ' : cannot access private member declared in class 'A '
Manish Agarwal
manish.k.agarwal @ gmail DOT com
|
|
|
|
|
Hi,
i am currently develop the CSP for Windows Vista platform.
i find out from internet that i need to replace advapi32.dll file in the system32. i already changed it and managed to replace the dll.
but, i still get an error when i run in the cmd prompt:
c:\windows\system32\regsvr32 mimoscsp.dll
the error that i got was :
the module "mimoscsp.dll" was loaded but the call to DllRegisterServer failed with error code 0x8009006
when i try to run the test program, i got an error at the function:
CryptAcquireContext returned error-57
anyone knows about it?
thanks
|
|
|
|
|
Error code 0x80090006 means "Invalid Signature"
Did you forget to sign the dll?
Test Signing the CSP[^]
Best Wishes,
-David Delaune
|
|
|
|