using locked in a type

Avra
Schreiberling
Avatar
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

using locked in a type

 · 
Posted: 21.06.2014 - 22:54  ·  #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
Gender:
Age: 24
Posts: 1409
Registered: 03 / 2005
Subject:

Re: using locked in a type

 · 
Posted: 23.06.2014 - 15:09  ·  #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
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: using locked in a type

 · 
Posted: 23.06.2014 - 16:04  ·  #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
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

Re: using locked in a type

 · 
Posted: 23.06.2014 - 20:19  ·  #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.
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   72   86 · Page-Gen-Time: 0.028748s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI