annotate src/parallel_execution/AtomicReference.cbc @ 468:ac244346c85d

Change used interface syntax from #include to #interface
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Mon, 25 Dec 2017 18:10:56 +0900
parents 8d7e5d48cad3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
441
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include "../context.h"
468
ac244346c85d Change used interface syntax from #include to #interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 462
diff changeset
2 #interface "Atomic.h"
441
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include <stdio.h>
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
444
0c024ea61601 Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 441
diff changeset
5 Atomic* createAtomicReference(struct Context* context) {
441
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 struct Atomic* atomic = new Atomic();
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 struct AtomicReference* atomicReference = new AtomicReference();
444
0c024ea61601 Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 441
diff changeset
8 atomic->atomic = (union Data*)atomicReference;
441
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 atomic->checkAndSet = C_checkAndSetAtomicReference;
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 return atomic;
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 }
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12
444
0c024ea61601 Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 441
diff changeset
13 __code checkAndSetAtomicReference(struct AtomicReference* atomic, union Data** ptr, union Data* oldData, union Data* newData, __code next(...), __code fail(...)) {
0c024ea61601 Using cas interface but occurred warning
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 441
diff changeset
14 if (__sync_bool_compare_and_swap(ptr, oldData, newData)) {
441
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 goto next(...);
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 }
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 goto fail(...);
5a737c3df91c Add AtomicReference Implements of Atomic Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 }