source: doc/theses/mike_brooks_MMath/programs/sharectx.run.cfa @ 62b5940

Last change on this file since 62b5940 was 62b5940, checked in by Michael Brooks <mlbrooks@…>, 3 days ago

Flesh out the string_sharectx demo

  • Property mode set to 100644
File size: 1018 bytes
Line 
1#include <string.hfa>
2#include <string_sharectx.hfa>
3
4
5
6
7
8
9
10void a( string & sm ) {
11        string sm_a = sm; // share
12}
13void b( string & sm ) {
14        string sm_b = sm; // share
15}
16void c( string & sm, string & sh1 ) {
17        string sm_c = sm; // copy
18        string sh1_c = sh1; // copy
19}
20void d( string & sm, string & sh1 ) {
21        string sm_d = sm; // copy
22        string sh1_d = sh1; // copy
23}
24void e( string & sm, string & sh1, string & sh2 ) {
25        string sm_e = sm; // copy
26        string sh1_e = sh1; // copy
27        string sh2_e = sh2; // share
28}
29void f( string & sm, string & sh1 ) {
30        string sm_f = sm; // copy
31        string sh1_f = sh1; // copy
32}
33void g( string & sm ) {
34        string sm_g = sm; // share
35}
36void helper2( string & sm, string & sh1 ) {
37        d( sm, sh1 );
38        string_sharectx ctx_on = {NEW_SHARING};
39        string sh2 = "sh2";
40        e( sm, sh1, sh2 );
41}
42void helper1( string & sm ) {
43        b( sm );
44        string_sharectx ctx_off = {NO_SHARING};
45        string sh1 = "sh1";
46        c( sm, sh1 );
47        helper2( sm, sh1 );
48        f( sm, sh1 );
49}
50int main() {
51        string sm = "sm";
52        a( sm );
53        helper1( sm );
54        g( sm );
55}
Note: See TracBrowser for help on using the repository browser.