win32 waitnotify library & requirement of dummy var ?

catrino catrino at cbs.cnrs.fr
Tue Dec 19 04:16:45 PST 2006


Thank you for your waitnotify library. I was looking for something like this. I
have implemented something myself but your implementation is better. I believe
these wait(), notify() functionalities should be part of the Object class, which
means to recompile phobos. The problem is that it is not possible to add members
to the Object class. I've tried that and the compiler fails on an assertion on the
Object size.

For your SIGSEGV problem, I believe that it is due to the public/private
implementation. In your waitnotifyImpl.d you added an int member to the
WaitNotifyObject. It means that the size of a WaitNotifyObject will be the size of
Object + the size of an int. In your public waitnotify.d, if you don't add a
member the WaitNotifyObject will appear to have the same size of a basic Object
but it is bigger in fact. I believe the hidden int member gets altered by other
objects in memory, the place where it lies looks available. I had similar problems
when I was playing with phobos (adding members to classes and recompiling).

Another thing that is important when using public/private implementation is to
always keep the methods in the same order. This is because the D compiler stores
the methods in the virtual function table in the order they appear in the source
file. For example if you have a public file like this :
class A {
   void fun();
   void afun();
}
and a private file like this
class A {
   void afun() { ... }
   void fun() { ... }
}
then when you will call A.fun() from a program importing your public d file and
linked with your already compiled private implementation you will have A.afun()
called instead. The same happens when you try to call A.afun(), you call A.fun()
instead.
I had this problem too.

I hope you could read my poor english and that I could help you.

Vincent



More information about the Digitalmars-d mailing list