* contrib/hbamf/tests/tstendin.prg
* contrib/hbblat/blatcls.prg
* contrib/hbct/tests/ctwtest.prg
* contrib/hbct/tests/token2.prg
* contrib/hbhttpd/readme.txt
* contrib/hbhttpd/widgets.prg
* contrib/hbmisc/fileread.prg
* contrib/hbmisc/hbedit.prg
* contrib/hbmysql/diff-en.txt
* contrib/hbmysql/diff-es.txt
* contrib/hbmysql/tests/dbf2mysq.prg
* contrib/hbmysql/tmysql.prg
* contrib/hbmysql/tsqlbrw.prg
* contrib/hbnetio/tests/netiot03.prg
* contrib/hbnetio/tests/netiotst.prg
* contrib/hbnf/doc/en/fttext.txt
* contrib/hbodbc/browodbc.prg
* contrib/hbodbc/tests/odbcdemo.prg
* contrib/hbodbc/todbc.prg
* contrib/hbtip/ftpcli.prg
* contrib/hbwin/tests/olesrv1.prg
* contrib/rddads/ads.ch
* contrib/rddsql/readme.txt
* contrib/sddodbc/tests/test2.prg
* contrib/xhb/dbf2txt.c
* contrib/xhb/hbcompat.ch
* contrib/xhb/hblog.prg
* contrib/xhb/html.ch
* contrib/xhb/tfile.prg
* contrib/xhb/tframe.prg
* contrib/xhb/ttable.prg
* ChangeLog
* doc/en/dbdelim.txt
* doc/en/dbsdf.txt
* doc/en/rdddb.txt
* doc/en/terminal.txt
* extras/gtwvw/tests/wvt2wvw.ch
* extras/httpsrv/cookie.prg
* extras/httpsrv/modules/tableservletdb.prg
* extras/rddado/adordd.ch
* extras/rddado/adordd.prg
* include/assert.ch
* include/hbsix.ch
* src/debug/dbgbrwsr.prg
* src/debug/dbgtinp.prg
* src/rdd/*.prg
* src/rtl/*.prg
* tests/*.prg
* tests/rddtest/rddtst.prg
* tests/usrrdd/exarr.prg
* tests/usrrdd/exfcm.prg
* utils/hbtest/hbtest.prg
* more minor
116 lines
2.1 KiB
Plaintext
116 lines
2.1 KiB
Plaintext
/*
|
|
* $Id$
|
|
*/
|
|
|
|
/*
|
|
* Harbour Project source code:
|
|
* demonstration/test code for file lock synchronization between
|
|
* aliased work areas
|
|
*
|
|
* Copyright 2008 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
|
* www - http://harbour-project.org
|
|
*
|
|
*/
|
|
|
|
proc main()
|
|
local cFile := "_tst"
|
|
|
|
if ! dbExists( cFile )
|
|
dbCreate( cFile, { { "F", "C", 10, 0 } } )
|
|
use _tst exclusive
|
|
while lastRec() < 100
|
|
dbAppend()
|
|
enddo
|
|
close
|
|
endif
|
|
? "Test exclusive access"
|
|
select 1
|
|
use _tst exclusive alias tst1
|
|
? "neterr->", netErr(), "used->", used(), "alias->", alias()
|
|
select 2
|
|
use _tst exclusive alias tst2
|
|
? "neterr->", netErr(), "used->", used(), "alias->", alias()
|
|
if used()
|
|
? "Error, exclusive mode in aliased work areas does not work"
|
|
else
|
|
? "OK"
|
|
endif
|
|
dbCloseAll()
|
|
wait
|
|
?
|
|
? "Test shared access"
|
|
select 1
|
|
use _tst shared alias tst1
|
|
? "neterr->", netErr(), "used->", used(), "alias->", alias()
|
|
setLock(2)
|
|
setLock(4)
|
|
setLock(6)
|
|
setLock(7)
|
|
dspLock()
|
|
select 2
|
|
use _tst shared alias tst2
|
|
? "neterr->", netErr(), "used->", used(), "alias->", alias()
|
|
setLock(1)
|
|
setLock(2)
|
|
setLock(3)
|
|
setLock(4)
|
|
setLock(5)
|
|
setLock(6)
|
|
setLock(7)
|
|
setLock(8)
|
|
setLock(9)
|
|
dspLock()
|
|
wait
|
|
?
|
|
select 1
|
|
? "unlock all in", alias()
|
|
dbUnLock()
|
|
dspLock()
|
|
select 2
|
|
? "lock 10 records in", alias()
|
|
setLock(1)
|
|
setLock(2)
|
|
setLock(3)
|
|
setLock(4)
|
|
setLock(5)
|
|
setLock(6)
|
|
setLock(7)
|
|
setLock(8)
|
|
setLock(9)
|
|
dspLock()
|
|
wait
|
|
?
|
|
? "unlock 3, 5, 9 in", alias()
|
|
dbRUnLock(3)
|
|
dbRUnLock(5)
|
|
dbRUnLock(9)
|
|
dspLock()
|
|
select 1
|
|
? "lock 10 records in", alias()
|
|
setLock(1)
|
|
setLock(2)
|
|
setLock(3)
|
|
setLock(4)
|
|
setLock(5)
|
|
setLock(6)
|
|
setLock(7)
|
|
setLock(8)
|
|
setLock(9)
|
|
dspLock()
|
|
wait
|
|
dbCloseAll()
|
|
hb_dbDrop( cFile )
|
|
return
|
|
|
|
proc setLock( n )
|
|
? "locking record: " + hb_ntos( n ) + " ->", dbRLock( n )
|
|
return
|
|
|
|
proc dspLock()
|
|
local n
|
|
? alias(), "active locks:"
|
|
for each n in dbRLockList()
|
|
?? "", hb_ntos( n )
|
|
next
|
|
return
|