Changeset 62b5940 for doc/theses/mike_brooks_MMath/string.tex
- Timestamp:
- Mar 20, 2025, 1:06:08 AM (3 days ago)
- Branches:
- master
- Children:
- f5bf3c2
- Parents:
- 5329cba
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified doc/theses/mike_brooks_MMath/string.tex ¶
r5329cba r62b5940 470 470 Hence, concurrent users of string objects must still bring their own mutual exclusion, but the string library does not add any cross thread uses that are not apparent in a user's code. 471 471 472 \PAB{I could not get this to do anything.} 473 The \CFA string library does provides a @string_sharectx@ type to control an ambient sharing context for the current thread. 472 The \CFA string library provides the type @string_sharectx@to control an ambient sharing context for the current thread. 474 473 It allows two adjustments: to opt out of sharing entirely or to begin sharing within a private context. 475 474 Either way, the chosen mode applies only to the current thread, for the duration of the lifetime of the created @string_sharectx@ object, up to being suspended by child lifetimes of different contexts. 475 \VRef[Figure]{fig:string-sharectx} illustrates its behaviour. 476 Executing the example does not produce an interesting outcome. 477 But the comments indicate when the logical copy operation runs with 478 \begin{description} 479 \item[share:] the copy being deferred, as described through the rest of this section (fast), or 480 \item[copy:] the copy performed eagerly (slow). 481 \end{description} 482 Only eager copies can cross @string_sharectx@ boundaries. 476 483 The intended use is with stack-managed lifetimes, in which the established context lasts until the current function returns, and affects all functions called that do not create their own contexts. 477 \lstinputlisting[language=CFA, firstline=20, lastline=34]{sharectx.run.cfa}478 484 In this example, the single-letter functions are called in alphabetic order. 479 The functions @a@ and @d@ share string character ranges within themselves, but not with each other. 480 The functions @b@, @c@ and @e@ never share anything. 485 The functions @a@, @b@ and @g@ share string character ranges with each other, because they occupy a common sharing-enabled context. 486 The function @e@ shares within itself (because its is in a sharing-enabled context), but not with the rest of the program (because its context is not occupied by any of the rest of the program). 487 The functions @c@, @d@ and @f@ never share anything, because they are in a sharing-disabled context. 488 489 490 \begin{figure} 491 \begin{tabular}{ll} 492 \lstinputlisting[language=CFA, firstline=10, lastline=55]{sharectx.run.cfa} 493 & 494 \includegraphics{string-sharectx.pdf} 495 \end{tabular} 496 \caption{Controlling copying vs sharing of strings using \lstinline{string_sharectx}.} 497 \label{fig:string-sharectx} 498 \end{figure} 499 481 500 482 501 [ TODO: true up with ``is thread local'' (implement that and expand this discussion to give a concurrent example, or adjust this wording) ]
Note: See TracChangeset
for help on using the changeset viewer.