digitalmars.D.learn - Reentrant Lock
- Larry Cowan (39/42) Apr 07 2005 module tester;
- Ben Hinkle (6/13) Apr 07 2005 Looks like a the locks.lib is corrupt. When I rebuild locks.lib without ...
- Larry Cowan (3/17) Apr 07 2005 Thanks.
module tester; import std.c.stdio; import locks.reentrantlock; class LockedIndex { private ReentrantLock rlock; private uint index; this(int begin) { rlock = new ReentrantLock; index = begin; } int current() { return index; } int getIx() { int retn; printf("A\n"); rlock.lock(); // block until lock is available printf("B\n"); retn = index++; if (retn >= 256*256) retn = -1; rlock.unlock(); // release the lock return retn; } } LockedIndex ixLock; int main( char[][] args ) { ixLock = new LockedIndex(42); printf("begin %d\n",ixLock.current()); for (int i=0; i < 10 ;i++) printf("%d: %d\n",i,ixLock.getIx()); printf("Done.\n"); return 0; } ------------------------------ prints:begin 42 A Error: Access Violation------------------------------ What am I doing wrong?
Apr 07 2005
------------------------------ prints:Looks like a the locks.lib is corrupt. When I rebuild locks.lib without -O passed to the compiler everything works fine. That would explain why my unittests passed when I last updated it. I have updated the zip file with a locks.lib built without -O and I'll try to narrow down the problem to post to D.bugs for Walter to ponder. -Benbegin 42 A Error: Access Violation------------------------------ What am I doing wrong?
Apr 07 2005
Thanks. -larry In article <d33in9$2d6o$1 digitaldaemon.com>, Ben Hinkle says...------------------------------ prints:Looks like a the locks.lib is corrupt. When I rebuild locks.lib without -O passed to the compiler everything works fine. That would explain why my unittests passed when I last updated it. I have updated the zip file with a locks.lib built without -O and I'll try to narrow down the problem to post to D.bugs for Walter to ponder. -Benbegin 42 A Error: Access Violation------------------------------ What am I doing wrong?
Apr 07 2005