-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stabilize lock statement #357
Comments
Ref keyword - we did consider all these options when doing this originally. I prefer to keep |
I am OK with I think I would also be OK with |
It's better to define the semantics related to object and record fields within
|
Nothing special about record or object references: |
Semantics of experimental implementation are described in #346. We need to decide how we want to do this in the spec. I think we should have semantics that more focused on providing a model for the programmer that is easy to understand and reason about and that does not expose implementation details.
I think it unlikely that the user will want semantics where the effects of multiple lock statements appear to be interleaved. Accordingly, I propose that the semantics be that outermost lock statements are not interleaved. All outermost
lock
blocks in the program execute in a single total order. Nestedlock
blocks do nothing. The effect is as if all lock statements execute under a single, global, recursive lock.This is similar to "atomic sections", which are often provided by language interfaces to software transactional memory e.g. C++. But several kinds of implementation are possible:
For Ballerina, we could start with 1 and then do 3. Papers on 3 include:
We also need to decide on the keyword. Possibilities are:
lock
synchronized
atomic
This also relates to the pure function idea #145. We might say that a pure function can access module-level variables only within a
lock
statement.The text was updated successfully, but these errors were encountered: