www.digitalmars.com         C & C++   DMDScript  

D - synchronized functions bug

reply "Pavel Minayev" <evilone omen.ru> writes:
It seems that synched functions always return 0. Try this:

    import stdio;

    class Synched
    {
     synchronized int synched() { return 666; }
    }

    int main()
    {
     Synched synched = new Synched;
     printf("%d\n", synched.synched());
     return 0;
    }

Took me about an hour to figure out why the hell the newly
allocated object suddenly turns to be null... =)

A pity this doesn't work yet: I wanted to make stream.d
(and my new socket.d, socket streams) at least partially
thread-safe, but no luck.
Jan 06 2002
parent "Walter" <walter digitalmars.com> writes:
Ok, I'll have a look. -Walter

"Pavel Minayev" <evilone omen.ru> wrote in message
news:a1a5ga$2r3a$1 digitaldaemon.com...
 It seems that synched functions always return 0. Try this:

     import stdio;

     class Synched
     {
      synchronized int synched() { return 666; }
     }

     int main()
     {
      Synched synched = new Synched;
      printf("%d\n", synched.synched());
      return 0;
     }

 Took me about an hour to figure out why the hell the newly
 allocated object suddenly turns to be null... =)

 A pity this doesn't work yet: I wanted to make stream.d
 (and my new socket.d, socket streams) at least partially
 thread-safe, but no luck.
Jan 06 2002