Ignore:
Timestamp:
Mar 20, 2025, 1:06:08 AM (3 days ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
master
Children:
f5bf3c2
Parents:
5329cba
Message:

Flesh out the string_sharectx demo

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified doc/theses/mike_brooks_MMath/programs/sharectx.run.cfa

    r5329cba r62b5940  
    11#include <string.hfa>
    22#include <string_sharectx.hfa>
    3 
    4 void a() {}
    5 void b() {}
    6 void c() {}
    7 void d() {}
    8 void e() {}
    93
    104
     
    148
    159
    16 
    17 
    18 
    19 
    20 void helper2() {
    21         c();
    22         string_sharectx c = {NEW_SHARING};
    23         d();
     10void a( string & sm ) {
     11        string sm_a = sm; // share
    2412}
    25 void helper1() {
    26         a();
    27         string_sharectx c = {NO_SHARING};
    28         b();
    29         helper2();
    30         e();
     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 );
    3149}
    3250int main() {
    33         helper1();
     51        string sm = "sm";
     52        a( sm );
     53        helper1( sm );
     54        g( sm );
    3455}
    35 
Note: See TracChangeset for help on using the changeset viewer.