How to use globals correctly?
Robert M. Münch
robert.muench at saphirion.com
Mon Mar 5 18:35:11 UTC 2018
Hi, I'm feeling a bit dumb but anway...
For hacking prototypes I mostly create a class to store all kind of
values. Then I create one global instance of this class and use it
everywhere. Pseudocode looks like this:
class myClass {
myMemb1;
myMembN;
this(){...}
}
__gshared myClass myObj;
main() {
myObj = new myClass();
func1();
...
}
func1(){
myObj.myMemb1 = ...
}
If I use VisualD and add a watch on myObj, I don't see anything just a
"identifier myObj is undefined". Not sure if this is because of some
threads running (using the D RX framework).
So, some questions:
1. Are myMemb1..N TLS or __gshared as well?
2. How to best implement a simple global to keep track of values (with
support for threads)?
--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster
More information about the Digitalmars-d-learn
mailing list