win32 waitnotify library & requirement of dummy var ?
Dan
ddaglas at gmail.com
Wed Dec 20 17:35:01 PST 2006
== Quote from catrino (catrino at cbs.cnrs.fr)'s article
> 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
Vincent,
I appreciate the advice. I will try a few things, like experimenting with
volatile, making sure methods are in the same order, etc.
Thanks.
Dan
More information about the Digitalmars-d
mailing list