I need help!
-
If I have a setup where two objects are getting an attribute and adding 1 to it(and then setting it) is there any possibility that one might get the attribute while the other one is adding, and effectively increase the attribute by 1 instead of 2? Assuming that they may not always trigger at the same time.
If that makes any sense. -
I'm not asking for a project. This is beyond my current understanding of how hyperPad operates.
But you've had 45 minutes from the original post to add a project example. And yet haven't done it.
Some of the answers to your questions about why I don't upload projects likely have some overlap with your existing reasons in this scenario.
As to your problem:
Concurrency and data state is an enormously difficult problem to solve in computing, despite having first been solved in the 1960's - that solve was thrown away and left to wither and die. The problems you see with Apple's roll out of iCloud are partly related.
Let's examine:
Object ABC and XYZ are as you say, going to both do an operation on the same data, and don't expect anyone else to do anything during that time, and then update that data.
If ABC grabs 1 and adds to it, and whilst he's doing this Object XYZ grabs it and begins performing the same operation, then yes... what can happen is this:
ABC finishes while XYZ is adding, and ABC updates the variable. If XYZ doesn't check to make sure that the variable hasn't changed whilst performing his operation, he could simply overwrite the variable with the exact same value...
One solution, when XYZ has finished adding, he can check to see if the value changed, and if it did, re-perform the operation with the new value.
But what if the source value changes AGAIN whilst he's doing this new addition?
And on and on it goes.
So the traditional solution is to have a flag that makes it obvious that the data in a source has been "checked out" and that someone is currently operating on that value and intends to update it when they're done. And this causes a backlog, cause now XYZ has to sit and wait for the value to be checked back in so he can have his turn on the value.
Another solution is to send the operation to the object and say "When you get a moment, can you do this?"
-
@Deeeds the most a project would do is help explain myself. Also, Iām not sure how I would set up a project that could even demonstrate the question, since I donāt know if it even would happen.
In your case, the for each wasnāt doing what you expected. That was something that could be diagnosed by another user.
This question was more directed towards the Hyperpad team, since they might known how that situation with the attributes would be handled. -
@iTap-Development So you didn't read beyond my teasing?
-
@Deeeds yes, I didš
Thatās basically what my conclusion was. But it helpful info! Thanks -
@iTap-Development I think that if they both attempt to do it at the same time, itāll actually add by 2, but Iām not 100% sure. Maybe you should test it, make an object that adds a to some attribute, then duplicate it a few times, and see if the attribute ends up being added by the amount of duplicate objects.
-
@Aidan-Oxley I could try, it but I canāt really be sure if they are triggering at the right moment to cause a problem. Right?
š¤·āāļø -
@iTap-Development Iāll try it. Itās pretty simple though, Iām just gonna make a heap of objects wait like 5 seconds from the start of the project being run, then they are all gonna try to add 1 to some attribute, then Iām gonna see what the attribute turns out to be.
-
@iTap-Development This is awesome. No matter how many objects attempting to add to the attribute at the same time, they all managed to do it without interrupting each other. I added 30 objects, all adding the the attribute at the same time, the attribute went up by 30 every time I triggered it (it was like a loop, I couldnāt see any numbers display between 0 and 30).
-
@Aidan-Oxley cool!