Skip to content
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

[Feature Request] Atomic properties #1253

Closed
jtenner opened this issue May 6, 2020 · 2 comments
Closed

[Feature Request] Atomic properties #1253

jtenner opened this issue May 6, 2020 · 2 comments

Comments

@jtenner
Copy link
Contributor

jtenner commented May 6, 2020

Proposed mechanism for this: @atomic decorator

Given the following class example:

class A {
  @atomic b: i32 = 0;
}

// should be the equivalent of writing the following code

class A {
  private _b: i32 = 0;
  public get b(): i32 {
   return atomic.load<i32>(changetype<usize>(this), offsetof<A>("_b"));
  }
  public set b(value: i32) {
   return atomic.store<i32>(changetype<usize>(this), value, offsetof<A>("_b"));
  }
}
@dcodeIO
Copy link
Member

dcodeIO commented May 6, 2020

To add to the discussion on Slack: I think we'll have to decide how to approach threading in general. For instance, the mechanism proposed here is a bit like Java's synchronized, which also covers methods etc., but we'd first have to be sure that this is what we want over something like postMessage and friends.

@MaxGraey MaxGraey changed the title Feature Request: Atomic loads and stores [Feature Request] Atomic properties May 10, 2020
@dcodeIO
Copy link
Member

dcodeIO commented May 28, 2020

Closing this issue as part of 2020 vacuum because the suggestion made here doesn't seem feasible as-is, respectively a more general discussion about how we'd like to approach threads is necessary first. At this point in time, my expectation is that we'll ultimately end up deciding for a more JS-like approach to threading, mimicking workers and postMessage, while leaving the ins and outs of low-level locking to those interested in implementing manual locking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants