I am trying to convert java code to objective c code. And the Java code contains variables defined in the form of Voltil. I saw volcano as online and "unstable" usage in Java
Essentially, the vapor is used to indicate that the values of a variable are modified by different threads Will go So, if I was going to set the variable in the Objective-C variable, since the variables are being accessed from various threads, then I set them as volatile Not required because I can just set those variables as atoms?
Objective-c contains unstable keyword you can use it . That's because the objective-CC is a superset.
Declaring the properties as atomic would not be correct unstable was meant to be unstable effective form Tells the compiler that adaptation can not be done to remove checks made on that variable, as it can change when the compiler was expected to remain the same. The easiest example is to assume that we have a global variable that has been declared:
int packetsReceived = 0; And it is used later in such a way:
received packet = 0; While (packets received & lt; 10) {// wait for more packets} Process packets (); We will never get through that loop, because the compiler will say "hey, received packet is never modified in that loop, so it is infinite Will go on. " As a result, it will only make a straightforward unlimited loop, so that it can be checked every time. If we have declared a variable instead:
achieves unstable int packets; We are saying to the compiler that this variable can change at any time, even if it seems that it should be the same. So in our example, the condition of machine code generated by the compiler will still be checked, and our program will work as expected.
Comments
Post a Comment