Construct for defining new fiber local storage variables.
The file, mod and line template params should be ignored. They are used merely to ensure that each FiberLocal
definition is unique.
To use, alias a name to FiberLocal like so:
aliassomeName = FiberLocal!(uint, 12);
Any reference to someName will reference a fiber local variable of type uint with an init value of 12.
Note:
It is important to understand that someName actually aliases a @property function that returns a reference to said
variable. Under most circumstances this makes no difference. If you wish to take the variable's address, however, you
need to explicitly invoke the function, or you'll get a pointer to the function rather than the variable:
The different FLS variables are distinguished based on their template paramters. Usually this is not a problem, as the
source file and line number where the variable is defined is coded. Under some cases, however, this is not unique
enough.
The above code creates three variables, called fls1, fls2 and someOtherFls, all aliased to the same actual value.
This is because all three are defined on the same source line.
To solve this problem, use the id template argument. It does not matter what it is, so long as it is unique. The
following code generates three variables, as before, but all three are unique:
Construct for defining new fiber local storage variables.
The file, mod and line template params should be ignored. They are used merely to ensure that each FiberLocal definition is unique.
To use, alias a name to FiberLocal like so:
Any reference to someName will reference a fiber local variable of type uint with an init value of 12.
Note: It is important to understand that someName actually aliases a @property function that returns a reference to said variable. Under most circumstances this makes no difference. If you wish to take the variable's address, however, you need to explicitly invoke the function, or you'll get a pointer to the function rather than the variable:
The different FLS variables are distinguished based on their template paramters. Usually this is not a problem, as the source file and line number where the variable is defined is coded. Under some cases, however, this is not unique enough.
The above code creates three variables, called fls1, fls2 and someOtherFls, all aliased to the same actual value. This is because all three are defined on the same source line.
To solve this problem, use the id template argument. It does not matter what it is, so long as it is unique. The following code generates three variables, as before, but all three are unique: