Thread overview | |||||
---|---|---|---|---|---|
|
April 07, 2005 Reentrant Lock | ||||
---|---|---|---|---|
| ||||
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?
|
April 07, 2005 Re: Reentrant Lock | ||||
---|---|---|---|---|
| ||||
Posted in reply to Larry Cowan | > ------------------------------
> prints:
>>begin @ 42
>>A
>>Error: Access Violation
> ------------------------------
>
> What am I doing wrong?
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.
-Ben
|
April 07, 2005 Re: Reentrant Lock | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | Thanks. -larry In article <d33in9$2d6o$1@digitaldaemon.com>, Ben Hinkle says... > >> ------------------------------ >> prints: >>>begin @ 42 >>>A >>>Error: Access Violation >> ------------------------------ >> >> What am I doing wrong? > >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. > >-Ben > > |
Copyright © 1999-2021 by the D Language Foundation