using locked in a type

Avra
Schreiberling
Avatar
Geschlecht:
Herkunft: Belgrade, Serbia
Alter: 54
Homepage: rs.linkedin.com/in…
Beiträge: 653
Dabei seit: 07 / 2002
Betreff:

using locked in a type

 · 
Gepostet: 21.06.2014 - 22:54 Uhr  ·  #1
It would be very nice to be able to define a type which will be used to instance locked variable:
Code
type
  TRawNum = integer, locked;        //   <<<<<   NOT POSSIBLE :-(

  TAiRuntime = record
    Eng: TSomeNotImportantType;
    Raw: TRawNum;                   //   <<<<<   NOT POSSIBLE :-(
  end;

var
  LockedVar: integer, locked;       //   <<<<<   POSSIBLE :-)
  AI: array[1..64] of TAiRuntime;   //   <<<<<   NOT POSSIBLE :-(


I have complex structures existing in runtime records accessed by different processes, and there are for example commands similar to this one:
Code
  Runtime.AI[4].Raw.Value := SomeValue;

It would really be nice to be able to lock such variables nested in typed records. Without such a feature I have to give up either locking or typed records, or write ugly disable/enable interrupt workaround wrapper for each variable access.
Merlin
Administrator
Avatar
Geschlecht:
Alter: 25
Beiträge: 1474
Dabei seit: 03 / 2005
Betreff:

Re: using locked in a type

 · 
Gepostet: 23.06.2014 - 15:09 Uhr  ·  #2
Hi Avra.

I know you only want to lock an element within a record within an array, but surely it does no harm to lock the entire array?

Code
var
  AI: array[1..64] of TAiRuntime, locked;


is permitted.
rh
Administrator
Avatar
Geschlecht:
Herkunft: Germany
Alter: 25
Homepage: e-lab.de
Beiträge: 5558
Dabei seit: 03 / 2002
Betreff:

Re: using locked in a type

 · 
Gepostet: 23.06.2014 - 16:04 Uhr  ·  #3
Hello Avra,

sorry, locking a part of an array or record is impossible here.
But you can simply do it like Merlin suggested.
Or implement your own locking like the compiler does it.
Code
NoInts;
  any access...
restoreInts;

rolf
Avra
Schreiberling
Avatar
Geschlecht:
Herkunft: Belgrade, Serbia
Alter: 54
Homepage: rs.linkedin.com/in…
Beiträge: 653
Dabei seit: 07 / 2002
Betreff:

Re: using locked in a type

 · 
Gepostet: 23.06.2014 - 20:19 Uhr  ·  #4
My complex structure in RAM is 1614 bytes and in EEPROM it is 1442 bytes, so locking the whole structures is not wanted when there are only few hundred bytes that are critical for locking. I will live with a manual locking wrapper in code around each variable access.

Merlin and Rolf, thank you both for looking at my problem.
Gewählte Zitate für Mehrfachzitierung:   0

Registrierte in diesem Topic

Aktuell kein registrierter in diesem Bereich

Die Statistik zeigt, wer in den letzten 5 Minuten online war. Erneuerung alle 90 Sekunden.
MySQL Queries: 15 · Cache Hits: 14   72   86 · Page-Gen-Time: 0.02517s · Speichernutzung: 2 MB · GZIP: ein · Viewport: SMXL-HiDPI