[Gambas-devel] Question about singleton class

John Leake jleake at ...741...
Sat Sep 13 10:53:11 CEST 2014


Hi Tobi,
Thank you for your response and confirming the same behaviour. Sorry for
the break point I left in the code and a path that was not relevant to
your test.

If you step back from the detail and look at this from a programming
perspective and look at the gambas docs then it appears to be a bug.

I have looked at the code but cannot quite work out where the bug is.
This is not because it is written in C but more to do with following the
program flow.

Do calls to THROW return ?

Anyway could I be bold and suggest what should happen and how it can be
implemented:

If a proc is granted a write Lock it should obviously be an exclusive
lock and remain in place until Unlock is called or the proc terminates.
All OS write lock mechanisms do this no matter whos standard you look
at. If the same proc calls Lock a second time without calling Unlock in
between then the original lock should be left in place and a 'no-error'
status returned to the caller.

To achieve this simply retain the file handle to the locked resource and
keep it open until Unlock is called or the proc dies/exits.

>> 3) Starting from scratch. Attempt to Unlock the file and you see an
>> error returned which is OK. But when you then Attempt Lock it returns OK
>> but the empty string from Error.Text does not wipe out the previous
>> error text. Surely I am doing something wrong in the code ?
> 
> No you don't. Error.Text "returns the last error message".
> 
Are you saying that Try followed by a test on Error is not the right way
to code in Gambas ?

> 
>> 4) How can an app decide when to clean up and remove the lock file ?
>>
> 
> I don't think I get your question right but in case I do, I'd say: It
> removes the lock when it's done with its job. When this event occurs
> must be wired into the program's logic.
> 
So do you mean that to use Lock and Unlock an app also has to Delete files ?

John




More information about the Devel mailing list