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

Conditionals in atomic sections #141

Open
septract opened this issue Feb 9, 2017 · 0 comments
Open

Conditionals in atomic sections #141

septract opened this issue Feb 9, 2017 · 0 comments

Comments

@septract
Copy link
Owner

septract commented Feb 9, 2017

(This is pulled out from the broader issue #105)

Conditionals in atomic sections would be very useful in the MCS queue (see #133) where we need a compareAndSet operation over Starling variables. I want to write something like the following:

method unlock (Node qnode) { 
  ...
  < if (qnode == tail) { 
        tail = null;
        test = true; 
     } else { 
        test = false
     }  > ;  
  ...
} 

The only way to do this at the moment is (I think) to piggyback on GRASShopper's if statement, which is dumb:

method unlock (Node qnode) { 
  ...
  < test = ( tail == qnode ); 
    tail = %{ if ( [|test|] ) { null } else { [|tail|] } }; > ;  
  ...
} 

I think @MattWindsor91 also ran into this when he was trying to encode the Treiber stack.

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

1 participant