text
stringlengths
9
39.2M
dir
stringlengths
26
295
lang
stringclasses
185 values
created_date
timestamp[us]
updated_date
timestamp[us]
repo_name
stringlengths
1
97
repo_full_name
stringlengths
7
106
star
int64
1k
183k
len_tokens
int64
1
13.8M
```xml import type { ConvertibleDataType } from './ConvertibleDataType' export type FileToDocPendingConversion = { data: Uint8Array type: ConvertibleDataType } ```
/content/code_sandbox/packages/docs-shared/lib/FileToDocPendingConversion.ts
xml
2016-06-08T11:16:51
2024-08-16T14:14:27
WebClients
ProtonMail/WebClients
4,300
37
```xml <?xml version="1.0" encoding="UTF-8"?> <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2"> <file source-language="en" target-language="de" datatype="plaintext" original="teams.en.xlf"> <body> <trans-unit id="A_4Fc7c" approved="yes" resname="teams.project_access"> <source>teams.project_access</source> <target>Zugriff auf Projekte gewhren</target> </trans-unit> <trans-unit id="QchGnbx" approved="yes" resname="teams.customer_access"> <source>teams.customer_access</source> <target>Zugriff auf Kunden gewhren</target> </trans-unit> <trans-unit id=".yIcFDx" approved="yes" resname="team.visibility_global"> <source>team.visibility_global</source> <target>Sichtbar fr alle Benutzer, da bisher noch kein Team zugewiesen wurde.</target> </trans-unit> <trans-unit id="hlIIRjb" approved="yes" resname="team.visibility_restricted"> <source>team.visibility_restricted</source> <target>Nur sichtbar fr die folgenden Teams und alle Administratoren.</target> </trans-unit> <trans-unit id="sx7AVYH" approved="yes" resname="team.project_visibility_inherited"> <source>team.project_visibility_inherited</source> <target>Das Projekt ist nur eingeschrnkt sichtbar, da Team Berechtigungen fr den Kunden gesetzt sind.</target> </trans-unit> <trans-unit id="FC4DW27" approved="yes" resname="team.activity_visibility_inherited"> <source>team.activity_visibility_inherited</source> <target>Die Ttigkeit ist nur eingeschrnkt sichtbar, da Team Berechtigungen fr das Projekt und/oder den Kunden gesetzt sind.</target> </trans-unit> <trans-unit id="cZEIdcu" approved="yes" resname="team.create_default"> <source>team.create_default</source> <target>Erstelle ein neues Team um den Zugriff zu beschrnken</target> </trans-unit> <trans-unit id="6g81kYY" approved="yes" resname="team.member"> <source>team.member</source> <target>Mitglieder</target> </trans-unit> </body> </file> </xliff> ```
/content/code_sandbox/translations/teams.de.xlf
xml
2016-10-20T17:06:34
2024-08-16T18:27:30
kimai
kimai/kimai
3,084
573
```xml <?xml version="1.0" encoding="utf-8"?> <!-- COMPLETED (4) Set the touch selector as the background property for the list item layout --> <LinearLayout xmlns:android="path_to_url" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/list_item_selector"> <!-- Horizontal linear layout to create a contacts list item --> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="80dp" android:paddingTop="4dp" android:paddingBottom="4dp" android:gravity="center_vertical"> <!-- Person icon --> <ImageView android:id="@+id/personIcon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_person" android:paddingRight="4dp" android:paddingLeft="4dp" android:contentDescription="@string/person_icon"/> <!-- Text views for a person's first and last name --> <TextView android:id="@+id/firstName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textStyle="bold" android:textSize="24sp" android:textColor="@android:color/black" android:text="@string/first" android:paddingRight="4dp" android:paddingLeft ="4dp"/> <TextView android:id="@+id/lastName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="24sp" android:textColor="@android:color/darker_gray" android:text="@string/last" android:paddingRight="4dp" android:paddingLeft ="4dp"/> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@android:color/darker_gray"/> </LinearLayout> ```
/content/code_sandbox/Lesson12-Visual-Polish/T12.04-Solution-TouchSelector/app/src/main/res/layout/selector_list_item.xml
xml
2016-11-02T04:41:25
2024-08-12T19:38:05
ud851-Exercises
udacity/ud851-Exercises
2,039
433
```xml /* * one or more contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright ownership. */ import {ReactNode, useState} from 'react'; import {Redirect} from 'react-router-dom'; import {Button, Form, TextInput} from '@carbon/react'; import {Modal} from 'components'; import {t} from 'translation'; import {showError} from 'notifications'; import {addSources} from 'services'; import {useErrorHandling} from 'hooks'; import {Source} from 'types'; import SourcesModal from './SourcesModal'; import './CollectionModal.scss'; interface CollectionModalProps { onClose: () => void; title?: ReactNode; confirmText: string; initialName?: string; onConfirm: (name?: string) => Promise<string>; showSourcesModal?: boolean; } export function CollectionModal({ onClose, title, confirmText, initialName, onConfirm, showSourcesModal, }: CollectionModalProps) { const [name, setName] = useState(initialName); const [loading, setLoading] = useState(false); const [redirect, setRedirect] = useState<string | null>(null); const [displaySourcesModal, setDisplaySourcesModal] = useState(false); const {mightFail} = useErrorHandling(); const confirm = () => { if (!name || loading) { return; } if (showSourcesModal) { setDisplaySourcesModal(true); } else { performRequest(); } }; const performRequest = (sources?: Source[]) => { mightFail( onConfirm(name), (id) => { if (id && sources) { mightFail( addSources(id, sources), () => { setRedirect(id); }, showError, () => setLoading(false) ); } }, (error) => { showError(error); }, () => setLoading(false) ); }; if (redirect) { return <Redirect to={`/collection/${redirect}/`} />; } return ( <> <Modal className="CollectionModal" open={!displaySourcesModal} onClose={onClose}> <Modal.Header title={title} /> <Modal.Content> <Form> {showSourcesModal && <div className="info">{t('common.collection.modal.info')}</div>} <TextInput id="collectionName" labelText={t('common.collection.modal.inputLabel')} value={name} onChange={({target: {value}}) => setName(value)} disabled={loading} autoComplete="off" data-modal-primary-focus /> </Form> </Modal.Content> <Modal.Footer> <Button kind="secondary" className="cancel" onClick={onClose} disabled={loading}> {t('common.cancel')} </Button> <Button className="confirm" disabled={!name || loading} onClick={confirm}> {showSourcesModal ? t('common.collection.modal.addDataSources') : confirmText} </Button> </Modal.Footer> </Modal> {displaySourcesModal && ( <SourcesModal onClose={onClose} onConfirm={performRequest} confirmText={confirmText} preSelectAll /> )} </> ); } export default CollectionModal; ```
/content/code_sandbox/optimize/client/src/components/Home/modals/CollectionModal.tsx
xml
2016-03-20T03:38:04
2024-08-16T19:59:58
camunda
camunda/camunda
3,172
704
```xml import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { CascadeSelectDemo } from './cascadeselectdemo'; @NgModule({ imports: [RouterModule.forChild([{ path: '', component: CascadeSelectDemo }])], exports: [RouterModule] }) export class CascadeSelectDemoRoutingModule {} ```
/content/code_sandbox/src/app/showcase/pages/cascadeselect/cascadeselectdemo-routing.module.ts
xml
2016-01-16T09:23:28
2024-08-16T19:58:20
primeng
primefaces/primeng
9,969
67
```xml #!/usr/bin/env ts-node import dotenv from "dotenv"; // Apply all the configuration provided in the .env file if it isn't already in // the environment. dotenv.config(); import chalk from "chalk"; import fs from "fs-extra"; import FileSizeReporter from "react-dev-utils/FileSizeReporter"; import formatWebpackMessages from "react-dev-utils/formatWebpackMessages"; import printBuildError from "react-dev-utils/printBuildError"; import webpack from "webpack"; import paths from "../config/paths"; import config from "../src/core/build/config"; import createWebpackConfig from "../src/core/build/createWebpackConfig"; /* eslint-disable no-console */ process.env.WEBPACK = "true"; process.env.NODE_ENV = process.env.NODE_ENV || "production"; process.env.BABEL_ENV = process.env.NODE_ENV; // Enforce environment to be NODE_ENV. config.validate().set("env", process.env.NODE_ENV); const isProduction = process.env.NODE_ENV === "production"; // Makes the script crash on unhandled rejections instead of silently // ignoring them. In the future, promise rejections that are not handled will // terminate the Node.js process with a non-zero exit code. process.on("unhandledRejection", (err) => { throw err; }); const measureFileSizesBeforeBuild = FileSizeReporter.measureFileSizesBeforeBuild; const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild; // These sizes are pretty large. We'll warn for bundles exceeding them. const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024; const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024; // Treat warnings as errors when we are in CI // TODO: This is currently turned off until we have // an optimized build. const treatWarningsAsErrors = false && process.env.CI && (typeof process.env.CI !== "string" || process.env.CI!.toLowerCase() !== "false"); // First, read the current file sizes in build directory. // This lets us display how much they changed later. measureFileSizesBeforeBuild(paths.appDistStatic) .then((previousFileSizes: any) => { // Remove all content but keep the directory so that // if you're in it, you don't end up in Trash fs.emptyDirSync(paths.appDistStatic); // Merge with the public folder if (fs.pathExistsSync(paths.appPublic)) { copyPublicFolder(); } // Start the webpack build return build(previousFileSizes); }) .then( ({ stats, previousFileSizes, warnings }: any) => { if (warnings.length) { console.log(chalk.yellow("Compiled with warnings.\n")); console.log(warnings.join("\n\n")); console.log( "\nSearch for the " + chalk.underline(chalk.yellow("keywords")) + " to learn more about each warning." ); console.log( "To ignore, add " + chalk.cyan("// eslint-disable-next-line") + " to the line before.\n" ); } else { console.log(chalk.green("Compiled successfully.\n")); } console.log("File sizes after gzip:\n"); printFileSizesAfterBuild( stats, previousFileSizes, paths.appDistStatic, WARN_AFTER_BUNDLE_GZIP_SIZE, WARN_AFTER_CHUNK_GZIP_SIZE ); console.log(); }, (err: Error) => { console.log(chalk.red("Failed to compile.\n")); printBuildError(err); process.exit(1); } ); // Create the production build and print the deployment instructions. function build(previousFileSizes: any) { if (isProduction) { console.log("Creating an optimized production build..."); } else { console.log("Creating development build..."); } const webpackConfig = createWebpackConfig(config); const compiler = webpack(webpackConfig); return new Promise((resolve, reject) => { compiler.run((err, stats) => { if (err) { return reject(err); } const messages = formatWebpackMessages( stats.toJson({ children: webpackConfig.map((c) => c.stats || {}) as any, }) ); if (messages.errors.length) { // Only keep the first error. Others are often indicative // of the same problem, but confuse the reader with noise. if (messages.errors.length > 1) { messages.errors.length = 1; } // eslint-disable-next-line @typescript-eslint/no-unsafe-argument return reject(new Error(messages.errors.join("\n\n"))); } if (treatWarningsAsErrors && messages.warnings.length) { console.log( chalk.yellow( "\nTreating warnings as errors because process.env.CI = true.\n" + "Most CI servers set it automatically.\n" ) ); // eslint-disable-next-line @typescript-eslint/no-unsafe-argument return reject(new Error(messages.warnings.join("\n\n"))); } return resolve({ stats, previousFileSizes, warnings: messages.warnings, }); }); }); } function copyPublicFolder() { fs.copySync(paths.appPublic, paths.appDistStatic, { dereference: true, }); } ```
/content/code_sandbox/client/scripts/build.ts
xml
2016-10-31T16:14:05
2024-08-06T16:15:57
talk
coralproject/talk
1,881
1,122
```xml import { Component } from '@angular/core'; import { FieldBaseComponent } from '../field-base'; @Component({ selector: 'app-form-checkbox-list', styleUrls: ['form-checkbox-list.component.scss'], templateUrl: 'form-checkbox-list.component.html', }) export class FormCheckboxListComponent extends FieldBaseComponent { get controls() { return (<any>this.formGroup.controls[this.config.name]).controls; } } ```
/content/code_sandbox/src/Presentation/Web/ClientApp/src/app/shared/components/forms/components/form-checkbox-list/form-checkbox-list.component.ts
xml
2016-06-03T17:49:56
2024-08-14T02:53:24
AspNetCoreSpa
fullstackproltd/AspNetCoreSpa
1,472
85
```xml import { EventCallback, IDisposable, IEvent } from "oni-types" import * as dompurify from "dompurify" import * as hljs from "highlight.js" import * as marked from "marked" import * as Oni from "oni-api" import * as React from "react" /** * Props are like the constructor arguments * for the React component (immutable) */ interface IMarkdownPreviewProps { oni: Oni.Plugin.Api instance: MarkdownPreviewEditor } interface IColors { background: string foreground: string link: string codeBackground: string codeForeground: string codeBorder: string } interface IMarkdownPreviewState { source: string colors: IColors } const generateScrollingAnchorId = (line: number) => { return "scrolling-anchor-id-" + line } class MarkdownPreview extends React.PureComponent<IMarkdownPreviewProps, IMarkdownPreviewState> { private _subscriptions: IDisposable[] = [] constructor(props: IMarkdownPreviewProps) { super(props) const colors: IColors = { background: this.props.oni.colors.getColor("editor.background"), foreground: this.props.oni.colors.getColor("editor.foreground"), link: this.props.oni.colors.getColor("highlight.mode.normal.background"), codeBackground: this.props.oni.colors.getColor("background"), codeForeground: this.props.oni.colors.getColor("foreground"), codeBorder: this.props.oni.colors.getColor("toolTip.border"), } this.state = { source: "", colors } } public componentDidMount() { const activeEditor: Oni.Editor = this.props.oni.editors.activeEditor if (!activeEditor) { return } this.subscribe(activeEditor.onBufferChanged, args => this.onBufferChanged(args)) // TODO: Subscribe "onFocusChanged" if (this.props.oni.configuration.getValue("experimental.markdownPreview.autoScroll")) { this.subscribe(activeEditor.onBufferScrolled, args => this.onBufferScrolled(args)) } this.previewBuffer(activeEditor.activeBuffer) } public componentWillUnmount() { for (const subscription of this._subscriptions) { subscription.dispose() } this._subscriptions = [] } public render(): JSX.Element { const renderedMarkdown = this.generateMarkdown() this.props.instance.updateContent(this.state.source, renderedMarkdown) const html = renderedMarkdown + this.generateContainerStyle() const classes = "stack enable-mouse oniPluginMarkdownPreviewContainerStyle" return <div className={classes} dangerouslySetInnerHTML={{ __html: html }} /> } private generateContainerStyle(): string { const colors = this.state.colors const syntaxHighlightTheme = this.props.oni.configuration.getValue( "experimental.markdownPreview.syntaxTheme", ) const codeBlockStyle = ` background: ${colors.codeBackground}; color: ${colors.codeForeground}; border-color: ${colors.codeBackground}; font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,sans-serif padding: 0.4em 0.4em 0.4em 0.4em; margin: 0.4em 0.4em 0.4em 0.4em; ` return ` <link rel="stylesheet" href="node_modules/highlight.js/styles/${syntaxHighlightTheme}.css"> <style> .oniPluginMarkdownPreviewContainerStyle { padding: 1em 1em 1em 1em; overflow-y: auto; background: ${colors.background}; color: ${colors.foreground}; } .oniPluginMarkdownPreviewContainerStyle a:link { color: ${colors.link}; } .oniPluginMarkdownPreviewContainerStyle pre { display: flex; ${codeBlockStyle} } .oniPluginMarkdownPreviewContainerStyle code { ${codeBlockStyle} } </style> ` } private generateMarkdown(): string { const markdownLines: string[] = dompurify.sanitize(this.state.source).split("\n") const generateAnchor = (line: number): string => { return `<a id="${generateScrollingAnchorId(line)}"></a>` } let isBlock: boolean = false const originalLinesCount: number = markdownLines.length - 1 // tslint:disable-next-line for (var i = originalLinesCount; i > 0; i--) { if (markdownLines[i].includes("```")) { isBlock = !isBlock } else if (isBlock) { // Skip blocks } else if (markdownLines[i].trim() === "") { // Skip empty lines } else { markdownLines.splice(i, 0, generateAnchor(i)) } } markdownLines.splice(0, 0, generateAnchor(i)) markdownLines.push(generateAnchor(originalLinesCount - 1)) const markedOptions = { baseUrl: this.props.oni.workspace.activeWorkspace, highlight(code, lang) { return code }, } const highlightsEnabled = this.props.oni.configuration.getValue( "experimental.markdownPreview.syntaxHighlights", ) if (highlightsEnabled) { markedOptions.highlight = (code, lang) => { const languageExists = hljs.getLanguage(lang) const languageNotDefinedOrInvalid = typeof lang === "undefined" || (typeof languageExists === "undefined" && lang !== "nohighlight") if (languageNotDefinedOrInvalid) { return hljs.highlightAuto(code).value } if (lang === "nohighlight") { return code } return hljs.highlight(lang, code).value } } marked.setOptions(markedOptions) return marked(markdownLines.join("\n")) } private subscribe<T>(editorEvent: IEvent<T>, eventCallback: EventCallback<T>): void { this._subscriptions.push(editorEvent.subscribe(eventCallback)) } private onBufferChanged(bufferInfo: Oni.EditorBufferChangedEventArgs): void { if (bufferInfo.buffer.language === "markdown") { this.previewBuffer(bufferInfo.buffer) } } private onBufferScrolled(args: Oni.EditorBufferScrolledEventArgs): void { if (this.props.oni.editors.activeEditor.activeBuffer.language !== "markdown") { return } let anchor = null for (let line = args.windowTopLine - 1; !anchor && line < args.bufferTotalLines; line++) { anchor = document.getElementById(generateScrollingAnchorId(line)) } if (anchor) { anchor.scrollIntoView() } } private previewBuffer(buffer: Oni.Buffer): void { buffer.getLines().then((lines: string[]) => { this.previewString(lines.join("\n")) }) } private previewString(str: string): void { this.setState({ source: str }) } } class MarkdownPreviewEditor implements Oni.IWindowSplit { private _open: boolean = false private _manuallyClosed: boolean = false private _unrenderedContent: string = "" private _renderedContent: string = "" private _split: Oni.WindowSplitHandle constructor(private _oni: Oni.Plugin.Api) { this._oni.editors.activeEditor.onBufferEnter.subscribe(args => this.onBufferEnter(args)) this._oni.editors.activeEditor.onBufferLeave.subscribe(args => this.onBufferLeave(args)) } public isPaneOpen(): boolean { return this._open } public getUnrenderedContent(): string { return this._unrenderedContent } public getRenderedContent(): string { return this._renderedContent } public updateContent(unrendered: string, rendered: string): void { this._unrenderedContent = unrendered this._renderedContent = rendered } public toggle(): void { if (this._open) { this.close(true) } else { this.open() } } public open(): void { if (!this._open) { this._open = true this._manuallyClosed = false const editorSplit = this._oni.windows.activeSplitHandle // TODO: Update API this._split = this._oni.windows.createSplit("vertical", this) editorSplit.focus() } } public close(manuallyClosed = false): void { if (this._open) { this._open = false this._manuallyClosed = manuallyClosed this._split.close() } } public render(): JSX.Element { return <MarkdownPreview oni={this._oni} instance={this} /> } private onBufferEnter(bufferInfo: Oni.EditorBufferEventArgs): void { if (bufferInfo.language === "markdown" && this._manuallyClosed === false) { this.open() } } private onBufferLeave(bufferInfo: Oni.EditorBufferEventArgs): void { this.close() } } export function activate(oni: any): any { if (!oni.configuration.getValue("experimental.markdownPreview.enabled", false)) { return } const preview = new MarkdownPreviewEditor(oni) oni.commands.registerCommand( new Command( "markdown.openPreview", "Open Markdown Preview", "Open the Markdown preview pane if it is not already opened", () => { preview.open() }, ), ) oni.commands.registerCommand( new Command( "markdown.closePreview", "Close Markdown Preview", "Close the Markdown preview pane if it is not already closed", () => { preview.close(true) }, ), ) oni.commands.registerCommand( new Command( "markdown.togglePreview", "Toggle Markdown Preview", "Open the Markdown preview pane if it is closed, otherwise open it", () => { preview.toggle() }, ), ) return preview as any } class Command implements Oni.Commands.ICommand { constructor( public command: string, public name: string, public detail: string, public execute: Oni.Commands.CommandCallback, ) {} } ```
/content/code_sandbox/extensions/oni-plugin-markdown-preview/src/index.tsx
xml
2016-11-16T14:42:55
2024-08-14T11:48:05
oni
onivim/oni
11,355
2,219
```xml <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="path_to_url" targetNamespace="path_to_url" xmlns="path_to_url" elementFormDefault="qualified"> <xs:element name="packageData"> <xs:annotation> <xs:documentation>The root element of the package data</xs:documentation> </xs:annotation> <xs:complexType> <xs:all> <xs:element name="commonProperties"> <xs:annotation> <xs:documentation> Contains a custom common properties whose values are used to replace $-delimited tokens (for example, `$description$`) in the `.nuspec` files </xs:documentation> </xs:annotation> <xs:complexType> <xs:all> <xs:element name="defaultProperties" minOccurs="0" maxOccurs="1"> <xs:annotation> <xs:documentation> Contains a default values for common properties of the packages. The values of these properties can be overridden by properties of specific packages. For naming these properties, it is recommended to use the camelCase style. </xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:any namespace="##any" processContents="skip" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="commonMetadataElements" minOccurs="1" maxOccurs="1"> <xs:annotation> <xs:documentation> Defines a common metadata of the packages. XML content of this element is substituted into a `$CommonMetadataElements$` token in the `.nuspec` files. This XML content is completely static and cannot contain $-delimited tokens. </xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:any namespace="##any" processContents="skip" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="commonFileElements" minOccurs="1" maxOccurs="1"> <xs:annotation> <xs:documentation> Defines a list of common files to include in the packages. XML content of this element is substituted into a `$CommonFileElements$` token in the `.nuspec` files. This XML content is completely static and cannot contain $-delimited tokens. </xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element name="file" minOccurs="0" maxOccurs="unbounded"> <xs:annotation> <xs:documentation>File or files to include in the package</xs:documentation> </xs:annotation> <xs:complexType> <xs:attribute name="src" type="requiredString_type" use="required"> <xs:annotation> <xs:documentation> The location of the file or files to include relative to the `.nuspec` file </xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name="target" type="xs:string" use="optional"> <xs:annotation> <xs:documentation> Relative path to the directory within the package where the files will be placed </xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name="exclude" type="xs:string" use="optional"> <xs:annotation> <xs:documentation> The file or files to exclude within the `src` location </xs:documentation> </xs:annotation> </xs:attribute> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:all> </xs:complexType> </xs:element> <xs:element name="packages"> <xs:complexType> <xs:annotation> <xs:documentation>Defines a list of data about the packages</xs:documentation> </xs:annotation> <xs:sequence> <xs:element name="package" minOccurs="0" maxOccurs="unbounded"> <xs:annotation> <xs:documentation> Data about the package on basis of which the `.nupkg` file are created </xs:documentation> </xs:annotation> <xs:complexType> <xs:all> <xs:element name="properties" minOccurs="0" maxOccurs="1"> <xs:annotation> <xs:documentation> Contains a custom properties of the package that are used to replace $-delimited tokens (for example, `$tags$`) in the `.nuspec` files. These properties can override common properties. The property value can contain a Mustache tag with special token name (`{{{base}}}`) that is replaced with the value of overridable common property. </xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:any namespace="##any" processContents="skip" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="preprocessableFiles" minOccurs="0" maxOccurs="1"> <xs:annotation> <xs:documentation> Defines a list of files that must be processed before creating a `.nupkg` files </xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element name="file" minOccurs="0" maxOccurs="unbounded"> <xs:annotation> <xs:documentation> Information about the file that must be processed before creating a `.nupkg` file. </xs:documentation> </xs:annotation> <xs:complexType> <xs:attribute name="src" type="requiredString_type"> <xs:annotation> <xs:documentation> The location of the pre-processable file relative to the XML file with package data. Pre-processable file is a primitive Mustache template. </xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name="target" type="requiredString_type"> <xs:annotation> <xs:documentation> The location of the target file relative to the XML file with package data. Target file is created based on primitive Mustache template and properties of the package. The path to target file can contain a Mustache tags that are replaced during processing with the values of corresponding package properties. </xs:documentation> </xs:annotation> </xs:attribute> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:all> <xs:attribute name="id" type="requiredString_type" use="required"> <xs:annotation> <xs:documentation>Unique identifier for the package</xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name="nuspecFile" type="requiredString_type" use="required"> <xs:annotation> <xs:documentation> The location of the `.nuspec` file relative to the XML file with package data </xs:documentation> </xs:annotation> </xs:attribute> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:all> </xs:complexType> </xs:element> <xs:simpleType name="requiredString_type"> <xs:restriction base="xs:string"> <xs:minLength value="1" /> </xs:restriction> </xs:simpleType> </xs:schema> ```
/content/code_sandbox/Build/NuGet/package-data.xsd
xml
2016-01-05T19:05:31
2024-08-16T17:20:00
ChakraCore
chakra-core/ChakraCore
9,079
1,790
```xml /* * one or more contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright ownership. */ import {expect} from '@playwright/test'; import {test} from '../test-fixtures'; import { mockBatchOperations, mockGroupedProcesses, mockProcessInstances, mockProcessInstancesWithOperationError, mockProcessXml, mockStatistics, mockResponses, } from '../mocks/processes.mocks'; test.describe('processes page', () => { for (const theme of ['light', 'dark']) { test(`empty page - ${theme}`, async ({page, commonPage, processesPage}) => { await commonPage.changeTheme(theme); await page.addInitScript(() => { window.localStorage.setItem( 'panelStates', JSON.stringify({ isOperationsCollapsed: false, }), ); }, theme); await page.route( /^.*\/api.*$/i, mockResponses({ batchOperations: [], groupedProcesses: mockGroupedProcesses, statistics: [], processXml: '', processInstances: { processInstances: [], totalCount: 0, }, }), ); await processesPage.navigateToProcesses({ searchParams: { active: 'true', incidents: 'true', }, options: { waitUntil: 'networkidle', }, }); await expect(page).toHaveScreenshot(); }); test(`error page - ${theme}`, async ({page, commonPage, processesPage}) => { await commonPage.changeTheme(theme); await page.addInitScript(() => { window.localStorage.setItem( 'panelStates', JSON.stringify({ isFiltersCollapsed: true, isOperationsCollapsed: false, }), ); }, theme); await page.route( /^.*\/api.*$/i, mockResponses({ groupedProcesses: mockGroupedProcesses, }), ); await processesPage.navigateToProcesses({ searchParams: { active: 'true', incidents: 'true', process: 'bigVarProcess', version: '1', }, options: { waitUntil: 'networkidle', }, }); await expect(page).toHaveScreenshot(); }); test(`filled with data and one flow node selected - ${theme}`, async ({ page, commonPage, processesPage, processesPage: {filtersPanel}, }) => { await commonPage.changeTheme(theme); await page.route( /^.*\/api.*$/i, mockResponses({ groupedProcesses: mockGroupedProcesses, batchOperations: mockBatchOperations, processInstances: mockProcessInstances, statistics: mockStatistics, processXml: mockProcessXml, }), ); await processesPage.navigateToProcesses({ searchParams: { active: 'true', incidents: 'true', completed: 'true', canceled: 'true', process: 'eventSubprocessProcess', version: '1', }, options: { waitUntil: 'networkidle', }, }); await filtersPanel.selectFlowNode('Event Subprocess task'); await expect(page).toHaveScreenshot(); }); test(`filled with data and operations panel expanded - ${theme}`, async ({ page, commonPage, processesPage, }) => { await commonPage.changeTheme(theme); await page.addInitScript(() => { window.localStorage.setItem( 'panelStates', JSON.stringify({ isOperationsCollapsed: false, }), ); }, theme); await page.route( /^.*\/api.*$/i, mockResponses({ groupedProcesses: mockGroupedProcesses, batchOperations: mockBatchOperations, processInstances: mockProcessInstances, statistics: mockStatistics, processXml: mockProcessXml, }), ); await processesPage.navigateToProcesses({ searchParams: { active: 'true', incidents: 'true', completed: 'true', canceled: 'true', process: 'eventSubprocessProcess', version: '1', }, options: { waitUntil: 'networkidle', }, }); await expect(page).toHaveScreenshot(); }); test(`optional filters visible (part 1) - ${theme}`, async ({ page, commonPage, processesPage, processesPage: {filtersPanel}, }) => { await commonPage.changeTheme(theme); await page.addInitScript(() => { window.localStorage.setItem( 'panelStates', JSON.stringify({ isOperationsCollapsed: false, }), ); }, theme); await page.route( /^.*\/api.*$/i, mockResponses({ groupedProcesses: mockGroupedProcesses, batchOperations: mockBatchOperations, processInstances: mockProcessInstances, statistics: mockStatistics, processXml: mockProcessXml, }), ); await processesPage.navigateToProcesses({ searchParams: { active: 'true', incidents: 'true', }, options: { waitUntil: 'networkidle', }, }); await filtersPanel.displayOptionalFilter('Variable'); await filtersPanel.displayOptionalFilter('Error Message'); await filtersPanel.displayOptionalFilter('Operation Id'); await filtersPanel.operationIdFilter.type('aaa'); await expect(page.getByText('Id has to be a UUID')).toBeVisible(); await expect(page).toHaveScreenshot(); }); test(`optional filters visible (part 2) - ${theme}`, async ({ page, commonPage, processesPage, processesPage: {filtersPanel}, }) => { await commonPage.changeTheme(theme); await page.addInitScript(() => { window.localStorage.setItem( 'panelStates', JSON.stringify({ isOperationsCollapsed: false, }), ); }, theme); await page.route( /^.*\/api.*$/i, mockResponses({ groupedProcesses: mockGroupedProcesses, batchOperations: mockBatchOperations, processInstances: mockProcessInstances, statistics: mockStatistics, processXml: mockProcessXml, }), ); await processesPage.navigateToProcesses({ searchParams: { active: 'true', incidents: 'true', }, options: { waitUntil: 'networkidle', }, }); await filtersPanel.displayOptionalFilter('Parent Process Instance Key'); await filtersPanel.displayOptionalFilter('Process Instance Key(s)'); await filtersPanel.displayOptionalFilter('Failed job but retries left'); await filtersPanel.displayOptionalFilter('End Date Range'); await expect(page).toHaveScreenshot(); }); test(`data table toolbar visible - ${theme}`, async ({ page, commonPage, processesPage, }) => { await commonPage.changeTheme(theme); await page.route( /^.*\/api.*$/i, mockResponses({ groupedProcesses: mockGroupedProcesses, batchOperations: mockBatchOperations, processInstances: mockProcessInstances, statistics: mockStatistics, processXml: mockProcessXml, }), ); await processesPage.navigateToProcesses({ searchParams: { active: 'true', incidents: 'true', }, options: { waitUntil: 'networkidle', }, }); await page.getByRole('columnheader', {name: 'Select all rows'}).click(); await expect(page).toHaveScreenshot(); }); test(`filled with data and active batchOperationId filter - ${theme}`, async ({ page, commonPage, processesPage, processesPage: {filtersPanel}, }) => { await commonPage.changeTheme(theme); await page.route( /^.*\/api.*$/i, mockResponses({ groupedProcesses: mockGroupedProcesses, batchOperations: mockBatchOperations, processInstances: mockProcessInstancesWithOperationError, statistics: mockStatistics, processXml: mockProcessXml, }), ); await processesPage.navigateToProcesses({ searchParams: { active: 'true', incidents: 'true', batchOperationId: 'bf547ac3-9a35-45b9-ab06-b80b43785153', }, options: { waitUntil: 'networkidle', }, }); await filtersPanel.displayOptionalFilter('Operation Id'); await filtersPanel.operationIdFilter.type( 'bf547ac3-9a35-45b9-ab06-b80b43785153', ); await expect(page.getByLabel('Sort by Operation State')).toBeInViewport(); await expect(page).toHaveScreenshot(); }); test(`filled with data, active batchOperationId filter and error message expanded - ${theme}`, async ({ page, commonPage, processesPage, processesPage: {filtersPanel}, }) => { await commonPage.changeTheme(theme); await page.route( /^.*\/api.*$/i, mockResponses({ groupedProcesses: mockGroupedProcesses, batchOperations: mockBatchOperations, processInstances: mockProcessInstancesWithOperationError, statistics: mockStatistics, processXml: mockProcessXml, }), ); await processesPage.navigateToProcesses({ searchParams: { active: 'true', incidents: 'true', batchOperationId: 'bf547ac3-9a35-45b9-ab06-b80b43785153', }, options: { waitUntil: 'networkidle', }, }); await filtersPanel.displayOptionalFilter('Operation Id'); await filtersPanel.operationIdFilter.type( 'bf547ac3-9a35-45b9-ab06-b80b43785153', ); const errorRow = page.getByRole('row', {name: '6755399441062827'}); await expect(errorRow).toBeInViewport(); await errorRow.getByRole('button', {name: 'Expand current row'}).click(); await expect( page.getByText('Batch Operation Error Message'), ).toBeInViewport(); await expect(page).toHaveScreenshot(); }); } }); ```
/content/code_sandbox/operate/client/e2e-playwright/visual/processes.spec.ts
xml
2016-03-20T03:38:04
2024-08-16T19:59:58
camunda
camunda/camunda
3,172
2,138
```xml abstract class A { abstract foo() : number; } class B extends A { foo() { return 1; } } abstract class C extends A { abstract foo() : number; } var a = new B; a.foo(); a = new C; a.foo(); ```
/content/code_sandbox/tests/format/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts
xml
2016-11-29T17:13:37
2024-08-16T17:29:57
prettier
prettier/prettier
48,913
60
```xml // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // // path_to_url // // Unless required by applicable law or agreed to in writing, // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // specific language governing permissions and limitations import '../../jest-extensions.js'; import { arange } from '../utils.js'; import { RecordBatch, makeVector } from 'apache-arrow'; function numsRecordBatch(i32Len: number, f32Len: number) { return new RecordBatch({ i32: makeVector(new Int32Array(arange(new Array(i32Len)))).data[0], f32: makeVector(new Float32Array(arange(new Array(f32Len)))).data[0], }); } describe(`RecordBatch`, () => { describe(`new()`, () => { test(`creates a new RecordBatch from a Vector`, () => { const i32s = new Int32Array(arange(new Array<number>(10))); let i32 = makeVector(i32s); expect(i32).toHaveLength(i32s.length); expect(i32.nullCount).toBe(0); const batch = new RecordBatch({ i32: i32.data[0] }); i32 = batch.getChildAt(0)!; expect(batch.schema.fields[0].name).toBe('i32'); expect(i32).toHaveLength(i32s.length); expect(i32.nullCount).toBe(0); expect(i32).toEqualVector(makeVector(i32s)); }); test(`creates a new RecordBatch from Vectors`, () => { const i32s = new Int32Array(arange(new Array<number>(10))); const f32s = new Float32Array(arange(new Array<number>(10))); let i32 = makeVector(i32s); let f32 = makeVector(f32s); expect(i32).toHaveLength(i32s.length); expect(f32).toHaveLength(f32s.length); expect(i32.nullCount).toBe(0); expect(f32.nullCount).toBe(0); const batch = new RecordBatch({ i32: i32.data[0], f32: f32.data[0] }); i32 = batch.getChildAt(0)!; f32 = batch.getChildAt(1)!; expect(batch.schema.fields[0].name).toBe('i32'); expect(batch.schema.fields[1].name).toBe('f32'); expect(i32).toHaveLength(i32s.length); expect(f32).toHaveLength(f32s.length); expect(i32.nullCount).toBe(0); expect(f32.nullCount).toBe(0); expect(i32).toEqualVector(makeVector(i32s)); expect(f32).toEqualVector(makeVector(f32s)); }); test(`creates a new RecordBatch from Vectors with different lengths`, () => { const i32s = new Int32Array(arange(new Array<number>(20))); const f32s = new Float32Array(arange(new Array<number>(8))); let i32 = makeVector(i32s); let f32 = makeVector(f32s); expect(i32).toHaveLength(i32s.length); expect(f32).toHaveLength(f32s.length); expect(i32.nullCount).toBe(0); expect(f32.nullCount).toBe(0); const batch = new RecordBatch({ 0: i32.data[0], 1: f32.data[0] }); i32 = batch.getChildAt(0)!; f32 = batch.getChildAt(1)!; expect(batch.schema.fields[0].name).toBe('0'); expect(batch.schema.fields[1].name).toBe('1'); expect(i32).toHaveLength(i32s.length); expect(f32).toHaveLength(i32s.length); // new length should be the same as the longest sibling expect(i32.nullCount).toBe(0); expect(f32.nullCount).toBe(i32s.length - f32s.length); const f32Expected = makeVector({ type: f32.type, data: f32s, offset: 0, length: i32s.length, nullCount: i32s.length - f32s.length, nullBitmap: new Uint8Array(8).fill(255, 0, 1), }); expect(i32).toEqualVector(makeVector(i32s)); expect(f32).toEqualVector(f32Expected); }); }); describe(`select()`, () => { test(`can select recordbatch children by name`, () => { const batch = numsRecordBatch(32, 27); const i32sBatch = batch.select(['i32']); expect(i32sBatch.numCols).toBe(1); expect(i32sBatch.numRows).toBe(32); }); }); describe(`selectAt()`, () => { test(`can select recordbatch children by index`, () => { const batch = numsRecordBatch(32, 45); const f32sBatch = batch.selectAt([1]); expect(f32sBatch.numCols).toBe(1); expect(f32sBatch.numRows).toBe(45); }); }); }); ```
/content/code_sandbox/js/test/unit/recordbatch/record-batch-tests.ts
xml
2016-02-17T08:00:23
2024-08-16T19:00:48
arrow
apache/arrow
14,094
1,128
```xml <mxfile modified="2019-04-07T06:20:56.809Z" host="www.draw.io" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36" etag="ivxSDjEtd7Gtab885dqP" version="10.6.0" type="device"><diagram id="MrFCz9NEisDjhpf9yqXw" name="english">5X3bctvYkuXXVETPw+your_sha256_hashYl77ky9y9hf9uc3M5vrtLd5XLzS+BdNr+your_sha512_hashyour_sha512_hashbpr/cYPPcvui4T+98u5/Y7fL6/your_sha512_hashyour_sha512_hashyour_sha512_hash+rJ8I4UNsn109I4Loo304Nyour_sha512_hashOVns3sjFecn13I+your_sha512_hash+dX+x/wNJM/97XK5/wV+O7++your_sha512_hash/+hvIo+PDh3y2OwvC/vS8/3uf//m79Gzcj+tduxn5z/zduRvxqLya72+Jqffevtqxyour_sha512_hashW20wq9your_sha512_hash+XF3d9CJPyJUyour_sha512_hashyour_sha512_hash/EbVg9b+WcyGP5Ng0Vyour_sha512_hash+mfiFr+fz10bywN5vfzzw+Lv0KoHiSnfv/your_sha512_hash//your_sha256_hashj3mK3vuU899Iv8m8YU9/TP4dPcoFHXcyLkG/a+fs2DWHkeLi+ah6LzV/POZVwx2j6fhZXjZxmHaxo/FtnhM17067R91l9tilXy+ul+cxN3oyour_sha512_hash+m+tnn2c3s+2V/EZZHybpXpv2enw2SEt/LM4LZ9y/your_sha512_hash+XBmleL4GqzuNhcLbbZ4+xk8zBr4/VCjr0I7jeXJ9lOxty/fGfjzb+f3c0mMjYsP56GZzeXJ83m4DfV7Hu2/lpl7ezikze7GJeXwcab9/dze/jaP9LfHI67mHUvPtP/Pi4wt4tP7Vn45UrmuVlcj8vlYCh7Nq2/nCflcoJ/9zayZ1G6xv7y3zH+nU56/M38YnyUbJubxfbbVVFdtvnF2c3sIvZOJwf7+uw/oRlvEfbKIjx7LPq+7E3zWMgzE292clbJf6vEffdYnHxay97Eclb16Xoq5320nV1nG5x32p+uTrtom4RXV6P25Ttk3Z2cXZ3ou+7z4OhuESZHySqt00EP/63cdwuRUrns5XKCZ0a+rPFxtp11s++ytvWwfu89st+gy03+/cvnYvupml98e7gcvPG7z8dCR2U5kzlPJlNP3hGnXXonexjImsLs/your_sha512_hash/N/Sej80GY/90XcQpfrcuZO8rGVP72WT4MBpMm2Qo/x4MH2Te3elg7Mmcw9GgkDnL+jD/your_sha256_hashJ3sUZVj/ZNhiv0b9ugEfZjq3h9GE+9ZkbaTr53yLOGvrFs8WXi0vVsdZus5lj5MolXXouCSUd8mzKvn3WNZcYm+atMW7erH8O0rPay/jb3sBfjs6jwJZv/w2lbnk3Qjvk/HZuvRlDl0m70s77MOwHvWjZjQYyz7k8qzc43wnvUj2WtZTt7LHD+kk5XPlNw/poJB1JNg/oY8xniHribx0MJS9GcszEn/EfUjkGWUr65BnFLKXiT6jwzNk3oPEl/your_sha256_hashCmleztMOYznvazTTuRi4MUdCHPGz4InbZydq08Q+RFYftPOvLkyour_sha512_hashyour_sha512_hash/KJ5kg794/USkmudgmp9eXKdriDVMki4+xS7D+6clELN+HwWyedtilV1onHkO0jd2XUlksxrOFM5bTndEJ9Digp1yqpkfNdrMj77SSp/+/your_sha512_hashP9v8NgB1PH1+qe+743d9T75LOq77vAYVtVzrqpI5biqZzxv75XXJ+s9K+Ey1SJX/pISHVnvzBE1Pqi465ttOL7LHhdgEcipr0yO1PM2+O6rzi+zm8nOFpz5kciKLYLYtRD/D1pDfvvemQf2oa/5090wbv01VtezmLjmRmVeeD17K1qnQai70KbK0yz3qiHUuvFKEkBUi/your_sha256_hashCd8mUajQQmelOfKc9ZDUEpDedRVQjmlyA0+F3KvERllY0uR5VUtuk3kWi+ELBW+D1OhBJFZkfztCw96Ig/KcXc4VngT8niSB/LcCDpB5I1PPbqu5O8K34mM7YXZCvqnELkwFX4WfQ+92WGtKZ7rUe51iTxbZGLXg36RPethvtDBom+HDeUGvysD0RMi73oB9csgET1a4DuRI0ktc2shkzPuG+your_sha256_hashyour_sha256_hashPzljMQySLzzaNsknp87iqKRbfKf2PsFfZcaCIRqTC1MxjL3gxlXC+kzp+U4GIfY0UaeUJjtby7FD0uUkjOZJ2L/your_sha256_hashXeF0NtUziFv8VyZQyO6UmhoKLZDEoo+Fv05xd9lthY9LfMTKddmHEtdJ3uYeskA/your_sha512_hash+CR3ijEql74nYnm0PZw2+iMFT3GexH+WsPdkDOSOcZy77keOMcUZCs8Jb8szsXOYvdoDse5d1Y55RBvtlMo5kD0rR+your_sha256_hash1Gn4z0hbBFZj+jltJE5N9l62omexZw98Kucc5CBJrshyour_sha512_hashG5LW1T4fmsL/wBO3EwBa/7fK7sk+yDB/your_sha256_hasho5S5mP0OkAfFvyrOS9NeVYJ7ywrkLYPiOZk6xN+CEVOih0rOwL/pb1lDIP4fFeB83P/your_sha256_hashtKmyErhR9AxbHfRBUJDscoa4dUulXmILT0A3YpFI7JRaNfJC1/ORfZXzg52nKxddEZrssYDL4uMA73xt3JmIm/AfxXsLZFDIiPOjd7E74AdDJtVfiPyZCr/OxQbMAW9CT+IRQFeAo+your_sha256_hash5JjIEdj5lBn47lLXjHCobmyJmIfKNNAV+Fn9hGJlyour_sha512_hash/nJeyour_sha512_hashDvXFOuoA/Fpp8iyg7xK8QeUG/4eDsjdZFd8q8IGvob8p5iNxtqe/Fh5V1gc4wL/hbMm/xl5Um1a+Db6VrgkUb0P8QeYa9S2EfvP6ug/+VQo8aH4gcEZk29Iw34c/BVy/JIyour_sha512_hashQzWuRmSpruEdCG5C5oHPK50xtGz4rg04Gb8JmAp/bHoJ2Ze0your_sha512_hashUn66MK3wisj8uYUPqHIWsYQZH+h3+Scxc41mSBrhP05hU/bQEbI2Ij7QVkl5yL8qD692A+Q68ITKm/your_sha512_hash/your_sha256_hashct7lL6oo9hyour_sha512_hash/SE1k1rMGfGWw28idjAzJ2jLgYnitryOHX+/v1ytqFTxryI/jP2SagA8gH0RU6LsWZmV0Dv6knNi3sy/your_sha256_hashyour_sha256_hashkzFF8B+hS6bmiyour_sha512_hashcN2QkxM7J8u8TV+your_sha256_hash6Bbz4rNkPrRPE7P/xE4Bba2FN0S+ITaF58LeBm2mtNV5BqL3hJfWhY2tyM8p9mKdIpbXqB7k2BBxOdiKMp7+I+QSz2cNnSK/your_sha256_hashyour_sha256_hash2PlYjCiU1S8DvSrcg8fSflpdC87IjRC+0Z+GbqH4hPKXqTNhfpBX50QB+M8x0jLikyirxFfy7DPPum0wdT4d1hx/e28NHEF6Jv0YMNFtN+IT2N1d4Ue5s6EHYt9WtJekoRk+hyX3kWcrgkD3Ctwi/QHWIHGc8W8O0D8t0asfu8Jl3pcxv6a5Ncn4s4ttgzo0litg/oRWwj8PsaNnEOufVk+8h75O9S919kysT0DKKRQk8ZaMLFuelXj1t7r3yXByn9LJ47fPDW7Bv44J0+S94L+qI8LanPKZOEJ8XWtPeK7TMQ/your_sha256_hashyour_sha256_hashyour_sha256_hash810B1V6axpAYygnNjniYJU8ZtxF5gJB9n6OKUIj+4B8z7wB9qGIvrq80ttOEjBqTPLrH3sp/k7Y76uBt3mlM5fHaq/your_sha512_hash+rbZPILwlvJ+LHe1iWWkEH1ltfcb+RNYnKp8ZW0hgn1P2C60JLQjtKi106ivBd6/AE4jNYv9apYUUvi38xA48gbEi6yPKDpzBinrDhw8C+your_sha256_hasht/GOY1rjUmVyOcKXyC2CXqD7qmFNnoYK3I3leciXix6YQB7Rr+your_sha256_hashtwn1CzFf8bvnPt30CnfsaixwiXix2b6/VWCTkzjigDOP5IVeAmJPYvn2lO9hNGXwb5herB+your_sha256_hashOFxtMB/cbS9ll4voh1LPxdkWuio2Uyour_sha512_hashGDKGJH5R3L+e98XeWHo4kDzJ0MPsVHkgnW/EN8QPY48FGUufV0f8WbhFcTE5NxAi7Q1kVtCfCKGjqA/NBCdRjuItrHIfNHZK3zHNYE31TYWuT+irUm7GvKVtqTuJeU+6ANxVMQaYFuqT0bZIbJIzn/Ed8IGrHyjjY70PRA+YcwksVhSXutz0wC2GeKKQrMt4lDiIwu/your_sha256_hashe5GxXJEZHXlXY9w+/your_sha256_hashwN6ZGbXSxUzwPcCB4KYkIzFueLfNTEmQivEjog+your_sha256_hashyour_sha256_hashyour_sha256_hashRfkt9gm+neO752Mj5CpHiP/wfAy7Ij7UyOS2rLshNkTHQobFJms6lXEiW/he6JkSMZuQtHgeqS2yNp6FHQdkAOU2zg/xSNC78izj1CJXeD7UO4ilY5+qVvXy0OZUIQcdaR52iHic0GIZKV2AZmCbiV5v8Vzog6Fnyour_sha512_hash++8Muxqt9A5z3yj8XlW+bQKSsqPF/your_sha256_hashyour_sha256_hashgfiNPe1gE8YaIh89fHufy/WWwqS5PgLQcAq9yszipj5Jt/LjYTt3f98X1t7vZxFvNvs82i+1RNesnb2Mbrm3OwEG+your_sha256_hashxLPg6MEhVIg17SflbLu5Wwy8VdIV/nidKWbx5OhmcX3WAbEj5/your_sha256_hashlz6S8LHyBGOnwfC+lwLCdHd8uLy8eF4ZeInlkdbyour_sha512_hash/sI/your_sha256_hashNytx+iARyaM7HxefN9SKIHPpVuGj8RPvEH2UnOJHks+7cbHvULoT+X+ChNBrlP1EmLS1HqU87Kbsou/zGTh6M73udouqUun87B8L1+your_sha512_hash+5fFdfJdR7axVas23R9Ef/NbO51s3O3+i6mcoLX52+v2LvziZyrl9C2YX8ePsZAxEOhHmo+1VO7vIcYYmNZM/4qo33vnFL7b1LgneREXf/EXzEGle/your_sha256_hashyour_sha256_hashhHx9okMxdgVUQ7wTGQsMt3gavAJxoI3htDaYhFNEU2PTXLC+gAaFh53A+your_sha256_hashyour_sha256_hashyour_sha256_hashyYM1BUPZ/aqw+voce9NEsNyB6iwXXfEKmS/your_sha256_hashyour_sha256_hashS/HphZhQlQN3lABJIZZ2KXsQRJx/xlVzRXd0lerM4MnOciBuga6Ghkz8EhkPACEpgcvZ9zltaIywH+l0SqtW6DwAiKUux6yV5HjAWT3ZQ9KtUJKZLGAvO+your_sha256_hashoSKBNkWFC5hlou9Z5mpVYweMyY5YLnklq54rvkgYRR3muR+your_sha256_hashjajFEkeFeMtvhEDk5cFGiMTKtPNDqieBN4H+Jpk54KosXFm2oNnRkzCwxUvTwbNAMPHUiF18+eEgGCfVXaGBPJhIoLyk6ReSOiOMgjmHeDagOg3HhGK0Sv0kgslwBZG+ELoFDw3EDRqohQ9gJanMgYECXEcR0z6x3k0BRZM59RBD0/X61MeZbwNCwyINpSowtFTgB/your_sha256_hashzMVkAtaHyGApZ/your_sha256_hashyour_sha256_hashxEs0KHaiZExyKSBvy/your_sha256_hashyour_sha256_hashAFEke+xzL16PjRktmIi+BkIdkfLJ2HvaY5zBmN+JbO32UWlGn+your_sha256_hashAxFGd7OQa9AllFJDwy9ECJGg8hyljWho4GGgW6vTH+Q1Qj1EgoUfWe6uShyQShAfzuXMbCDxC7IgWCHp+pRwhkeUnEM9YI24XnDlsLCIM8IP+8HBsQ/c6I2lhR2TzXJKQco4xHJBNIVtBbKXILaBzIKegdoopj3QtkfREFKjvl+your_sha256_hashZeGCGXhZJ/wUVkrEhy0RnRyoPNB5DMPkdVQ+h8iamhyApkVkceDsWf04jHqO2GEyGelFnS36HjlqyH0BFHEKu+Q+your_sha256_hashX+nQ5B1aTPyOtBLKc4m0DlhPWOP+your_sha256_hashhFGRB52CpDloaILYIcUnp0r+DNSm4X7j30S/ZsaXwntD0qPVQdApzBSVpmeBvIdaFxktSpkbFqN1uM7ZB/Fz6BdQV3RImOqtJ8wOgA7RGmwhE0cmQxvuC+yDlRvjBj5JeolNJmHyCt0Omysg7G0eeU9UyCcAkUlAanFs/GIqgfNgl7WsK1LyB7TZ+DHpAbNvkHDHjMgsj/IAKpcAwoJ69Oxsl+yb1Pf5L/IbET+your_sha256_hashyour_sha256_hash0wxgAxQlxwKZjyyLjc0ol/I44XsLIBUb9UVYVYPoPrJXgxGRwUQX1qRnIAmgF+QdMhbR6Ia8SnrO1Y4W+your_sha256_hashyour_sha256_hashshYZO9CBlekG/AWjnzOgKPjv2mXaYZjUQiQucPQRUaEY/llVfLaP3A2eHoeJK7F1USR3OSxGvsMM72+d3+eEJSY5qGVmn6U52JlijyiqNFWVAWer0AmS5B30z0t8iE+your_sha256_hashkJRuyEMTggMZn9o/0fGOK0VSQKMixA42Bejj6A3ge/4r2MeQQq+/FcIH2QVWQljezDNNDKZXmuVm0jY6SIb/iXoi+pz4FqBH+your_sha256_hashK28NQbdacSJUMmU1WSCEjAt81d9/JXg/1ufCDRGdlqELQ58L3AfIJz8UcgNS2qj7MiVkb2MIYi6ou2L+ejfWIbmOFVAm9G9LGtn0gwk58PSDUkfEFCijDunVsQNQidQpootC/your_sha256_hash5aRmv3oaFwOd0m4D70KnI9M07YjGpd3JysHIqhjfONuKSBrQl4yF/kAVF+your_sha512_hash+your_sha256_hashSDfWqVxxFuAiHfyour_sha512_hash+dToLJM5H1l9nsPCINIK5kgh4G0HLbuvUAayTwiO1vEMGB/mvyCXJT/VqwOiVnNKTLJdAViPbEiSiryKStj1k4GIX4D/Y33stMC0FK+0jL8Y/hF41azNj1URXUa26LPAb+0y1av5UXKuEqPmVyrAAms+your_sha256_hashTthfCt9NRb2OTJPa0MLMyMNP4q8bVWoQLbkrjMEbMvAbJiQ8VUg/your_sha256_hashyour_sha256_hashMdODtQBus8pbaleRN3XEo0UagY718w+4ojahYPZbyCedZ8TrZiYpFbhQ/81JFpoQL9OkSaKstSKIdHnGktUmmYF/Pkbz1b0qo+4rD47VRRVR+your_sha256_hashFIdr6txbVrIqB5vkDRFoGN7VjFoNUy7/OCoiAbxqKA8JlMn2wU+HREkCDTnLT0iZzdDTRTlyiaH348/BrGt2l3o/your_sha512_hash+MkDRYtrHBX2asYqH6LWEPdu7TvsY40YJZ/your_sha256_hash2QaWj0gzkM7oDYW8d/your_sha256_hashuKTZ4cqoMKqsw7HMp/DqmkbK/your_sha256_hash2g1Mq8Evqi2fuHtIfHyour_sha512_hashB/VMlo5RYq3Ile9VTGwdYrYJtYdd3Q0Ktj1SVqM7ea9+OzQ+oK5hPRGYPVyVZ5cnB+6NYBmwax+sHBPnWlou4n1DMH3xW071JWl7uKP1SPDM2eS+E3Cs+6qoihdmwwWmbMgxUw1b5qhZWLSjfMvwE5rdVVyPHQbvGcbcscFqtWWNWG/your_sha256_hasho0NNbeHCktX8ZVG5p+FipZDHBK0mrAyIF2brYezRUWU2Jvk25drVV8f+Srq3MRVHBNJqF2OUCFf+lbJFNGXJ/+your_sha256_hashyour_sha256_hashb/qr5SgHmpDpC6Fb2c4S5Ka0h7oL4J587YpU6fIS9TwmZ+your_sha256_hashbLQ3UErV4g21c4cNhYVBw53U7FiZ6RdI5g3gd4zhGmjvmKpCEZ29skpP6y6B/TXaGUQYojIS+your_sha512_hash+QbMgNLqwRlARoH+xK5R/oEuox3embxGt65G0ffgH2A6Uu+JzvNWEbz4jtWRkdIxY1Yh4your_sha512_hash/GqJrjJ0p0PiIu5HODtYJfYhY6tRVAcJe9LVypjCEqNBp2zuU0yFxCOJbw0ZS/wpIenRLMgwNaI15/anqAcQlWCkzDk0ex8QtaOe5jt14EM82+YVOQsA4aLc6xEiBiHWyuhJ/your_sha512_hash+0ysiQ+U3SWGJ7AmwA+your_sha256_hashr_sha512_hashI59N23RM3BP1uVWElFrZowhVz+your_sha256_hashNrvsab2NEl4lr2+zCF7KrVVqs0H4z4C8bSVgNWx43tBVrBj/kidjN12AR2eCFeprN9oD+CbluF7QNjV7E9t061ysy+gz1R2f7CV0lYRcb9ZS4CPr/your_sha256_hash7zLm/your_sha256_hash/ExAP0x1la9Y2TzWam3kdobaXWeF+cN/your_sha256_hashyour_sha256_hashjLMA49LTCkFWObMym+u0qoJYKx2mWhU3UJ2iHWtQcckKQZ+oePrljh4Ryour_sha512_hash/7ywrpvDPe9JT+poH6OsSoAiNZq3yDfu2x85k7m5S2Hc+go325JoaRZz4CtkRj8ZF2ZEGH56meH+your_sha256_hashSH/DHSShXh+4rrUX4orIqPnZrip+41B2OJSQKe0HV5hX+KLkjM/cTEiDBnQ5nxI76lf2cxPMwlMLrTKial94DV0pMqVv+wJJaOPhL2i910K1brmC4BpjNQemcevmaHiVZlM3xf4m1YEQtZPa7pw6jcJ64EeF+tiK1aVutjLHISg8JwEKy2hJ8VarcQxvDhx/oqixi/A/4kdPsFHkCls76XeCPEHVXfqH8I+6JkRSK6JGKefC/your_sha256_hashuVC7YOHZS8omN5XyBo0GnmQR0pd34kAOjjcpqZ1RWeak9l/icSW7fVQG7FLb23YQdRfVc2XUy9zSfyI5tWpF2rucKTBU7/Og7MddYq4oZ427ZTdGtc1BF9BtZYc3OjLHlsWNW5KKLhL0X9lyG7pA8G/jbqKTM3bk2wKZoDLBS+QEsM6uvYfMDA0L71rpmTrGnbj2od4jUXqq0MhGy6rxnVd/ACrDDV2yd+your_sha256_hashyour_sha256_hashyour_sha256_hashxWseM+oTxmzhZyqnbxPGU9gB5OAdDCBr5M7GdfQTnouhzrYhNzniOeJHOW+ghr2g1Yimx5CVWpgvFXTD+qczQosWeEr3RAjCIyk7+zdlF3OHc+iM5rizlg9OaBebawyO2I3BtUVETGBE3bjtL0AjzBPEhk+your_sha256_hashgFgr84Ch2WkRY/tiM5rdGmtlaWXdFSC/IWNzoznEMXAOZaQVuuATxFTgG4zZpQoxBbPTI+your_sha256_hashGjeMxBAbPQ8XwjjYsCG5PjvZ3i03uR8hHiZegeXKKrvb4Xf6vPHDK+wu6a6ITfUwwKa1uAPS7VPkQVMKo7ma8FdoMyJSStAC+your_sha256_hashkqrjKrsduEOqnMGyour_sha512_hash/your_sha256_hashWgDWOKp0RX0+xj5CM/your_sha256_hashdjjr7DpXPDW0i+GzYf2J4LCcudqbKm5fjiAsF5vG8Z+8bM57J70i30H+your_sha512_hash/xmuD9zxK0GQ8dX6OIS6jvHrM9C/nL/TuL1hlpVz1xayVoHnS+wkNp1jfTAeA+wKWPr2oD35kZLqP4e+3qeFXU1600cLe3Hcg+pYxSTpPJL876VnQ2qTEvtLEEfIzccK20PdAnSynja+your_sha256_hash3lB9iFXy2pz7YDOjrRmu3SsfQtYYYsOC/wbOpfYDqyBeRKtYkfn2cTtFTqdIHevXThWzPsjn670NqFedJW7sfpb+G7IGIXojOb1d8gPo4avZDxNO/your_sha256_hash5NvUicJiv2iXGADe3GIoYYa5dIxdqgJlDkE9+bArODjkPsQKA+gOatx7V2rGP1sXVFgJwD/syNRe5G918xjAm7Jdqc4Gu2+your_sha256_hashyour_sha256_hashG+cAU+nqBnxlAcq7fSOzlwqD4D7N2zrMCaPU/your_sha256_hashyour_sha256_hashyKpx+sWIdY8fYOT19FelOByb+Jdl5DzNPpCGDZ1N+AzkaHi7xRnVWS34EzcjQ1oi5lDDYeaa0TdFypHVJQj5GGmY1VnU27Itbaz8ry/1hP6rOzodqNkda4oEbYxrK2kB1wSHOM1XTO9wL+omzd2bOr4dpsHd7Igjruqc1pyJsE1H/KWedLDJxbDzE/your_sha256_hashL/your_sha256_hash0Z8QaEdWVjiSNtXPcW1TPDxvi+your_sha256_hashyour_sha256_hashtoi+xOF3Y/VDnI/zg3PXm43YERdyWuNW0KnUWRzfUu6BJic6L/ra7MaMOHti3cOR33UyBb7YkDeDwfZgBzLYBnsfiViy+M1nIx85gR1S8tmwz7C3puMiq2vhjQkH8/your_sha256_hashOHnmLgODZit0XkVzmnAjgIT8+fnW1d7UHLs0G95Jq6ip2r2WGtK91ewq9HvPEOuCB2ZmT8nHtpsXfT2+ysiJph2u/sypWxsyJ1TsPOaRN0601cRy/2QKCtoZ2qAo1VJHqmqCPU9/KuI+your_sha256_hash5UZrgIsyMavckFMQbaTZHKDPVT1I5D3WaiNKPdj0PFRles/+your_sha256_hashNSu+your_sha256_hashaIMQOvXgLjxQ79sDVWxiPIaa9LPYOXYxvm7ljPhpgO50zeRidGvdVs6rNemrxN+gRvt0qPeBZvt/FJj/TF0cUbMUj0okD3sxR6oGSXf+your_sha256_hashE7Sya15mEL3kpo3Yk6dnVUeaKxJXTI7bv1IOyour_sha512_hashB+your_sha512_hashyour_sha512_hash+6WB76mmjMe603CBADtDL9yfzasNN9rKgzR6yFUR+CuB1gnrne0ifeznyIEfsjIOad7G+bQI2b2hnonFg1Sqtcv58y72jvBX6INf9JrfU7Y+JXdSzih3nD9RBfgBr6qWd2BrBknfbyOKQpjCVeWjuf8+zRHwH4NZNFA9bQe3b2HnOirdPJ6OPSC21OreutoD4Rc9O8UUbpArXc0FXOTkQ/kanjr5hYlklpYxEfhK9PjOhDql397Dti8gOLhx+efaP1MIhrjlUWqR/KvJzpZOQ5u9F+n9NW4+cm59DvYzD1bE3EXiMuoGPH2uW7b/us8ZbA3hs+your_sha256_hashu7HRHDCq7EbMsZbzNFpGXnnc0gdkvQ9k/NB3tDzi/your_sha256_hashUam357xJn5b+bylj/rt4GxpmyMWPnR65vnYmrKnm4rOIG2E2qMkZ0d7w6lCH/K2DOI+your_sha256_hashuZw9a1d0LG/ZQi1v2lpuCLeXsCbbYsvoQWb410J9Qu399GqsdvmDPtSxKetEC4cPUsy+2Ii6tpL5fJfPwA1VQoPIyYeakwHWVHOGiv9gP6zy1T6p3808rPYfwQ1owM+nFivHuKk3shp+your_sha256_hashur_sha512_hash/0mit/8xDsLuqg4z3WosWm//e7ZPodbaj3GDI/u/your_sha256_hash0DFuvEFcZOgwcI3dKHgoRyK9GQadqSHriY2veSaaszV8Y8W+DyPt19ZZF1TmMNE7gb3eXJdu7ZQeWbfzzmgxZk00cOist2IHXugu4WGtZdd+DInDJwaMl7B3DGtnEQNQTAPzlfA1eXPc67Hkf3aE1bGsZdd+Npp3Qn+qoclFyuVYsZrAAUHXVuz7cLhW1spM2GesVLxxj/nJbOXoCbYS6jgP5Yj2WtAaCOv7AHwSMb7V/tkZ64zY98G32xVawz92ehtJpTfpkYbYDTxW/your_sha256_hashhm92SynvUhsgyour_sha512_hash/lqKx79itXuNfZawd2dlrzZ6L2sQCOCbiJ1gT240by336iiMclyPaD6RP0wO4+UFvanr5HeWx3jjLWw6Ze6UtqPQ21a7+ituybr+oK6wcrgT8jZvzcO4x+your_sha256_hash/Jiracl7/CWi0xrMbB/nv4WOcepYVmSQG986B3ScKzxIrX7Dvtp6K2LiHMgTlP/your_sha256_hashFj3LlxNL52tvk9fPZmxrwC73eLbeVIFacWIx2PPAZ12M1Uq/mDdj28B3ohcBvkN9pyour_sha512_hash/WhAzpfTMG5aI83K5V+hI1M3aXnWqv10+BDGoUm/your_sha256_hashbiDWnVpUa5+WNsS530OqNDcnr76j30NevsNtLgQOv/CfcYuHbDRTstcE+JIPKYdlBy9YfkLION+Xq7dvU44j/JvubT5+9N2KHcuacqjfey76S7GDyour_sha512_hash+fF22E80ISTSbCPrX6w0Rs8YG+l9mzejGa3RPFmt9Bup4r1pohppLm/IePQwMwr78Keh/xNtY4WGDnestTzLS4aqs2Bsazn4q0T6T6HjVtF9ZYivRmpZO2FYhuQC3E1/YdjiV8JWMeuY33e8KNYJZ+1L+hj8aoWTHMlxBB3VgsGO0/1jsWg0Eeop7WJxJZTrnWWL0bPEMujvdhjzbN0iCNZ74RndbKWZ4nt5sVGb+1Cv4jKxU2AedJboOhno6eIxpCob3FjJe24l7Wwuk+ovUnYJT/VvG3MOP0+b4uac9YtNuqHJrWjN8ZyDBv8cmxqt2Yjp+jGVsDfR095v6HVbCdWqzt2mB3YC7HhIlyour_sha512_hash/your_sha512_hashyour_sha512_hash/aIbEfGN8TxAEOlsUzts6oyxHInlcXJiAGzG7RSkz/onWI5SOYS0H8vN/your_sha256_hashgja7fCowfdvvYW9aWx1qQR8xNC3mttJ2u/fLtBJSZeH/1ntIfKgZzmbxveZOBuHUWcAPpVMQI+cX2I0+xv6aRsNsw++HLK/Xp266LHGkeHfUN9n9X5aZ8h9ODc66cg0x50kLmB3ho59Pd2AG80rAKrB+your_sha256_hashoYl1YPjpheYli0krkk+KO63pdjR+d6I6XdANsSm8EbD0s747He3Hnu9hIxWdgXhrXRWw+a188mfyJX39nNta3aVONWY9aIH0IfFp3q+your_sha256_hashk+P1eF7ef6IezGGcfBek3PwGdJwX8M7YL2pyU/QWU97U+A7yoY9ThO3msfuO/Ta0pv7+F2gdnehZ88aK+6r0XOCm706rWVmLQUwaw7zh16VoWKwSI8x+5C6ugvUUjzhsFm3CjzFk15FfGZsNSope8Wn2gPE4vPAGPS0X01XsoZJ+your_sha512_hash+Gz10S+u5gRrECnn0WPFYvAEbecH4rWcr3mz6dJPivi6jsHwk8DvQwaz1fDlv9u8F/fCGWu1NjXkQS4Lc7DByNxtlvGkFtZ6KM1B7H/HaSms92RsE+your_sha256_hash9B4z7UHUecaC46bPUOjbm/JF30XyJ1r3z/gGMZfwj1Z7dlk8eo86YdbGszUSclzKNfVQiYhq1tvXlWOaKgP3J3Y2StfYWHz/l9KGb9jdK9tiDX+USe+giVmF12kPqeNzK47BCqcYt9dkv5sUcns/eAq2ruX2HH5SXPdqfqCNWXW59GaexjY+1n1jVPOGNoItKVyPOGJDm6YaKHWEvddJ0rL0xcFud8gvrKRhHY+your_sha256_hashyour_sha256_hashLqOAdgSZhHQK5H8fbsHcH8H/your_sha256_hash3Vifkxf10JY77KwnodZSo78JZK/mDnm7tt5Cyj7JNe1ayysip2P4d5+4W/your_sha256_hashGnB/zBPGlBLELymj863naMGqzVG7zFmNMwfJKvkCG4kbrHfDN9HPSasv4MP+BbqzlTfJPD+1hPssjVKmoOjXX/dvbEvMZaVwZyour_sha512_hashSWe6ryJrVSbwuF7cWMr+Yt8zL4o3CviQRDDTa2+vCTen+e7tp5XHe6WYj1hx56QlEOJYRqBHeR6au3nmqpsxp5qXxfPaiBRB9Iq/iWBXmKcW2sRE73dV/E66I1SM2aufjPr74CRQA9Z+Im6b3mrNZDsgYmcXmRjO9603rk6Xr7H0/WkxBbYjZ08O2LC2NdT34v+iDbWU/lR6Pms9ZbYTG+d136IwDZTTyXae3Ti+ijkZhfmjduLEXJMk9JqeXPrX8b4T8sefozXplaHWinuku+FL4rYLW8vD/Q2cr2tGf06TnlnxdBux9Y+w5n2ZfRouzL/Nm1c3TLOKX36LrCefQHzxgMXc9Lnoi+/your_sha256_hashyour_sha256_hashrJgN3QufNQzoNTFITRZBTvWs18ghf9FO6Kx/3ouaW8OKwGb3Ukfn78gZtcnZv7x9wrUBF8X7GYxeieUCbiC0NdWsU2X/your_sha256_hashbwvFjbM9lSesSze7mD01kSMaav2r9rMJDSeEPIzPXnbn+3peru/your_sha256_hashTkKefGr3zJs9W/RfkvNmfO1DeZ3067npS/+Xw2Ss+C322uGar1ZD9TYymc70Dy83tRY2f+your_sha256_hashFtVO0V7RdXuxl/2zGSvvaHJtIR5H413l4xhp7iTQZ+r/ZmoN5jrRfxIeXHNnhgd8wZ6U21AHK/KfsWrIOf1VEyour_sha512_hashJp4b+4TeXWv03LXbgNkLA/your_sha256_hashUrnpRWI8ie8CHt8Y76tVOc2VCxLeiBxNg+bo2lnIg11kN8V8CY8X4sIpSKKz+gx479+xlfJj2HGhuCv7rnf/B95Oh5ZH619igea28zu/vB6iLhU4RqO0M/oJ839JDWRaJnmNb7c2wA/ICeEeyCysU/Wu33Ct1u9ZY4766ItR4BPIzaavZ6Jg8hz4taTKU53Dunve2IIULOzvS+9nLAnIo9/your_sha256_hash9lfeNzp/U24JyE3vkUNx1T1OvvBATNOWzHSeDTq9wqjc+SQEX8lf/HW+RH6Cpzb2U/GjNdyLLFwJXJiGKtxfGDDScu52mUaP+i4L+hzMcgdH3h6J2TuaE59AxuL/your_sha256_hash8NQ/YjEV3s2cXsBrAOxS5nZVrhvBzk+20fgdM3PBj3BJq26zNX+vkPjqruRK2JPd8X9r3kfY5itXf0o4+your_sha512_hash+r0UJsdwczHyM6y7Ohg75W33wMrbWObRU/o9aaAxninteY2Bs58ZZatifcauR4vl8dB3Hc8l/jLkvSpaN9zxHkHGrFONfwN/1Nf63RHoi7guPjdizavSY6x9eeAnkh5Dxb/your_sha256_hashyour_sha256_hashlXxm4Wrxna7U8QMl+odZHghhz+07vCGQvhB/QsNWhK49UVvsCfZywZ5W+l/X+1oOKNA7bt9W4DzARnJu3p3HUlK3drfKwXfPYyU32EFT8mq2nZM9G0/your_sha256_hashN/dMzB8rZrV9sLvqta0/your_sha256_hashd7OfmlN2njbBjrA08mwD3ESv/EB3naJxZYCehO3kHkeBI04WsNJubEd2pfD2IOUCcyDG2tiF+12lOXubKYfcBbZyuhz+rUaPzlWDuP2ORTqHEd1NSpXkP82fr5KNYFfQuo36FfWD/VWV0oe9jwnlE7d/AW4xyDg33SPr/sGWz7/zYNk8ZZKxczd8HalSS2uzACxqyour_sha512_hash+riDqasFYV0o5AVzLKjBWPcaHVton+o143oeYo2Yh/b/Y90M+61o3j3VvCtqm/your_sha512_hash/your_sha256_hashkrmesd2OLb23rQZ8OX+l2bL2weool4FjY+LjrVccSLyL628aCl2q18zBWe0a7OpQMNX5af+uxPwriROvc1Ze1mmOobOxY70fY3z8PP532u6c2Ou7nmlo9I2qEy1jnxLwfbE/P1UJq/your_sha256_hashm/OfBTvSUtXuh7UP4+your_sha256_hashEequukpMN7mrvFidH1/lFJH/PbhYn9VGySoOzwWyYVeP374sfNNc23pt/P7ubnSfv3wzyour_sha512_hash//tN7137/2gfpy93Jyour_sha512_hashyour_sha512_hashPfgbe6/MF0I1vpfPOw1J/your_sha512_hash/++2mz6u83ulmPDy3j58VLO8fjuyour_sha512_hashb+QbaYs5fJB16xu5ZfPewe7uSPSzk32auWP7u52d3ev3/aMvFnL3t1rrLf9y8P762znW9W5bX8Wcjclrd/0Xn5H3zHi390ZPGvf9GJyour_sha512_hash/jrt/dLAus+PdVA9Y75it77lPPfSL/vpzfz38Je/pn8OnuUejpuJEzDfpfP4sYbUV4XzQPReet5p/your_sha256_hashhashJv8Il4vgrObxVY+C47uRdzfzr6fref9o4eiTcrLYFNdnsh4FHSFx5E8W8Ztruefx/gszr7zs2B+8S0cb48iUUh1MuiVCNokBH7JM7bf2iLYPC7W3gpJ9WT9UuEk5959MrzcLOR3+fezx2K9K6fB/ebyJNslCO6KoZj0S146lrZVeXp+/HIftl8e5yff7ucXn7CGSvbg+nSbPS7Oj9z6ZYx3oP6+fj67uTxpNl+your_sha512_hash+Zzsf0ks//2cNk/Xi8H3krLNgGXSr0vspN5WMmus50ZUoVox7WR3d++9dvZ9Zu/beWEUJKAf9/MZJy+89PdmZocm8X1+your_sha256_hashadl3ZfjdP3l+OXTcEXs9E2T7mv/6PU+Dt74HUzEz3JGwiXynnsxyour_sha512_hasht09aO9nW2your_sha512_hash/Pv38RJFpOz+your_sha512_hash+z64Wn79tsL9pv6eSBf/bt/99your_sha512_hash+iZ7vnX11+/nKzHB75lyffxDlOHr+u8vXyZPjrW86E7qK/KbaXm8n2qBLH4gXNgMuLk6ubvH3/your_sha512_hash/viyour_sha512_hashK7ZlIGNlPeavM+mpxnW0X4Zd7OJIieR6KoLm6PJnuTieFXuKIIEC/Lk/Zyour_sha512_hash/rb+2iX67f1iqVcJVpysGN47hs6guty7/lt4+X34VTPx8/your_sha256_hashyour_sha256_hashqXv+4JQm+fNTCl+c0uopAHFWzU7wH/jHLJ0Pl583NXhj8i2biKyrZ9PLdhF+q//gdA8oL7sRafETIZEXcqxVuhDr6V6k47v0/Y7cqnNYUify9kob+KCR54jJmKE1ImIwWwu/21obgQ/0UscEF8ad64UeqQILPfcZAXls7INkHy+9QQI2UoAlL4fCpWBI8teuCPFUtMe4e/HbO2qTw/H9Z8/your_sha256_hashyour_sha256_hashA3YuxugY23EcSJNBiLF5cHZ++your_sha256_hashyour_sha256_hashht9MKmoV4khya8oFmCaJCg52VfjcpHuzwEYAptGOUuT/3RWE8LMxCQTu9G2kgytks0tSEMmwIkdwTy4WKA9dSS5WySEgC+L3zqj/SybDTkdRcXIBnF5h0KnCfAyZqvT/your_sha256_hashyour_sha256_hashzmQ3AbGi93Q51v34DoBCKxuWXNS3XZvA2eHS4/your_sha256_hash8oLEDo2meIlKZEV3NUGmHQvFUHhrBUUEe0UAZQothlokw+a6DhRHwCKaO/your_sha256_hashzuwMsqAm1YVeol5xM2j0Wy2zfQ5A/H8pJfJhgxljQRsLHtuRZ8AFg8YvJpSFAOgLkZEz2k/your_sha256_hashBBKcHvMy4C0iC7UppFjFGYAiIAintou/your_sha256_hashvsA/ULGhJqUJ1BZLzjle4faiIlj0RRj7GsBLZvUsbk/your_sha256_hashyour_sha256_hashGFJ/sxi60gbMaCTHi5xgJ05rjmWBPOQTQES43Ktnl6cXjt7QtAUAPl6+C7mnjZiGNYE/your_sha512_hashyour_sha512_hash+EA34suIj6Kzm22P2oVY22bN3yEq+BuLjp78vvSZNf/your_sha256_hash9UJYJTvyDCMILf8D5AWrZT8LZ1aLvdafT7LH4XCGWVeYhfXWFV+P5A/jpWcz54foEbRnR7GOPyour_sha512_hash+c9UHu5ubd1Re76your_sha512_hash+Tv4RfXi1F+m8kPyour_sha512_hash+HG2u1z+5/ruR7+XR99gvf/xtb2/2l3/6Kf/3JH+y0/Ivg0O8ugfXyfRj944v7+OVd7Kor/CPdgxrXZ370EV3hsyv7683ckMfhrz8N6DlhuRTbc48ndoqLi6lT35J170H1snI+6Wt3Kid//nJ3EZf0fCOnoDUPMWYf169M8TViS2VjX9PJyc/vbhePll4nUPu38ErxX19z7wMxcD8O9qdA5wzC2wMW8w7zTpPYgInd/vbvX3PUdH74/5X3Eu/sefPJgP/l9kJzjQ3Lyour_sha512_hash/your_sha512_hash/XnH9e+B5/0pi+JOYyujPE4P8ebvb3T/77kRWd5WKAYdf/D8=</diagram><diagram id="1CEBIX5tpSs0rog4AU72" name="chinese">5b1rc9tIkgX6axSx98Ns4GlLHykSluERwIZFWga/your_sha256_hashhyour_sha512_hashdje5P7q7OK2ffFRmOyF4x+3tw/613U3vlxj89y+LB77qw/xbZ88fSrLj1cfj4rDyT90sk9/ZMjmFX5c3jz8Z6cOdOqns/Wj7Vd2Vsn/y2d7yce9UbR3mOwl8d7+eO9whE8Oor2DT3vJh719b29fFvZhLSs6PP8hf9X4y7bqoXf7/+P28ebiEmvw5ev2avlweXJ3VuHbVihOPrt6uF7b10your_sha512_hash/WW3Qxe/s6n+5qSFRS5vry8ffvQyzmb5x76jc2OPyP7ZPtPah9g+u3pBZ9G+fXhm9F1v5n4+Q/nDjvEPHGn46khfnUkth3L37pYYJ56du597/5mtCoPtrTrY/+/your_sha512_hashFc2+K2PRMQcitwRWbO/N/q4t78PMXRwsDfap2A63Bt9ojwa7e1H/OTj3uEhRdWIv5FRiQkvkWL7Iu69eUqx9gESbBRz9Hhv//DFxJ/2DseQdYnIvcne4SeTePjqw97I2zvw8Yk84fDDswxM+OSDkDMnXM6rR2weHu8d7u/your_sha512_hashyour_sha512_hash6bt97oQF/oi73oclEeyour_sha512_hash+9n++73+9aHnLH3x/k1your_sha512_hash+f7EEd9P6IiLkx3QrY3g344mbxkdrwTLXy8n3jkXJyf8v1pO/HX+1h/0TcP9X5Spf6KceMsjeyUnGIb5elnd/your_sha256_hash6iffDTDY59/PwfLPiJ8duhcokMN2YknlJxcri9vlo/XstB0krzlgf5NbZZ3Tn9js/xqsPxPk0aOAP9+your_sha512_hash+RP/5jMTzvT2PuX/your_sha512_hash/your_sha512_hashbe530f7jl3jPbKv/817IDCx/ykSP3qec+kb8vRCjshSP9Z/Dp/qneCw47Odlg/NvnPFj0h9H5afdYDd7y7PNXr5rcPh2HF+FFH4dZHz9V19VTthq12fhguLiulunnq4fzo3iY3lzdn53GP347+your_sha512_hash/GJ+H9UG6GtXZeOTnk7TG9zJHsPj+your_sha256_hash_sha512_hashyour_sha512_hash8Wp7F3PNvZ1xfyour_sha512_hash/0Mee9Bzq5N9VkPZXBwfx6mB+kya7PJCP8t3XfnIqdK2cvLGeaMfHnHp8X1Ylh8l3dbJe17z5H9Bl2uy+9fPlfXn5qz02+your_sha256_hashmaZidREJnzX02Pszk7z5b1TaulO/ks3E0CB3aZ1m/your_sha512_hash/WP8k2a8Kz5HeYY8j6tssmpYyr/your_sha256_hash5zOuG9d3kf6/lxvFed922Nu4dX6dHmYZ6tS9jiNMnkPHZeG8iyZq5G/C3nnGnvTZT2eNYrl7yg7ab2cvx0F+O30JArk/eW3maylHKZ4nozPV7UvaxhyeV42YB+SdjqOuumkkH0oZa7S43pno0j2Wt6n7WWPH7NZxnnlN4/ZpJL3SLF/Qh8F5pD3ibxsksjeFDJH6k+your_sha256_hashashk448Ob9e3hvvq/syour_sha512_hash/pPsF+F0BvXLPSANTRyhoX8TsYN6dYcMi4kD/SHZyIf7sDLIptE/your_sha256_hashyour_sha256_hash89frs5v8uvz8MuDaF1P1vVYBZ1Ip/ktTjgbmkF2+f4YWk6oSuYOyour_sha512_hash/ekK7+qITPVYs05S9KeGi1N0/Q9KTqokM+7fg0fzoXm0BOZWV6pJXZ7LuDtjzN7y4+N5j1MZcTOQ8W15XoZ9ga8tv3njRpn/SdP92/0MZvU1Uru3mbHsnKG88HL+WrTGi1FPoUWTqUHnXEqhReqULICpH/your_sha256_hashwpdZNJ3U4EmZV+your_sha256_hashQe1MWwO1Z4E/J4VgYybwSdIPLGpx5dNfLvBt+JjB2F+RL6pxK5MBd+Fn0PvTngXTPM61HuDanMLTJxGEG/yJ6NsF7oYNG3SUe5we/qQPSEyLtRQP0ySUWPVvhO5Ejaytp6yOSc+4Z1FMKNja/yiucwqJ6DrKyjXN4rXxX4PIYcmsqaKZdW0Kt1KPsXQDdMZ8LF2NOhjkU+BfJOnnwfiy0A+R5jLbIukVulvBP1i8wldm6PsXImswY6tZN36rFvMrYVeefWKM+RdcsZiGSR9ZZRPss8zruMYtGt8l+BvcKeC02kIhXmdgaF7E0i40Yhdf6sBhf7GCvSyBMaa+XZtehxkUJyJqtS7A9Z0wQ6tAyF/your_sha256_hash7yyhk50pdBQIrZDGoo+Fv05x7/rfCV6WtYnUq7POZa6TvYw89IJ+GUOOpa9KI0HRrKnVQQdv3s+mEtoFWfZ6/k28vs51oO9BK3DfoK9FoD/your_sha256_hashnuyBnBHOs5T9KHHGOCOhWeEtmTMyour_sha512_hash/S57I1oKOp0PCeELSLvI3o562TNXb6aD6JnsWYP/CrnHOSgySGBHxbkOLcl9Lyour_sha512_hash+AN24mQOXvc5r+yT7IMH+6cYajmfGvso55ZirMwltDBJ+3SCcxa7eybPgX00wG7EPJXYhiOx8yI5mwT+J/ahlbOU9QidTsC3Nc9KnttSjg3CC6smhO0zlTXJuwk/ZEIHlY6VfcG/5X1qWYfw+GiA5uf+T/your_sha256_hash2RlcKPoGPY7qILhIZilTXCq0Mm6xBbegK6FYtGZKPQrpMXvpyL7K+cHew4eXfRGb3JGg+8LDIO9MbfypmJvAH/NbC3RA6JjDgxehO/A3YwbFb5jciTufxvIjZgBnoTfhCLArwEHhF5Irwo/JfU5D1YWrQBMVZ0IehcbFShC+g6OTvIfPKtnF8tdAsZC5qCJSQ+gdBJRjkmMgR2PmUGfpvIu+your_sha256_hash9Gzk0sOqGpZRSRb1e6j8oDCfZN9nGHpjg2kd/PO8ohOXs5P3munR/9hznO2tezL4TuYQdUJsNq0bPYTz4XOgQ2A3SF2BXwR6Fna3sf0bFYI+Wb2NazGjwU6T6JnBCZJe+OeT36Z7A3TkgX8MdCk28RZYf4FSIv6DfsnL3RuuhOWRdkDf1NOQ+Ruz31vfiw8l6gM6wL/pasW/xlpUn16+Bb6TvBog3of4g8w95lsA9efzfA/8qgR40PRI6ITEs84034c/DVa/LIqhIZIOc7xnrn0FFC63WoZyvySfyObMJ5A+jYHPsMGQY9KfswxfmeYCzoHHtX9cZfA/ic9DbAb5/your_sha256_hashbR/Jbk/WgGXlvWUdH3htHIneKiHzL96kglwbon22+zBDbAO8Kj1T163OFXJIx4rmYDtkaK+cMuhf+adSfpI8ufCu8MiVvzuETiqxlDEH2F/pNzlnsXJMJ8o6wP+fwaTvICBkbcT8oq+RchB/Vpxf7AXJdeELlDXz8OfSS+vb0r9OWukRlFTybwHz8l+uiHppCFouMlf3aWVeGdcCOFb92pN+J3hXawDl0kPli88hZNLXOK/7pIDYZ5wWP0Sb23byi30S3zEMbGyE2Iu9sYxvhe9ixGIu9guwV+xR7AVk1iC4hXSVm59HftbhL7Ys+your_sha256_hashGGsuoZtqi1XBlgnJCzPwRiq+yEhkVdKCP3PYbORPxgZkbIG4GOaVdyjh1/ub95V3Fz7pyI/gP2ebgA4gH0RX6LgMZ2Z2Dfymkdi0sC/bnbGqwzLESiYZ35WxG+iKYeOztKALjdvIO5L+your_sha256_hash7wbGg2S/EN8QuwQ2O+XOiO8t6xG5k4ivAH0KXZeY7yO+BuMosp8D3mMOG8fJQk//your_sha256_hashyour_sha256_hashE/Z9iLVYZYXqd6kGNDxOVgK8p4+o+QSzyfFXSK/GZWxeR9xjDniCiFHMs4bgM6lrEJ/VJGhLgXiL0VHuyJVOOm0Cmxni2ekwa0FcegC/BVKjQsvgn5AfYPfLM55vU1IiQ8tlT+FHtaeBB6Tubluzd9rnyPffIYxdJ5d8ZqvBfylmNhG0IHwg6hvQ0+your_sha256_hashdCsyT59JeSk0Lzti9EJ7Br6Z+gfiU4repM1FeoEfHdAH43oLxCVFRpG36M/your_sha256_hashr_sha512_hash/Xuv8iU2amZxCNFHrKQRMuzk2/uujtufJdGWT0s3ju8MF7s2/ggw86lzwX9EV5WlOfUyYJT4qtac8V22ci/sXYYiDwQ4bavY/ognmovjl85pHQUxnaPsGG9zRGju+E/kUHGU28JzPP0sR7RRdq34A/KLM5XtYS6T4mjCchJjCljiKvMaJq8g06E76kvQ/iCSOf8gs2mOg2xH/IA2ozt3wf6r4KUeP4BQ+8GCv7JnpXZFtnY0WOpE4fM34g9lg4tbPNoc8G0ps9B+your_sha256_hashB/gj8Yi08QJyQda8yi8nUPMVb8U+ElfgdfaKg1psbvwOuMv5lOg/wU24oycwTbCvMH6WuejVy8VPdh51yXyG8V8N3f4nfYjjFlx4nRBeJSeD/wjsZdMKfIF8vJ0M6hXDUfu2oRl1F7C7ky+KCI36gNkiPvNVHdlWssqYOM4NqYp0nDjHEbsRcYyccZujilyA/uAfM+your_sha256_hash6IF6/your_sha256_hashfYJhLeE90uxo10sK4vgI6utz9ifyPpU5TNjCynsc8p+oTWhBaFdpYVBfSX47g14ArFZ7F+vtJDBt4WfOIAnMFZkfUTZgTNYUm/48EEgf/hc0fF87gA+FX9KfDjodMToGaNhTk/OgnEyour_sha512_hash+2hlxEvBi9mkPUx45iUZ4itw36t1YZELmAFmwqxkgSxWJFBsFkLo52mg23CfULMV/your_sha256_hash1rbPwvNVrGPh74pcEx0t+yE6APEhyour_sha512_hash/k/De+L/LC0MWB5k8SD7FR5IJ1vxDfED2OPBRlLn1dH/Fm4RXExOTcQIu0NZFbQnwiho6gPzQRnUY7iLaxyHzR2Ut8x3cCb6ptLHJ/SluTdjXkK21J3UvKfdAH4qiINcC2VJ+MskNkkZz/lM+EDdj4RhsD6XsifMKYSWqxpLLVebMAthniikKzPeJQ4iMLvxadyUrYTz75czWy/your_sha256_hash78V9MhY7oDYbQ35DXntTTUOVzO/your_sha256_hash3RJjIrRC7IjoA3yHs8phe66gyour_sha512_hash+hLTpoBlyxYpCj8OuQZ1F9hDNIqMvkO+bQqFuVv+SZsKdoa4I/POpM+your_sha256_hashzHsivhQU5Pb8t4dsSE6FjIsNlkzqIwT2cLnQs/your_sha256_hash0pHnYBPE4ocU6UroAzcA2E73eY17og8QzfYBzF9sXa0UsC/ZS0jJfRt6q6dvDd1IeKBkfpi2P90FOU2xc9aMRq8OelibPwQNC0/Is8ABzvGIvmC6A7QR/w1dfeHus6jfQ+Yj8Y3H5njl0yooG8+seE98jayFOBbYY7MG5pyour_sha512_hash+O6oU1bc+vFoE84fshGi8/jx4WMtsj+dBvCbi4fOXpzP5/iJYNxdHQFomwKvcnR+1B+l1/HR+PXfyour_sha512_hash+CFFwiVd5/hsBbnQRcvgoNHh1Ah1nSc1ovr9f35xFumQ+UXq1wxi0cHd+c3XwcgduScH80PFH2dIl4geoPytEZOnDgoxHpORpDdQhvzVmXEHD6x+hLIo0+gXwv49LAnoadezEt/WfgAMdLkfSykw7EcHdxfnl48nRt+ieiZ5eH12Wl3DzwLUDPTyfrT7+xnD70h/MK8+fF4FNMXQqxm0tyln4XTTrv1P8U2SMde98+Twy2U0THiPWoD0A6U32yPH+/s44tnGY/your_sha256_hashigRya8+n88/rmPIgc+lW4qHimfeKP8iOcSPpZd25xfdCfC/1v4aE0GuU/UyYtLUepzzspuyi7/MZO7owfe4Oi6pS6/3kChOvh09lp7AGZnY2ZlYVnQws1nYxq0WhtCsRhz8gnEEGQfL19Bkn3E4Rt+7R4H33rOPla1vywODGOGfv9hbyTyZEPi+9fnt7FdxnVLnql1vL6IPqd39r5fBsWJ89U/QKlxc+Ov3/xz4/mcm7fgsVp/LQ4KoBIJ8J8en3VL05LnKFJzfT3uOqNZ37xq+v2Ng3eREXf/UnrEGle/QTD9vNvFcl4iPPKGV1gZqtQL57Z+your_sha256_hasht7zwO+your_sha256_hashbLKI5oumxSU5YH0DDwuPu4H2pxV0DhdupBQ6+ETpaIWJYMMKc0wqCpp8z6pSLJySWCywgjkOmyt61RUZO+EqsniJSpE82KLoF/67hySD6Bi8ggicpvBg8ewW0iF5/your_sha256_hashrmbwaDEhwoBoV4FIICIzQAwwyoY1A0U18qm9xvAaRtxLs9SA7CEaXPcNkSrZL+your_sha256_hashyour_sha256_hashyour_sha256_hashByiqFsFZUB/quNVmndAoUXEKE8jJC9ihwPILsve1CrFVIjiwXk/aA8AbrO4C0GisiBhTvvzFtsmZkDCo+your_sha256_hash8k8zOFd+your_sha256_hashyour_sha256_hashyour_sha256_hashisVwCZG2EL4BCwbyBolURoRwFtDiRMSBKiOMGZtYHyKE5smY+your_sha256_hashImqDqMuVyGhav+your_sha256_hashYJGZlD1QSQVvpOQJ9ZJg2Ry1IRl+Rr8Bj0DKO4oWa0YSPNHY/hbIHAlTVBXwJRW3mqoxJ6b0IjRLri/your_sha256_hashyour_sha256_hashyour_sha256_hashmOcQcHvRLYOm6g0o0/whpRmFHUhsp7VSDzbjtnLCcYCKZnGtCGcDJxhj4GoqgbSPTzoSfNMM8ycYY+BsKmAGIrzjRyDXoGsIhIeGXqgRI2HEGWsW0NHA40C3d4Z/yGqEWoklKh6T3VyYjJBaAC/O5Gx8APErsiAoMdn6hECWV4T8Yx3hO3Cc4etBYRBGZB/tscGRL8zolYoKpvnmoaUY5TxiGQCyQp6q0VuAY0DOQW9Q1RxrHuBrC+iQPWgfN8o6mNoZGxJe1B4JFY6VqROdgLEDeyDOVDYug9YD+your_sha256_hashyour_sha256_hashQYtcoCmTkit6Pc7RHWzUgo0fTIiKPiCmNj2oJAFo9JL7SphP+dDkHWpc/J60AvZTibQNeE9yk87hOrNypUzIU5kQvUL60icvEd0Elz3+S8Rdwh1zBvRruQUU/uE+your_sha256_hashPVC9MWXkl6iX0GQeIq/Q6bCxdsbS5pXnzIFwChSVBKQWz8Yjqh40C3pZwbauIXtMn4Ef0xY0+wYNe8yAyP4gA6hyDSgkvJ+your_sha256_hashv5yA+G5HA8PGQIV+qXKSdOwGasEVkXXgLKFazH4job4gmfGNuZIGIPso5N+your_sha256_hashJXkymRwUQXtqRnIAmgF+QZMhbR6I68Snou1Y4W+your_sha256_hashyour_sha256_hashyour_sha256_hashur_sha512_hash+d3+eEZSY5qGXlP053sTLBClVUWK8qAstTpBchyD/pmqr9FJtTX9wLfC40SiUJUecfqNeoF7DXskTnlFtHD4DWxJSgjmKGF/qkQxUeWsUNGPCeqpmQmGLETxuCAxGT2j/Z/YIjTXpEoyLAAjYN1OfoAeh/8iucy5hGo7Me8QPogq8hKGtmHeaCVyzKvVm0jY6SIb/iXoi+pz4FqBH+7SqYZMsZpS5m1ItIF6AHRcajsqZAdQvUxnhmyuo4Va0SD85210jYLSAsTIOOIUA+UtpNQbdaSSJUcmU1WSCEjAt+1dN/JXic6L/wg0Vk5qhB0Xvgyour_sha512_hashn2lVS02rOoieg37MjDmAh2jWXYZS/your_sha256_hashyour_sha256_hashJWlNk+your_sha256_hashysjZq9CzOe2ihqgoyDTNiDJ+A1SApzSODBzQRmIn9xt7C8i3Xmkc8RYg4p0/X3pYAyrUWLUA1PlEbVbYccIfQDQ+your_sha512_hash+eC6SRrCOys0UMA/anyS/IRflvyeqQmNWcIpNMVyDWEyuipCGfsjJm5WQQ4jfQ33guOy0ALeUrLcM/hl9U9Jq1GaEqatDYFn0O+your_sha256_hashyour_sha256_hashQOzYULGV4H0X24qIvBOGquF7IUcZl4maRVdgHesTKbX8Kc6oiwnpeZ/BpOvWtMPWxUZ9zY3O+your_sha256_hashWxAzs5UAfoPme0pUYRdV9PNFKoGexSM/uII2oXDma/gXjWfU61YmKWWYUP/deQaKEJ/TpFmijKUiuGRJ9rLFFpmhXwJ2/your_sha256_hashKE/your_sha256_hashU+HREkyDSnPX0iZ3cDzTSkiuaHHw+/hvFt2t2o/vOJlkVcBL4eUYFcc0d01olD+your_sha512_hash+wz62iFFy3jErsoKNLY+qolni2T4gXhJoNQt4aI5uIR5R9fShMiDJHf95lF+Kfus05liJjZna2BSVjkozkM/oDoS9dfyHOMSKsqpnvgpygmvKFFUvPoJWf+CsiXDsbZ96rVBpbGxhFa0b2xNopYBybkkbuWfFJ88OVUCVVWftjmU+your_sha256_hashu7HIEaG7QK2VeTX0RbfxD2kPF/6Gzok4M58a8maoWPWuFQhbtAp542m1IuX6S7oIGceHLN7wx+Y7+your_sha256_hashL1aqC5Rm7nXvB/nDqkrmE9EZwxWJ1vlyc75oVsHbBrE6ic7+zTUirqfUcyour_sha512_hash/your_sha256_hasho0NNbeHCktX8ZVF5p+FipZDHBK0mrIyIFuZrYezRUWU2Jvk2+13VV8f+Srq3NRVHBNJqF2OUCFf+1bJFNGXJ/+your_sha256_hashyour_sha256_hashb/your_sha512_hash+A6y5IFZBEZk4AyIwVZ+your_sha256_hashyour_sha256_hashrJf8gbzzbVF+9fNdQO4sQ/8EzQKU5eMTJN2AGlFZ3zgAyCvQndo3yD3QZ7fDB5DW6dXWKvgf/ANORec90XvaK4MV3rI6MlI4ZswoZpze+xN7lGovHmuCDhhmrNlCtNGcO3d7VZw5aeXb7O+o85DIzV/0J1Nmg54ZniG+6Sm0cbMBS4/vMC+J5lVaosf9Xgq4xdqZA4yPuRjrbeU/your_sha256_hashyour_sha256_hash2lXXhIwpW7USsG+your_sha256_hashJYansCbAD4uNK4Anw/IKBFxrDahB0bKiK+jSYRCwmtgoq5A/your_sha256_hashntZpbqq2yssKOS/Oixyi7D/khlURlJRz3CtgqSbMubNyRHVYuvtdTL05oS7WfegZW/your_sha256_hashf6I+i2Vdk+MHYV27xtplVm9h3sicb2F75Kyioy7i9zEfD5dR+2x1assBU552lXzIJ2wgYnRVT6vLcKCU9trUZsr9pkb4GuAq3yWWG+aKb5YNqAI+bc33iuT4wTaESrFN/nA9WPiueasBucjYc+bMzuRWwf/mVhthG6ptTsIrHpRIkck1YxIT8T0A9TXeUrVraMtVobuZ1Eu+sssX74D6hkaQaOPWG8NNaqBOYbobd7lUv0+ynjWNFFnNMcfBHb2IDVfkTjI8/your_sha256_hashqNYnnQtxlyjgLMC4jrRBklTMrs/meVlUQa6XDXKviJqpTtGMNKi5ZIegTFU+/your_sha256_hashyour_sha256_hashZ5PRtuMZDLQvV8Qw8synwJZoLD7Sjizo8DzX82O8jv6PjYUPlQwbWgPdGu+your_sha512_hash/BP0QWJuZ+your_sha256_hashGSu/Mw7fsMNGrbIbvS7wNK2Ihq4uWPozKfeJKgPfVitimZ7U+xiInMakMB8FqS/hZoXYLYQwffqyvsojxO+your_sha256_hashOtUC/VDkWcZGx8tkp8duNF3o7+YEUbVauakScAb9PnRuWCjWMnJZ/your_sha256_hash5RHZs04q0Ez1XYKrY4UefibXGWlXMGHfPboruPSdNRL+RFdbszBhbHjtmRS66SNhzYc/l6A7Js4G/jUrK0p1rB2yKxgAblR/AMrP6GjY/MCC0b61r5hx76t4H9Q6R2kuNViZCVp2MrOobWAF2+Iqtcx8qCt3+wx739X0QH0E1c6M6RPv7tsAyceySXUf6nF1Tyl7jSFoVp/your_sha256_hashI9iNdOSBOo6guBWcnUT94ZSzsNfgC7UhG/MQFfJoHJbPD2YHvRGd8pnULPoFPOZOQ53gGmBR2/TVaw4j2nPmXMFnKqdfI+YzyBHUwC0sEMvk7pZFxHO+your_sha256_hashY5dzyLzmiKO2P15IR6tbPK7IjdGFRXRMQEztiN0/YCPMI8SWT4BHa6Q2U2u1dbt4opsZOoJKtNBmkXDxcrMp6w7kDgW+SHnZ0APxk6lt1CAmKzIJ9pA+your_sha256_hashyour_sha256_hashbfq2GjeMxBAbMw8HwjjYsCG1PiuYPi00eR8hHiZegeXKOrvT4X/1afOWR8hd010Ql/your_sha256_hashz3x21nNyjp0FUpUpu2PHhgNf1TYW3WDmocrITHGVw4jdINRPYd4Ya4Kug+yK1W6CPwHMa9lubIUJO28O3Mexdd2izQWZUnENWjnMziRxrlX5sXbogq/BvYDNjhhkp3EfPtc37FKnyour_sha512_hashzaMICXanZvwt5ObS/RHSOnfULfK2AH641dDAx2pTzKOCvqntLoWQdCn1c2NkOno8G+Q+VzR5sIPhv2nxgey4mLnanyZnsccaHAPJ6M7HkF45n8jnQL/Ve6tbKjlvIW+RZ8omeDOO+your_sha256_hash7xG+your_sha256_hashagOeWRkuo/i58Pc+Gupr1Jo6WNmO5h9QxiklS+your_sha512_hash/oW2V57H5xv7zuiD7kKtltbl2QGdHWrNdBta+BaywRYcF/hs6l9gOvAPzJFrFjs6zqdsrdDpB7l67cCyZ90c+your_sha512_hash/your_sha256_hashgUB9A89ZFqx3rWH1sXREg54A/your_sha256_hashjIfPBBmPDq+dykPkNgp0xR1Mh+PmD2CprNsFdGX1Qs9CT7GbWMR8ESqpRd+pns0G5oS1K8XOWHb2GthtSscCQxzqjTPg6Qw1I57yQKOd3tGZS+UBcP+your_sha256_hashyour_sha256_hashb1oFOGINgVTz9YMU6xIq3d3j6JtKbCkz+zbTzGmKeTkcAy6b+BnQ2OlyUneqsmvwOnJGjqSl1KWOw8VRrnaDjau2QgnqMLMxtrOps2hWx1n42lv/H+2Qyour_sha512_hashQ51YtOpHzo3W5YxMXYl5/u8Lzetm8wObdDWQ0yBtq51py9iJ8emvM0i0/your_sha256_hashR3Z8QbEFaNjSWOtHPdW1TPJJ3xfa/1P9ahRWu7BtO5WlO80riX+your_sha512_hash/your_sha256_hashui762uzGjDh7at3Dkd91MgW+your_sha256_hashyour_sha256_hashyour_sha256_hashyour_sha256_hashOkKelDYXO3qhHsTtBTtu2l7QToLP7GyFmHlp4Io4TugbMcCNrTCHr+brXmyPpc87qfSmMsNFmB3R6U0uiDHQbopUZqifonYc6jZTpRntfhwqNrph/your_sha256_hashr_sha512_hashbI2l8Qhy2qtaz2B7bMfcHevZENPhmsnb6MSot5rNfdZLk7dJn+DtXukRc/F2G5/0SF8cXbwRg0QvCnQ/y6AHanb5R95/ZnzC2DFyGOnAvULemfYqzh/your_sha256_hashyour_sha256_hashoboVBx07WCqDOEv6gZzKBnffQlR39Q/gcvN9Y+RY1GLD7lee3xraWr+9oyour_sha512_hashyour_sha512_hash/Foy6D421JlT1sKoD0HcDjDPfN/aJ97OfIgp+yMg5p1ubptAjZvaGeic2HRKq3x/P2Pe0Z4L/BBr/tNW63cK4ld1LOKHZcf3Ib4ANfRzz+wMYMkG7eWxS1MYS7y0dj7n2aMyour_sha512_hash/your_sha256_hashxAxxba5Xts+6zxlsCeGz7HAXfHgneBGQLW0MYi1ozYourcgO+vOhd7BVmkZ8CcHuIkpXXRBF6B/WIGkxkeu5gPhdEcMKrsRsyxlvM0WkZeuejpA7LeBzI+8R0tT3n/4UjlCbuss1a0VtlZoheLp/Ix006FckbW6a1n/Qr3mLjtkB2yKRMot7Am371PzrPOItNvL3gTv2183tJH/bZztrTNEQtPnJ55Obal7BnmojNIG6H2KCnZ0d5wqtCHvC2DuI+B/RI8zVOPiA2CD6e3+your_sha256_hashYZwewlrsi22jB5khn+t1CfU3k+vxmqXP+hDHZuxTrRy+CDF7IuNqO9WM5/v8hm4oUpoEDn5UHMywJpqzlDxH+yHVb/aJyour_sha512_hashyour_sha512_hash/aPXf1nqd7+xzgIu6s6zHSvsWi9/e/FPoVaa1/gBkf2f5myA2qldUjEU8+RD7XeMtvfWx16jBgZn7tkL66et8opTgfY4AG3UWr/your_sha256_hashN+xC7DLk8JGxW+DOgYN94gLpI4DFxnNwruypFIb4ZBZ2rIemLjW56J5mwN39iw78NU+your_sha256_hashyXsHcPaWcQAFNPAfCV8Td4c93os+Z8dYXUsa9m1n43mndCfKjG5SLkcK1YTOCDo2oZ9H3bflbUyM/YZqxVvPGJ+Ml86eoKthDrOXTmivRa0BsL6PgCfRIxvs5k7Z50R+z74drtCb/jHQW8jafQmPdIQu4HH6r+BN4EZVbmqt26hlrPxTE7FiGOjl5XisdC/rlBsF+Uf5BTigbyRCDfYBYq1RwxIb5LRm81K2ovENhg+h7e4Qe5O6mATl9I846D1QIhHjniewM5nis+ym7yqwG5njLTOoLTbq6wOFjjmnrfw+ZTXeosQ84y0IfqR6gz2a6k6+your_sha512_hash+ituybr+oK2wcrgT8jZvzcO4x+your_sha256_hash/Jiracl7/CWi1xrMbB/nv4WOce5YVnSQG98GO3ScKzxIrX7dvtp6K2LiHMgTtP+lP61xpo9CULm5hzf8macud4st93nIeJNebBRGONnXB4+your_sha256_hashyour_sha256_hashxTNQV1VaLJ651cH6I4DPiJ/eYKjYw7Gy2m/UcsL+c/nRipgppWfesEScl8u9Qkeibtb2alD97fIhiEHVeqOn3rIR2/your_sha512_hash+vpVdnspcOCN/your_sha256_hashVeSHczfpHP6gzX0jqufbzUeVQUm/6KpxWHdzX16q2VqZ4ta26q32+xik2uGIySPIu9tN+Xx1oLAztZnX5ABfU459t3n6rp4O4wHmnAyCfax1Q92eoMH7K3M5ubNaHZLFG92C+12qlhviphHmvtLGIcGZl55F/Y85G+mdbTAyPGWpZFvcdFQbQ6MZT0Xb53INjls3CqqtxTpzUg1ay8U24BciKvp3x1L/ErAOnYd6/OGH8Uq+ax9QR+your_sha256_hashUyVqeJbabFzu9tQv9IhoXNwHmSW+Bopyour_sha512_hashxGq2U6vVLRxmB/ZCbLjIrXdVHYY8nN5Ysl1LbL1vgKXivMBvIb7ZdE5eQM+6XOKr7xEnB1ZrsqltRw2L3Wyhucjc3U7FWC/your_sha256_hashrlPq/FPB+your_sha256_hashK5k8biZMSA2Q1amckf9E6xHCRzCei/V5r8Yc+NaJPLY4wgG1ztJm/A2sgQ3rL74la3l2PZLzNAzMPqdiP2mdG4bsueCzP2R9qtkbVb4dGDblN7i/rSWGvSiPkJIeyour_sha512_hash/LTPEHpwbvRTkGsPOsjcQG+your_sha256_hashx1qgj3pxpnyTDeKKHcW314IjppYZFq5lLgj+q77s9dnqiN1LaDbA9sRm88bC2My705s4Tt5eIycK+MKyN3nrQvZ6b/Ilc/WA31/ZqUxW9xqwRP4Q+rAbV9an2inF4JvYKQ6/H0t1y2LLG2nBf6HuQszdMazWmjG939k6M/your_sha256_hashBs2OE3cah6779BrS2/u43eB2t2Vnj1rrLivRs8pbvYatJaZtRTArDnMH3pVhorBIj3G7EPq6i5QS/your_sha256_hashyour_sha256_hash3Yl1ufjR66tfXcQA1igzx6rHgs3oCNvGD81tyKN5s/36S4qcuoLB8J/A50MGs9t9fN/your_sha256_hashyour_sha256_hashlndXuFpzJZ9Ozzaf5pX03pBxdd3WgNSdHbzbK816LjtqNrkFzS3id5Dc/sOGPdEdR5xoLjps9Y6Nub8kXfRfInWvfP+AYxl/CPTnt2WTy5QZ8y6WNZmIs5LmcY+KhExjVrbuj2WuSJgf0p3o2SrvcWL55w+dNPmRskRe/CrXGIPXcQqrE47oY7HrTwOK5Rp3FLn3loXc3g+ewv0rub2HX5QXvZof6KOWHW59WWcxzY+1n5iTfeMN4Iuql2NOGNAmqdLFDvCXuqk6Vh7Y+C2OuUX1lMwjsbaPeTZQuPzWPu6zzutc9T+3HrbHeW4x1s1tc5K7x0YKH9tbBozP886R/YK4I1vNnZgXJ60MzdMK+jG1kS7QDGG2nN7HilOnbIJMeKBtTasBUtZN/CcO8QN4cCRoecwbUTF1HENwJIwj4Bcj+Lt2TuC+T/sqW+1lz57M2ufbObp0MM5Gza1uhFr+AbH+xn731n95PZY9h3MeAuX1k8S241bxfDcnrkC3oTbaP0k7+pAD3WHkWhirdlinarSuMMUKEaC2Bv9DnUchpdlbrFQvAe/your_sha256_hash_sha512_hashPHwNuOUYO1fIO3GHNKwmf5ChmCG6lHzDfTx0GvKevP8BO+tZozxTc5vI/1JItcraLm0Fj3b2dPzGusdWXwFxPW05u+6XiPTM++msQ7T2fUwbwJm7VvWnMWGLZ20Hw1+5LynhXWd7G+HDqF9MYYR87erVbHOKCWDX4B+qmU7C/xXOdNbKXaFA7fixtbyV/kY/ZF4V4RD4IYbmb15TXx/jzflfW8GnC3FOsJB/aEpBxKDdMI7CDfp9V+rpnKZuyp9nXxrAYSdSC94l9S6CXGubUWMdXbfRWvg94oLWPm6jez/g4YCfSQhZ+oyour_sha512_hash/OXB+F0uzCsnN7MUWOaVZbLW9p/csY/+nZw4/x2szqUBvFXfK58EURu+Xt5YHeRq63NaNfxzHvrEjsdmztM5xrX0aPtivzb/your_sha256_hashsZEI88lLrHxDSUrcW6fPWlWAOHsa1ifdNh00cBN5Pz9kzSKnsqq/0yt75V6aA2CGtetPep9SR4OVZtrCZUbPY8VPxjbRiUQjEbuhc+axjQa2KSmSyCnBpZr5Fd/qKdMFj/vK2aW8OKwGb3Mkfn78gZtcnZv7xyour_sha512_hash/your_sha256_hashq8yx6iZifMH7Wux2rwFcccqJ2YWKwHODYn02va6+your_sha512_hash/QGcwVRvc44yl6+euP3Gzdeo+your_sha256_hashWXeR+your_sha256_hash8+1I/znFlPxHrhCc+JuEHoea0vhG5TuYo1TRU/FLta1e2x6BGFWF5jdX4ap9EeHwVvgCdmV+sLcf4x8dzYJ/your_sha256_hashp2JrzrERi4jmvqrV/your_sha512_hash+ep+dXao7jQ3mZ294PVRcKnCNV2hn5AP2/oIa2LRM8wrffn2AD4AT0j2AWNi3/your_sha256_hash+ezE20PpQ7e+your_sha256_hashnoTS+RQ3HXPU6+8EBM05bMdJ4NOr3KqNz5JARfyV/8db5KfoKnNjZzwrGazmWWLgaOTGM1Tg+sOGk5VLtMo0fDNwX9LmYlI4PPL0TsnQ0p76BjUV/your_sha256_hash8xzFeufpRxcMSlYnunVu/6cjdY896vbkNTkybUngis6wjp/3PNDfEDsAN0XsTWILeKzvYZvVICGxtr/avhf3H29PtSvXWeZ49+L5XJMdxcjPwM6652xs552z2w8jaWefSMfk8WaIxnTnteY+DsZ0bZqlifwvVosTwe+q5jXuIvQ96ronXDA+8RZMw60/g38Edjrd+dgr6I6+K8EWtelR5j7csDP5H0GCr+your_sha512_hash+e7Y7t7R6h1mpaW/your_sha256_hashyour_sha256_hash9Bxa/Z+your_sha256_hashWsvdvh15I+BOVjedu1qe8F3TW96HjK4t54hoEXW0NCOH8wWJ/aaewi8eGt2ia++fdNqDeYOjdN+your_sha256_hashour_sha512_hashcL6qcHqQtnDhveM2rmDtxjnmOzsk/b5Zc9g2/+3aZg0zlq5mLkL1q6ksd2FETB+DZ3E3iqF+vbsASxrwt0HrJVjDQ2w9bGz/6bsxVxqfQrjE+your_sha256_hash1baZ/qFeN6HmKNWIf2/your_sha512_hash+cGehNWPo9UEaQO6gpP7Seiz45uhrrTHqnL0bkaNAzIn1gQPzlIz3F/2mJ/tSawvZr5j5c+4HYght/your_sha256_hash0q0PJUeOn9bce+6MgTrQqXX1ZrzmGxsYWej/C5v55+Om03z210XE/19zqGVEjXMe6Jub9YHt6rhZS6+your_sha256_hashpz5qN4T1q21PdB/fOUuD7UdLJmEbFCV8sa834R1mBiLO/1sr2AX4X46Ci2sR7rOFiDiVgQeDk1your_sha512_hashPh6yz/lC4Po/your_sha512_hash+8dhHsgv9sLJXni4FwR7gfd0+ePhssMnQeDrR3dnPy5vHvSjxWN/9SG+your_sha256_hashd7wYe1PPbw/If8VT9wO/4zn3y9XC/PzteXb/0Wi7h/6Ne2iB+3jzcXl1i5L1+3V8uHy5O7swrftj/O7uSzq4frtX39r+V6Pb5d3/7g2PAivty/kJM8vH/4cdtcvvhmPzgPP3z4tw7Y/+n5/iP66G2d74fX5+tH3usD9r0/7YTjd0/4Yvm0e1gvPsrOKvl/GbmXfNw7GO3tR3vJh73DeG//cCyour_sha512_hashRR1n62V9I/+s5DQvf/xvnrj/wXc8/nuHHn/8s878wxtnvrOP91dndyour_sha512_hash8r2UHlj7kI0fuU899In9fnD2c7YUj/Wfw6f6pFhHdyUkH498+i4DuRS2cdo/V4C3PPn/1qsnt03F4EV70sZiI8VN1XT3xCrvxwXBxXS3Tz1cP50fxML25uj87jX+I2rm9your_sha512_hashDr3fm1fBYcPIgi+bH4/nV1Nj54rPq0vgjWzcWRjEepWHgYydwybn1z9rnAZ3H+nZ8FZ6ffwuL6IBJV16aTUY1wUEpImcxx/a2vgvXT+cpbIl2frrZVWXriPaTJxfpcfld+//pUrW7refCwvjjKb1OEjcUETcc1rzPL+qY+your_sha512_hash/muyOOvq7FsJRPi/DLWla6XowPQzFKbtNPbtciUczuV7tjFze7n5qBQ+your_sha512_hash/1WNmfX5TfGQyour_sha512_hash/GB6/3cfLG72B8fpYzEi6R5zyIU4G9iFyour_sha512_hashtreL62+/2dvWi8/gu5HM8BWrw77egYfmwYGYn/m6OO3as6NE5MSXdRV+u7/AaQZXcooH4SxYXFdC+7PwG57a/your_sha512_hash/Myour_sha512_hash/IHzdn32v395VW9cv72ouFHKzmL3zxru/m8dPi6N5fXYavdg9/+ri85e7y+TAvzj6Jm53+vTbslxdHiUf33JTdBf9dXV9sZ5dHzTismzRDLi8Orq6K/v35xFO2szxxm9EwhkHrXZdkrdk3G9HlbyR0MP68GoRzCFbQFv9uUh42e/H8yAGPw3ylk9n8v2zxkmeHcXr+On8eu7+/VDdfLtfzLzl4vtCtIa85VjmNI0xvfkaV0fzg7TxZ/OjTzfvOIzPbmW/OO1EanwR19K/Pw8unqD33pqt+P7FE715VV1/FQkj+ylPlVVfnd/k1your_sha512_hash/73b08mtJfXRwf3l68XRumiNfHz6df17fnAcvXPqbb/your_sha256_hash0PF5/XLXhj9i2fiaxrF/OL/jz81v7O6e5QXn4n0uIXgi1bcqxXuhDr6UGk47v0/Y7caktYUkfy9EZbA6FF6JRpnsRaHDFMriXlfastxid6XWSKq+hO9KqQTCGLnvuMUD+your_sha256_hash5NSbKK6bjttcWfFnE1M+E13your_sha512_hash/skyJ4b+tsbqO7CVP9IrgZZ58Urs+Hj7Oa7MlGUiubzjy+doi3GENtFSA61tdsauCCkFLA8pxK3nIJTJ0hXA9tGeYes5DIO+your_sha512_hash/sa9jwEHoqB73nbAcLuKNd240S3QmvYrcWMEWk117wSnBATTu9CirRK+rQ3hc0S3gOUv+8RqxT+WjXkgCmoa2o3LWsPxvrackHQt3Z/VRbVMZ2Pae2mmG7gfSeEEFcObCaWxqe7VcCFAYIn/your_sha256_hashyour_sha256_hashyour_sha256_hashnhWhXATHHF1jwmPIqQEaR50XJsDlhlwDYfk4wtyFwbX16xx6tdqo5XQ/B6q5dpeJRjtiGvXhzQworXs0RWztcSvjqwBA0lvVaqRBhZBLin0GKo5Tds2+vgdoRCom0Er1KcoL2VlhuxvRJaoAC+w1YqKA0uW7t+LFSYyxzvrfQ0oAVSZVcmIcWWoQ1ap/uCayN4DUagrbBqvT59xra0SKP7Bsf86VheH8zUJcaSJgK2zD3RUhJAlqdMayWE+your_sha256_hashyour_sha256_hashyour_sha256_hashMUTx6LdRuFraS7b3/your_sha256_hashyour_sha256_hashyour_sha256_hash_sha512_hash/your_sha512_hash/your_sha512_hash/plfy+dfdeCvfn3/5vJXh/LxsU7O9keD++keH9your_sha512_hashyour_sha512_hashMrWe7I0CHMb+/t7hRybkD/dGn/6f16dxzaP7R3uBGfLbi8v/Xt3/4UlkEXfYmf/6rX+4ur35w+Pyour_sha512_hash/6NB/your_sha512_hash+uzh9oeOHTlC+7Xx/zcOzN//xRP74P9ZJxbyour_sha512_hash/v4Q7Yw8B5+XF6aESG2g+EHE2AJFS04ivnVJ0iMwJuOv24DEsX0iPC30wP8scwQ4BMxSeXBb4AWYxgpNjP//j8FSHyPUv4g5DT645Qi//xxe/vw4rsjeburTGxJ/OL/Aw==</diagram></mxfile> ```
/content/code_sandbox/diagrams/macaca eco v4.xml
xml
2016-03-16T02:52:39
2024-08-12T02:11:35
macaca
alibaba/macaca
3,161
25,347
```xml import * as React from 'react'; import createSvgIcon from '../utils/createSvgIcon'; const CaretSolidLeftIcon = createSvgIcon({ svg: ({ classes }) => ( <svg xmlns="path_to_url" viewBox="0 0 2048 2048" className={classes.svg} focusable="false"> <path d="M384 1024L1408 0v2048L384 1024z" /> </svg> ), displayName: 'CaretSolidLeftIcon', }); export default CaretSolidLeftIcon; ```
/content/code_sandbox/packages/react-icons-mdl2/src/components/CaretSolidLeftIcon.tsx
xml
2016-06-06T15:03:44
2024-08-16T18:49:29
fluentui
microsoft/fluentui
18,221
121
```xml // See LICENSE.txt for license information. import {OperationType} from '@constants/database'; import {transformReactionRecord} from '@database/operator/server_data_operator/transformers/reaction'; import {createTestConnection} from '@database/operator/utils/create_test_connection'; describe('*** REACTION Prepare Records Test ***', () => { it('=> transformReactionRecord: should return an array of type Reaction', async () => { expect.assertions(3); const database = await createTestConnection({databaseName: 'reaction_prepare_records', setActive: true}); expect(database).toBeTruthy(); const preparedRecords = await transformReactionRecord({ action: OperationType.CREATE, database: database!, value: { record: undefined, raw: { id: 'ps81iqbddesfby8jayz7owg4yypoo', user_id: 'q3mzxua9zjfczqakxdkowc6u6yy', post_id: 'ps81iqbddesfby8jayz7owg4yypoo', emoji_name: 'thumbsup', create_at: 1596032651748, update_at: 1608253011321, delete_at: 0, }, }, }); expect(preparedRecords).toBeTruthy(); expect(preparedRecords!.collection.table).toBe('Reaction'); }); }); ```
/content/code_sandbox/app/database/operator/server_data_operator/transformers/reaction.test.ts
xml
2016-10-07T16:52:32
2024-08-16T12:08:38
mattermost-mobile
mattermost/mattermost-mobile
2,155
293
```xml import { Component, Input, Output, EventEmitter, SimpleChanges, ElementRef, OnChanges, ChangeDetectionStrategy, HostListener } from '@angular/core'; import { select } from 'd3-selection'; import { Transition } from 'd3-transition'; import { BarOrientation } from '../common/types/bar-orientation.enum'; import { Gradient } from '../common/types/gradient.interface'; import { id } from '../utils/id'; @Component({ selector: 'g[ngx-charts-heat-map-cell]', template: ` <svg:g [attr.transform]="transform" class="cell"> <defs *ngIf="gradient"> <svg:g ngx-charts-svg-linear-gradient [orientation]="barOrientation.Vertical" [name]="gradientId" [stops]="gradientStops" /> </defs> <svg:rect [attr.fill]="gradient ? gradientUrl : fill" rx="3" [attr.width]="width" [attr.height]="height" class="cell" (click)="onClick()" /> </svg:g> `, changeDetection: ChangeDetectionStrategy.OnPush }) export class HeatMapCellComponent implements OnChanges { @Input() fill: string; @Input() x: number; @Input() y: number; @Input() width: number; @Input() height: number; @Input() data: number; @Input() gradient: boolean = false; @Input() animations: boolean = true; @Output() select: EventEmitter<number> = new EventEmitter(); @Output() activate: EventEmitter<number> = new EventEmitter(); @Output() deactivate: EventEmitter<number> = new EventEmitter(); element: HTMLElement; transform: string; startOpacity: number; gradientId: string; gradientUrl: string; gradientStops: Gradient[]; barOrientation = BarOrientation; constructor(element: ElementRef) { this.element = element.nativeElement; } ngOnChanges(changes: SimpleChanges): void { this.transform = `translate(${this.x} , ${this.y})`; this.startOpacity = 0.3; this.gradientId = 'grad' + id().toString(); this.gradientUrl = `url(#${this.gradientId})`; this.gradientStops = this.getGradientStops(); if (this.animations) { this.loadAnimation(); } } getGradientStops(): Gradient[] { return [ { offset: 0, color: this.fill, opacity: this.startOpacity }, { offset: 100, color: this.fill, opacity: 1 } ]; } loadAnimation(): void { const node = select(this.element).select('.cell'); node.attr('opacity', 0); this.animateToCurrentForm(); } animateToCurrentForm(): void { const node = select(this.element).select('.cell'); node.transition().duration(750).attr('opacity', 1); } onClick(): void { this.select.emit(this.data); } @HostListener('mouseenter') onMouseEnter(): void { this.activate.emit(this.data); } @HostListener('mouseleave') onMouseLeave(): void { this.deactivate.emit(this.data); } } ```
/content/code_sandbox/projects/swimlane/ngx-charts/src/lib/heat-map/heat-map-cell.component.ts
xml
2016-07-22T15:58:41
2024-08-02T15:56:24
ngx-charts
swimlane/ngx-charts
4,284
709
```xml import { $ } from '../$.js'; import { getAttribute, setAttribute } from '../shared/attributes.js'; import { isElement, isFunction, eachArray } from '../shared/helper.js'; import './each.js'; import type { JQ } from '../shared/core.js'; declare module '../shared/core.js' { interface JQ<T = HTMLElement> { /** * CSS * @param className * CSS * * CSS CSS `this` * @example ```js // p item $('p').addClass('item') ``` * @example ```js // p item1 item2 $('p').addClass('item1 item2') ``` * @example ```js // p $('p').addClass(function (index, currentClassName) { return currentClassName + '-' + index; }); ``` */ addClass( className: | string | ((this: T, index: number, currentClassName: string) => string), ): this; } } type Method = 'add' | 'remove' | 'toggle'; eachArray<Method>(['add', 'remove', 'toggle'], (name) => { $.fn[`${name}Class` as 'addClass'] = function ( this: JQ, className: | string | (( this: HTMLElement, index: number, currentClassName: string, ) => string), ): JQ { if (name === 'remove' && !arguments.length) { return this.each((_, element) => { setAttribute(element, 'class', ''); }); } return this.each((i, element) => { if (!isElement(element)) { return; } const classes = ( isFunction(className) ? className.call( element, i, <string>getAttribute(element, 'class', ''), ) : className ) .split(' ') .filter((name) => name); eachArray(classes, (cls) => { element.classList[name](cls); }); }); }; }); ```
/content/code_sandbox/packages/jq/src/methods/addClass.ts
xml
2016-07-11T17:39:02
2024-08-16T07:12:34
mdui
zdhxiong/mdui
4,077
465
```xml import { c } from 'ttag'; import { useGroupMemberships } from '@proton/account/groupMemberships/hooks'; import { useUser } from '@proton/components/hooks'; import type { GroupMembership } from '@proton/shared/lib/interfaces'; import { Loader, Table, TableBody, TableCell, TableHeader, TableRow } from '../../../components'; import { SettingsParagraph, SettingsSectionWide } from '../../account'; import GroupActions from './GroupActions'; import GroupState from './GroupState'; const GroupsTable = ({ memberships, isPrivateUser }: { memberships: GroupMembership[]; isPrivateUser: boolean }) => { const isEmpty = memberships.length === 0; return ( <> {isEmpty && c('Info').t`You are in no group nor invited to any`} {!isEmpty && ( <div style={{ overflow: 'auto' }}> <Table hasActions responsive="cards"> <TableHeader> <TableRow> <TableCell type="header">{c('Title').t`Group`}</TableCell> <TableCell type="header">{c('Title').t`Address`}</TableCell> <TableCell type="header">{c('Title').t`Status`}</TableCell> <TableCell type="header">{c('Title').t`Action`}</TableCell> </TableRow> </TableHeader> <TableBody colSpan={6}> {memberships.map((membership, index) => { const key = index.toString(); return ( <TableRow key={key} labels={[ c('Title').t`Group`, c('Title').t`Address`, c('Title').t`Status`, c('Title').t`Action`, '', ]} cells={[ <span className="block max-w-full text-ellipsis" title={membership.Name}> {membership.Name} </span>, <span className="block max-w-full text-ellipsis" title={membership.Address}> {membership.Address} </span>, <GroupState key={key} membership={membership} />, <GroupActions key={key} membership={membership} isPrivateUser={isPrivateUser} />, ]} /> ); })} </TableBody> </Table> </div> )} </> ); }; const GroupMembershipSection = () => { const [originalGroupMemberships, loading] = useGroupMemberships(); const [User] = useUser(); const { isPrivate } = User; const groupMemberships: GroupMembership[] = (originalGroupMemberships ?? []).map( ({ Group, State, ForwardingKeys, AddressId, ID }) => ({ Name: Group.Name, Address: Group.Address, Status: State === 0 ? 'unanswered' : 'active', Keys: ForwardingKeys, AddressID: AddressId, ID: ID, }) ); // make status unanswered come first, then sort alphabetically by address const sortedGroupMemberships = [...groupMemberships].sort((a, b) => { if (a.Status === 'unanswered' && b.Status !== 'unanswered') { return -1; } if (a.Status !== 'unanswered' && b.Status === 'unanswered') { return 1; } return a.Address.localeCompare(b.Address); }); return ( <> <SettingsSectionWide> <SettingsParagraph>{c('Info').t`View and manage your groups.`}</SettingsParagraph> {loading && <Loader />} {!loading && <GroupsTable memberships={sortedGroupMemberships} isPrivateUser={isPrivate} />} </SettingsSectionWide> </> ); }; export default GroupMembershipSection; ```
/content/code_sandbox/packages/components/containers/account/groups/GroupMembershipSection.tsx
xml
2016-06-08T11:16:51
2024-08-16T14:14:27
WebClients
ProtonMail/WebClients
4,300
790
```xml import { fireEvent, render, waitFor } from '@testing-library/react'; import React from 'react'; import Popper from '../index'; if (global.document) { document.createRange = () => ({ setStart: () => {}, setEnd: () => {}, // @ts-ignore commonAncestorContainer: { nodeName: 'BODY', ownerDocument: document, }, }); } window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({ disconnect: jest.fn(), observe: jest.fn(), unobserve: jest.fn(), })); describe('Popper', () => { it('renders correctly', () => { const onVisibleChange = jest.fn(); const { container } = render( <Popper content="" onVisibleChange={onVisibleChange}> <p></p> </Popper>, ); expect(container).toMatchSnapshot(); }); it('renders menu-slide', () => { const onVisibleChange = jest.fn(); const { container } = render( <Popper content="" onVisibleChange={onVisibleChange} animationType="menu-slide"> <p></p> </Popper>, ); expect(container).toMatchSnapshot(); }); it('renders menu-slide bottom', () => { const onVisibleChange = jest.fn(); const { container } = render( <Popper content="" onVisibleChange={onVisibleChange} animationType="menu-slide" direction="bottom" > <p></p> </Popper>, ); expect(container).toMatchSnapshot(); }); it('check hasArrow prop', () => { const { getByTestId } = render( <div data-testid="za-popper-hasArrow"> <Popper trigger="click" hasArrow={false} content="fdsfsd" mouseEnterDelay={0} mouseLeaveDelay={0} > <div className="hello">Hello world!</div> </Popper> , </div>, ); const wrapper = getByTestId('za-popper-hasArrow'); const elments = [].slice.call(wrapper.getElementsByClassName('hello')); fireEvent.click(elments?.[0]); expect(wrapper.getElementsByClassName('.za-popper__arrow')).not.toHaveLength(1); }); it('check onVisibleChange func prop', async () => { const onVisibleChange = jest.fn(); const { getByTestId } = render( <div data-testid="za-popper-onVisibleChange"> <Popper trigger="click" content="fsdfds" mouseEnterDelay={0} mouseLeaveDelay={0} onVisibleChange={onVisibleChange} > <div className="hello">Hello world!</div> </Popper> </div>, ); const wrapper = getByTestId('za-popper-onVisibleChange'); const elments = [].slice.call(wrapper.getElementsByClassName('hello')); fireEvent.click(elments?.[0]); await waitFor(() => { expect(onVisibleChange).toBeCalled(); }); }); }); ```
/content/code_sandbox/packages/zarm/src/popper/__tests__/index.test.tsx
xml
2016-07-13T11:45:37
2024-08-12T19:23:48
zarm
ZhongAnTech/zarm
1,707
659
```xml export declare type Fork = { use<T>(plugin: Plugin<T>): T; }; export declare type Plugin<T> = (fork: Fork) => T; export declare type Def = Plugin<void>; export declare type Omit<T, K> = Pick<T, Exclude<keyof T, K>>; ```
/content/code_sandbox/node_modules/degenerator/node_modules/ast-types/types.d.ts
xml
2016-03-11T09:28:00
2024-08-16T17:55:54
antSword
AntSwordProject/antSword
3,579
63
```xml <?xml version="1.0" encoding="utf-8"?> <de.westnordost.streetcomplete.view.SlidingRelativeLayout xmlns:android="path_to_url" android:layout_width="match_parent" android:layout_height="match_parent"> <include android:id="@+id/markerCreateLayout" layout="@layout/marker_create_note"/> <include android:id="@+id/questAnswerLayout" layout="@layout/fragment_quest_answer" /> </de.westnordost.streetcomplete.view.SlidingRelativeLayout> ```
/content/code_sandbox/app/src/main/res/layout/fragment_create_note.xml
xml
2016-07-02T10:44:04
2024-08-16T18:55:54
StreetComplete
streetcomplete/StreetComplete
3,781
117
```xml import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities'; import { TableContextValue } from '../Table/Table.types'; export type TableHeaderSlots = { root: Slot<'thead', 'div'>; }; /** * TableHeader Props */ export type TableHeaderProps = ComponentProps<TableHeaderSlots> & {}; /** * State used in rendering TableHeader */ export type TableHeaderState = ComponentState<TableHeaderSlots> & Pick<TableContextValue, 'noNativeElements'>; ```
/content/code_sandbox/packages/react-components/react-table/library/src/components/TableHeader/TableHeader.types.ts
xml
2016-06-06T15:03:44
2024-08-16T18:49:29
fluentui
microsoft/fluentui
18,221
110
```xml import * as assert from "assert" import * as path from "path" const MemoryFileSystem = require("memory-fs") // tslint:disable-line import * as FileMappings from "./../../src/Services/FileMappings" describe("FileMappings", () => { let rootPath: string let srcPath: string let testPath: string let fileSystem: any beforeEach(() => { rootPath = path.join("C:/", "oni-unit-test-container") srcPath = path.join(rootPath, "browser", "src") testPath = path.join(rootPath, "browser", "test") fileSystem = new MemoryFileSystem() fileSystem.mkdirpSync(srcPath) fileSystem.mkdirpSync(testPath) }) describe("getMappedFile", () => { it("returns null for template file if template file doesn't exist", () => { const srcFile = path.join(srcPath, "source.ts") const mapping: FileMappings.IFileMapping = { sourceFolder: "browser/src", mappedFolder: "browser/test", mappedFileName: "${fileName}Test.ts", // tslint:disable-line } const mappedFile = FileMappings.getMappedFile(rootPath, srcFile, [mapping]) assert.strictEqual( mappedFile.templateFileFullPath, null, "`templateFileFullPath` should be null since there is no template file specified.", ) }) it("returns a template file if template file exists", () => { const srcFile = path.join(srcPath, "source.ts") const mapping: FileMappings.IFileMapping = { sourceFolder: "browser/src", mappedFolder: "browser/test", mappedFileName: "${fileName}Test.ts", // tslint:disable-line templateFilePath: "templates/template.ts", } const mappedFile = FileMappings.getMappedFile(rootPath, srcFile, [mapping]) assert.strictEqual( mappedFile.templateFileFullPath, path.join(rootPath, mapping.templateFilePath), ) }) }) describe("getMappedFileFromMapping", () => { it("returns simple mapping", () => { const srcFile = path.join(srcPath, "source.ts") const testFile = path.join(testPath, "sourceTest.ts") fileSystem.writeFileSync(srcFile, " ") fileSystem.writeFileSync(testFile, " ") const mapping: FileMappings.IFileMapping = { sourceFolder: "browser/src", mappedFolder: "browser/test", mappedFileName: "${fileName}Test.ts", // tslint:disable-line } const mappedFile = FileMappings.getMappedFileFromMapping(rootPath, srcFile, mapping) assert.strictEqual(mappedFile, testFile, "Validate mapping worked correctly") }) it("works with recursive directories", () => { const nestedSrcFolder = path.join(srcPath, "nested", "a") const nestedTestFolder = path.join(testPath, "nested", "a") fileSystem.mkdirpSync(nestedSrcFolder) fileSystem.mkdirpSync(nestedTestFolder) const srcFile = path.join(nestedSrcFolder, "source.ts") const testFile = path.join(nestedTestFolder, "source.test.ts") fileSystem.writeFileSync(srcFile, " ") fileSystem.writeFileSync(testFile, " ") const mapping: FileMappings.IFileMapping = { sourceFolder: "browser/src", mappedFolder: "browser/test", mappedFileName: "${fileName}.test.ts", // tslint:disable-line } const mappedFile = FileMappings.getMappedFileFromMapping(rootPath, srcFile, mapping) assert.strictEqual(mappedFile, testFile, "Validate mapping worked correctly") }) }) describe("getPathDifference", () => { it("resolves path correctly", () => { const diff = FileMappings.getPathDifference("D:/test1/test2", "D:/test1/test2/test3") assert.strictEqual(diff, "test3") }) it("resolves path correctly, in reverse", () => { const diff = FileMappings.getPathDifference("D:/test1/test2/test3", "D:/test1/test2") assert.strictEqual(diff, "test3") }) it("handles case where there is no common path", () => { const diff = FileMappings.getPathDifference("D:/test1", "C:/test2") assert.strictEqual(diff, path.join("D:", "test1")) }) }) }) ```
/content/code_sandbox/browser/test/Services/FileMappingsTests.ts
xml
2016-11-16T14:42:55
2024-08-14T11:48:05
oni
onivim/oni
11,355
942
```xml /* * @license Apache-2.0 * * * * path_to_url * * Unless required by applicable law or agreed to in writing, software * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ import incrmmax = require( './index' ); // TESTS // // The function returns an accumulator function... { incrmmax( 3 ); // $ExpectType accumulator } // The compiler throws an error if the function is provided an argument that is not a number... { incrmmax( '5' ); // $ExpectError incrmmax( true ); // $ExpectError incrmmax( false ); // $ExpectError incrmmax( null ); // $ExpectError incrmmax( undefined ); // $ExpectError incrmmax( [] ); // $ExpectError incrmmax( {} ); // $ExpectError incrmmax( ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an invalid number of arguments... { incrmmax(); // $ExpectError incrmmax( 2, 3 ); // $ExpectError } // The function returns an accumulator function which returns an accumulated result... { const acc = incrmmax( 3 ); acc(); // $ExpectType number | null acc( 3.14 ); // $ExpectType number | null } // The compiler throws an error if the returned accumulator function is provided invalid arguments... { const acc = incrmmax( 3 ); acc( '5' ); // $ExpectError acc( true ); // $ExpectError acc( false ); // $ExpectError acc( null ); // $ExpectError acc( [] ); // $ExpectError acc( {} ); // $ExpectError acc( ( x: number ): number => x ); // $ExpectError } ```
/content/code_sandbox/lib/node_modules/@stdlib/stats/incr/mmax/docs/types/test.ts
xml
2016-03-24T04:19:52
2024-08-16T09:03:19
stdlib
stdlib-js/stdlib
4,266
419
```xml import { Version } from '@microsoft/sp-core-library'; import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base'; import { sp, Web, RenderListDataOptions } from "@pnp/sp"; let _documentResults: string = ""; let _searchResults: string = ""; export default class ThumbnailWebPart extends BaseClientSideWebPart<void> { public async onInit(): Promise<void> { let web: Web = new Web(this.context.pageContext.web.absoluteUrl); const noRedirect = "?preferNoRedirect=true"; // undocumented, to avoid a redirect to CDN //const noRedirect = ""; const libraryPath = "Shared Documents"; // const libraryPath = "SitePages"; // Using renderListDataAsStream for ease of use to also get the List ID on one call let options : RenderListDataOptions = RenderListDataOptions.ListData | RenderListDataOptions.ContextInfo; let fileData = await web.getList(`${this.context.pageContext.web.serverRelativeUrl}/${libraryPath}`).renderListDataAsStream({ RenderOptions: options , ViewXml: "<View Scope='Recursive'><ViewFields><FieldRef Name='FileLeafRef' /><FieldRef Name='UniqueId' /></ViewFields><RowLimit Paged='TRUE'>10</RowLimit></View>" }); let searchResults = await sp.search({ Querytext: `path:"${this.context.pageContext.web.absoluteUrl}/${libraryPath}" IsDocument:1`, RowLimit: 10, SelectProperties: ["FileName", "DocumentLink", "NormSiteID", "ParentLink", "SPWebUrl", "NormListID", "NormUniqueID"] }); // Thumbnail URL docs // path_to_url // When using custom thumbnails: // The thumbnail returned may not exactly match the pixel dimensions that was requested, // but will match the aspect ratio. In some cases, a larger thumbnail may be returned than was requested, // if the thumbnail already exists and can easily be scaled to match the requested resolution. // Often it's better to request one of the default sizes const maxHeight = "c99999x150"; //const maxWidth = "c150x99999"; let listId = fileData["listName"].replace(/[{}]/g, ""); fileData.ListData.Row.forEach(fileInfo => { let itemUniqueId = fileInfo["UniqueId"].replace(/[{}]/g, ""); let fileName = fileInfo["FileLeafRef"]; let thumbnailUrl = `/_api/v2.0/sites/${this.context.pageContext.site.id}/lists/${listId}/items/${itemUniqueId}/driveItem/thumbnails/0/${maxHeight}/content${noRedirect}`; _documentResults += (`<li>${fileName}<br/><img height="150" border="1" src="${thumbnailUrl}" onerror="this.src=''"></li>`); }); searchResults.PrimarySearchResults.forEach(item => { let thumbnailUrl = `/_api/v2.0/sites/${item["NormSiteID"]}/lists/${item["NormListID"]}/items/${item["NormUniqueID"]}/driveItem/thumbnails/0/${maxHeight}/content${noRedirect}`; _searchResults += (`<li>${item["FileName"]}<br/><img height="150" border="1" src="${thumbnailUrl}" onerror="this.src=''"></li>`); }); } public render(): void { this.domElement.innerHTML = ` <div> <h3>REST loaded</h3> <ul> ${_documentResults} </ul> <h3>Search loaded</h3> <ul> ${_searchResults} </ul> </div>`; } protected get dataVersion(): Version { return Version.parse('1.0'); } } ```
/content/code_sandbox/samples/js-msgraph-thumbnail/src/webparts/thumbnail/ThumbnailWebPart.ts
xml
2016-08-30T17:21:43
2024-08-16T18:41:32
sp-dev-fx-webparts
pnp/sp-dev-fx-webparts
2,027
809
```xml import { bootstrap } from '@angular/platform-browser-dynamic'; import { enableProdMode } from '@angular/core'; import { HelloMobileAppComponent, environment } from './app/'; import { APP_SHELL_RUNTIME_PROVIDERS } from '@angular/app-shell'; if (environment.production) { enableProdMode(); } bootstrap(HelloMobileAppComponent, [ APP_SHELL_RUNTIME_PROVIDERS ]); ```
/content/code_sandbox/hello-mobile/src/main.ts
xml
2016-01-25T17:36:44
2024-08-15T10:53:22
mobile-toolkit
angular/mobile-toolkit
1,336
77
```xml import { requireLogin } from "@erxes/api-utils/src/permissions"; import * as dotenv from "dotenv"; import { IContext } from "../../../connectionResolver"; import { sendProductsMessage, sendSalesMessage } from "../../../messageBroker"; dotenv.config(); const configQueries = { /** * Config object */ async multierkhetConfigs(_root, _args, { models }: IContext) { return models.Configs.find({}); }, async multierkhetConfigsGetValue( _root, { code }: { code: string }, { models }: IContext ) { return models.Configs.findOne({ code }).lean(); }, async dealPayAmountByBrand( _root, { _id }: { _id: string }, { models, subdomain }: IContext ) { const deal = await sendSalesMessage({ subdomain, action: "deals.findOne", data: { _id }, isRPC: true }); if (!deal || !deal.productsData || !deal.productsData.length) { return []; } const mainConfigs = await models.Configs.getConfig("erkhetConfig", {}); const brandIds = Object.keys(mainConfigs); if (!brandIds.length) { return [ { _id: "", name: "", amount: deal.productsData.reduce( (sum, pd) => Number(sum) + Number(pd.amount), 0 ) } ]; } const productsIds = deal.productsData.map(item => item.productId); const products = await sendProductsMessage({ subdomain, action: "productFind", data: { query: { _id: { $in: productsIds } }, limit: deal.productsData.length }, isRPC: true, defaultValue: [] }); const productById = {}; for (const product of products) { productById[product._id] = product; } const amountByBrandId: any = {}; for (const productData of deal.productsData) { // not tickUsed product not sent if (!productData.tickUsed) { continue; } // if wrong productId then not sent if (!productById[productData.productId]) { continue; } const product = productById[productData.productId]; if ( !(product.scopeBrandIds || []).length && brandIds.includes("noBrand") ) { if (!amountByBrandId["noBrand"]) { amountByBrandId["noBrand"] = 0; } amountByBrandId["noBrand"] += productData.amount; continue; } for (const brandId of brandIds) { if (product.scopeBrandIds.includes(brandId)) { if (!amountByBrandId[brandId]) { amountByBrandId[brandId] = 0; } amountByBrandId[brandId] += productData.amount; continue; } } } return (Object.keys(amountByBrandId) || []).map(brandId => ({ _id: brandId, name: mainConfigs[brandId].title, amount: amountByBrandId[brandId], paymentIds: mainConfigs[brandId].paymentIds || [] })); } }; requireLogin(configQueries, "multierkhetConfigs"); export default configQueries; ```
/content/code_sandbox/packages/plugin-multierkhet-api/src/graphql/resolvers/queries/configs.ts
xml
2016-11-11T06:54:50
2024-08-16T10:26:06
erxes
erxes/erxes
3,479
728
```xml <?xml version="1.0" encoding="UTF-8"?> <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2"> <file source-language="en" target-language="en" datatype="plaintext" original="validators.en.xlf"> <body> <trans-unit id="rmH78_V" resname="At least one team leader must be assigned to the team."> <source>At least one team leader must be assigned to the team.</source> <target>At least one team leader must be assigned to the team.</target> </trans-unit> <trans-unit id="6WAG.Xj" resname="The entered passwords don't match."> <source>The entered passwords don't match.</source> <target>The entered passwords don't match.</target> </trans-unit> <trans-unit id="6u6oCwB" resname="The email is already used."> <source>This e-mail address is already in use.</source> <target state="translated">This e-mail address is already in use.</target> </trans-unit> <trans-unit id="S14XECA" resname="The username is already used."> <source>The username is already used.</source> <target>The username is already used.</target> </trans-unit> <trans-unit id="ekO5eXI" resname="An equal username is already used."> <source>An equal username is already used.</source> <target>An equal username is already used.</target> </trans-unit> <trans-unit id="INlaCgW" resname="An equal email is already used."> <source>An equal e-mail address is already in use.</source> <target state="translated">An equal e-mail address is already in use.</target> </trans-unit> <trans-unit id="IkNxbBI" resname="This value is not a valid role."> <source>This value is not a valid role.</source> <target>This value is not a valid role.</target> </trans-unit> <trans-unit id="CLHaByy" resname="End date must not be earlier then start date."> <source>End date must not be earlier then start date.</source> <target state="translated">End date must not be earlier then start date.</target> </trans-unit> <trans-unit id="ePrqiLM" resname="The begin date cannot be in the future."> <source>The begin date cannot be in the future.</source> <target>The begin date cannot be in the future.</target> </trans-unit> <trans-unit id="Jz1y3yB" resname="Duration cannot be zero."> <source>Duration cannot be zero.</source> <target>An empty duration is not allowed.</target> </trans-unit> <trans-unit id="1V6BsD_" resname="You must select at least one user or team."> <source>You must select at least one user or team.</source> <target>You must select at least one user or team.</target> </trans-unit> <trans-unit id="yDlKSRw" resname="This invoice document cannot be used, please rename the file and upload it again."> <source>This invoice document cannot be used. Please rename the file and upload it again.</source> <target>This invoice document cannot be used. Please rename the file and upload it again.</target> </trans-unit> <trans-unit id="0o.pH3X" resname="This period is locked, please choose a later date."> <source>This period is locked. Please choose a later date.</source> <target>This period is locked. Please choose a later date.</target> </trans-unit> <trans-unit id="u2wjm2i" resname="You already have an entry for this time."> <source>You already have an entry for this time.</source> <target>You already have an entry for this time.</target> </trans-unit> <trans-unit id="VJSZSD0" resname="The given value is not a valid time."> <source>The given value is not a valid time.</source> <target>The given value is not a valid time.</target> </trans-unit> <trans-unit id="1oKCOa5" resname="The budget is completely used."> <source>The budget is completely used.</source> <target>The budget is used up. Of the available %budget%, %used% has been booked so far, %free% can still be used.</target> </trans-unit> <trans-unit id="dcPei9G" resname="Sorry, the budget is used up."> <source>Sorry, the budget is used up.</source> <target>Sorry, the budget is used up.</target> </trans-unit> <trans-unit id="6rO8GZ1" resname="Maximum duration of {{ value }} hours exceeded."> <source>Maximum duration of {{ value }} hours exceeded.</source> <target>Maximum {{ value }} hours allowed.</target> </trans-unit> <trans-unit id="to1Q85W" resname="An activity needs to be selected."> <source>An activity needs to be selected.</source> <target>An activity needs to be selected.</target> </trans-unit> <trans-unit id="rHd9_aA" resname="A project needs to be selected."> <source>A project needs to be selected.</source> <target>A project needs to be selected.</target> </trans-unit> <trans-unit id="mjlH0la" resname="This timesheet is already exported."> <source>This timesheet is already exported.</source> <target>This timesheet is already exported.</target> </trans-unit> <trans-unit id="gSAwscA" resname="Validation Failed"> <source>Validation Failed</source> <target>There was a problem saving.</target> </trans-unit> <trans-unit id="7HYTefs" resname="Cannot stop running timesheet"> <source>Cannot stop running timesheet</source> <target>You have an active time record which cannot be stopped automatically.</target> </trans-unit> <trans-unit id="xp0lmgm" resname="The given code is not the correct TOTP token."> <source>The given code is not the correct TOTP token.</source> <target>The given code is not the correct TOTP token.</target> </trans-unit> <trans-unit id="7mqg3TC" resname="This value is not a valid role name."> <source>This value is not a valid role name.</source> <target>This is not a valid name for a user role.</target> </trans-unit> <trans-unit id="ZObikpA" resname="This absence type is not known."> <source>This absence type is not known.</source> <target>This absence type is not known.</target> </trans-unit> <trans-unit id="0ULsHQA" resname="The chosen date is not a working day."> <source>The chosen date is not a working day.</source> <target>The chosen date is not a working day.</target> </trans-unit> <trans-unit id="N21br.P" resname="The chosen date is already locked."> <source>The chosen date is already locked.</source> <target>The chosen date is already locked.</target> </trans-unit> <trans-unit id="6H84TMs" resname="An absence must be assigned to a user."> <source>An absence must be assigned to a user.</source> <target>An absence must be assigned to a user.</target> </trans-unit> <trans-unit id="nLcihCc" resname="An absence must have a date."> <source>An absence must have a date.</source> <target>An absence must have a date.</target> </trans-unit> <trans-unit id="SZO4xjC" resname="An absence cannot be booked before your first working day."> <source>An absence cannot be booked before your first working day.</source> <target>An absence cannot be booked before your first working day.</target> </trans-unit> <trans-unit id="IN37g5N" resname="Not enough holidays left."> <source>Not enough holidays left.</source> <target>Not enough holidays left.</target> </trans-unit> <trans-unit id="ByeEMxW" resname="You do not have enough overtime, remaining are {{ value }}."> <source>You do not have enough overtime, remaining are {{ value }}.</source> <target>You do not have enough overtime, remaining are {{ value }}.</target> </trans-unit> <trans-unit id="DiaaRa1" resname="You cannot have two absences of this type at one day."> <source>You cannot have two absences of this type at one day.</source> <target>You cannot have two absences of this type at one day.</target> </trans-unit> <trans-unit id="kSBiyaF" resname="This is a public holiday, booking not allowed."> <source>This is a public holiday, booking not allowed.</source> <target>This is a public holiday, booking not allowed.</target> </trans-unit> <trans-unit id="c2B6.lW" resname="You can book a maximum of {{ value }} days at once."> <source>You can book a maximum of {{ value }} days at once.</source> <target>You can book a maximum of {{ value }} days at once, you currently selected {{ selected }}.</target> </trans-unit> <trans-unit id="BztgSSP" resname="The period of absence must not extend beyond the turn of the year."> <source>The period of absence must not extend beyond the turn of the year.</source> <target>The period of absence must not extend beyond the turn of the year.</target> </trans-unit> <trans-unit id="fvxWW3V" resname="The CSRF token is invalid. Please try to resubmit the form."> <source>The CSRF token is invalid. Please try to resubmit the form.</source> <target>Please try to resubmit the form. If the problem persists, refresh your browser.</target> </trans-unit> </body> </file> </xliff> ```
/content/code_sandbox/translations/validators.en.xlf
xml
2016-10-20T17:06:34
2024-08-16T18:27:30
kimai
kimai/kimai
3,084
2,357
```xml import { CreateValetTokenResponseData } from './CreateValetTokenResponseData' export type CreateValetTokenResponse = CreateValetTokenResponseData ```
/content/code_sandbox/packages/responses/src/Domain/Files/CreateValetTokenResponse.ts
xml
2016-12-05T23:31:33
2024-08-16T06:51:19
app
standardnotes/app
5,180
34
```xml import React from 'react'; import { CommonActions, DrawerActions } from '@react-navigation/native'; import type { DrawerContentComponentProps } from '@react-navigation/drawer'; import UITideAtom from '../../UITideAtom'; import { Stack } from '@mobily/stacks'; import BoxNucleon from '../../nucleons/BoxNucleon'; import { IconNucleonProps } from '../../nucleons/IconNucleon'; import { useColorRoles } from '../../../theme/colorSystem'; import TextRoleNucleon from '../../nucleons/TextRoleNucleon'; import groupBy from './groupBy'; interface ItemDefinition { index: number; group: string; groupLabel: string; key: string; name: string; title: string; drawerLabel: string; iconName: IconNucleonProps['name']; } /** * Component that renders the navigation list in the drawer. */ export default function DrawerItemList({ state, navigation, descriptors }: DrawerContentComponentProps<any>) { const { surface } = useColorRoles(); // const buildLink = useLinkBuilder(); // const routes = state.routes as Array<{ key: string; }> const routeDefinitions = state.routes.map( ({ key, name }: { key: string; name: string }, index: number) => ({ ...descriptors[key].options, key, name, index }) ) as Array<ItemDefinition>; const renderItem = ({ key, title, drawerLabel, iconName, name, index }: ItemDefinition) => { const focused = index === state.index; return ( <UITideAtom key={key} title={ drawerLabel !== undefined ? drawerLabel : title !== undefined ? title : name } leftIconName={iconName} active={focused} // to={buildLink(route.name, route.params)} onPress={() => { navigation.dispatch({ ...(focused ? DrawerActions.closeDrawer() : CommonActions.navigate(name)), target: state.key }); }} /> ); }; const renderGroup = (name: string, defs: ItemDefinition[]) => { return ( <BoxNucleon key={name}> <Stack space={1}> <TextRoleNucleon color={surface.secondaryContent} role="sectionOutline"> {name === 'root' ? 'Getting Started' : name} </TextRoleNucleon> {defs.map(renderItem)} </Stack> </BoxNucleon> ); }; const groups = groupBy(routeDefinitions, 'group'); return ( <BoxNucleon paddingY={1} paddingX={1}> <Stack space={4}> {Object.entries(groups).map(([name, defs]) => renderGroup(name, defs))} </Stack> </BoxNucleon> ); } ```
/content/code_sandbox/apps/discovery/src/components/screens/HomeDrawerScreen/DrawerItemList.tsx
xml
2016-11-29T10:50:53
2024-08-08T06:53:22
react-native-render-html
meliorence/react-native-render-html
3,445
637
```xml /** * This file is part of OpenMediaVault. * * @license path_to_url GPL Version 3 * @author Volker Theile <volker.theile@openmediavault.org> * * OpenMediaVault is free software: you can redistribute it and/or modify * any later version. * * OpenMediaVault is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ import { Component, ViewChild } from '@angular/core'; import { Router } from '@angular/router'; import { marker as gettext } from '@ngneat/transloco-keys-manager/marker'; import * as _ from 'lodash'; import { DatatablePageComponent } from '~/app/core/components/intuition/datatable-page/datatable-page.component'; import { DatatablePageConfig } from '~/app/core/components/intuition/models/datatable-page-config.type'; import { format } from '~/app/functions.helper'; import { NotificationType } from '~/app/shared/enum/notification-type.enum'; import { NotificationService } from '~/app/shared/services/notification.service'; import { RpcService } from '~/app/shared/services/rpc.service'; @Component({ template: '<omv-intuition-datatable-page [config]="this.config"></omv-intuition-datatable-page>' }) export class SharedFolderPermissionsDatatablePageComponent { @ViewChild(DatatablePageComponent, { static: true }) private page: DatatablePageComponent; public config: DatatablePageConfig = { stateId: '99f40468-8309-11ea-834f-cbe87c99180b', autoReload: false, limit: 0, hasFooter: false, hasSearchField: true, hints: [ { type: 'info', text: gettext( 'These settings are used by the services to configure the user and group access rights. Please note that these settings have no effect on file system permissions.' ) } ], selectionType: 'none', columns: [ { name: gettext('Name'), prop: 'name', flexGrow: 2, sortable: true }, { name: gettext('Type'), prop: 'type', flexGrow: 1, sortable: true, cellTemplateName: 'chip', cellTemplateConfig: { map: { user: { value: gettext('User') }, group: { value: gettext('Group') } } } }, { name: gettext('Permissions'), prop: 'perms', flexGrow: 3, sortable: true, cellTemplateName: 'buttonToggle', cellTemplateConfig: { buttons: [ { value: '7', text: gettext('Read/Write') }, { value: '5', text: gettext('Read-only') }, { value: '0', text: gettext('No access') } ] } } ], sorters: [ { dir: 'desc', prop: 'type' }, { dir: 'asc', prop: 'name' } ], store: { proxy: { service: 'ShareMgmt', get: { method: 'getPrivileges', params: { uuid: '{{ _routeParams.uuid }}' } } } }, actions: [ { type: 'iconButton', icon: 'mdi:transfer', tooltip: gettext('Copy permissions'), execute: { type: 'formDialog', formDialog: { title: gettext('Copy permissions'), fields: [ { type: 'sharedFolderSelect', name: 'src', store: { filters: [ { operator: 'ne', arg0: { prop: 'uuid' }, arg1: '{{ _routeParams.uuid }}' } ] }, hasCreateButton: false, label: gettext('Source'), hint: gettext('The shared folder from which the permissions are copied.'), validators: { required: true } }, { type: 'hidden', name: 'dst', value: '{{ _routeParams.uuid }}' } ], buttons: { submit: { text: gettext('Copy'), execute: { type: 'request', request: { service: 'ShareMgmt', method: 'copyPrivileges', successNotification: gettext('Shared folder permissions have been copied.') } } } } } } } ], buttons: [ { template: 'cancel', url: '/storage/shared-folders' }, { text: gettext('Save'), class: 'omv-background-color-pair-primary', click: this.onSave.bind(this) } ] }; constructor( private router: Router, private rpcService: RpcService, private notificationService: NotificationService ) {} onSave() { const privileges = _.map(_.reject(this.page.table.data, ['perms', null]), (obj) => ({ name: obj.name, type: obj.type, perms: _.toInteger(obj.perms) })); this.rpcService .request('ShareMgmt', 'setPrivileges', { uuid: _.get(this.page.routeParams, 'uuid'), privileges }) .subscribe(() => { this.notificationService.show( NotificationType.success, format(_.get(this.page.routeConfig, 'data.notificationTitle'), this.page.routeParams) ); this.router.navigate(['/storage/shared-folders']); }); } } ```
/content/code_sandbox/deb/openmediavault/workbench/src/app/pages/storage/shared-folders/shared-folder-permissions-datatable-page.component.ts
xml
2016-05-03T10:35:34
2024-08-16T08:03:04
openmediavault
openmediavault/openmediavault
4,954
1,210
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ ~ ~ path_to_url ~ ~ Unless required by applicable law or agreed to in writing, software ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --> <RelativeLayout xmlns:android="path_to_url" android:layout_width="match_parent" android:layout_height="match_parent" style="@style/root" android:background="#000"> <ren.qinc.foundation.lib.touchImageView.TouchImageView android:id="@+id/picture" android:layout_centerInParent="true" android:layout_width="match_parent" android:layout_height="match_parent" android:contentDescription="@string/Description" /> <include layout="@layout/view_common_toolbar_with_title_view" /> </RelativeLayout> ```
/content/code_sandbox/app/src/main/res/layout/activity_common_single_picture.xml
xml
2016-06-30T10:37:13
2024-08-12T19:23:34
MarkdownEditors
qinci/MarkdownEditors
1,518
182
```xml <?xml version="1.0" encoding="utf-8"?> <!-- path_to_url Unless required by applicable law or agreed to in writing, software WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --> <resources> <style name="Widget.MaterialComponents.PopupMenu.Overflow" parent="Base.Widget.MaterialComponents.PopupMenu.Overflow"> <item name="android:popupBackground">?attr/popupMenuBackground</item> <item name="android:popupElevation">8dp</item> </style> <style name="Widget.MaterialComponents.PopupMenu" parent="Base.Widget.MaterialComponents.PopupMenu"> <item name="android:popupBackground">?attr/popupMenuBackground</item> <item name="android:popupElevation">8dp</item> </style> <style name="Base.Widget.MaterialComponents.PopupMenu.ListPopupWindow" parent="Widget.AppCompat.ListPopupWindow"> <item name="android:popupBackground">?attr/popupMenuBackground</item> <item name="android:popupElevation">8dp</item> <item name="android:dropDownVerticalOffset">1dp</item> </style> <style name="Base.Widget.MaterialComponents.PopupMenu.ContextMenu" parent="Widget.AppCompat.PopupMenu"> <item name="android:overlapAnchor">true</item> </style> </resources> ```
/content/code_sandbox/lib/java/com/google/android/material/menu/res/values-v21/styles.xml
xml
2016-12-05T16:11:29
2024-08-16T17:51:42
material-components-android
material-components/material-components-android
16,176
300
```xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="path_to_url" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <ListView android:id="@+id/listview" android:divider="@color/transparent" android:dividerHeight="0dp" android:layout_width="match_parent" android:layout_height="match_parent"> </ListView> </LinearLayout> ```
/content/code_sandbox/app/src/main/res/layout/frg_recommend_recommend.xml
xml
2016-11-21T02:35:32
2024-07-16T14:34:43
likequanmintv
chenchengyin/likequanmintv
1,050
105
```xml import { AsyncIterableX } from './asynciterablex.js'; import { wrapWithAbort } from './operators/withabort.js'; import { throwIfAborted } from '../aborterror.js'; import { safeRace } from '../util/safeRace.js'; type MergeResult<T> = { value: T; index: number }; function wrapPromiseWithIndex<T>(promise: Promise<T>, index: number) { return promise.then((value) => ({ value, index })) as Promise<MergeResult<T>>; } /** @ignore */ export class RaceAsyncIterable<TSource> extends AsyncIterableX<TSource> { private _sources: AsyncIterable<TSource>[]; constructor(sources: AsyncIterable<TSource>[]) { super(); this._sources = sources; } async *[Symbol.asyncIterator](signal?: AbortSignal) { throwIfAborted(signal); const sources = this._sources; const length = sources.length; const iterators = new Array<AsyncIterator<TSource>>(length); const nexts = new Array<Promise<MergeResult<IteratorResult<TSource>>>>(length); for (let i = 0; i < length; i++) { const iterator = wrapWithAbort<TSource>(sources[i], signal)[Symbol.asyncIterator](); iterators[i] = iterator; nexts[i] = wrapPromiseWithIndex(iterator.next(), i); } const next = safeRace(nexts); const { value: next$, index } = await next; if (!next$.done) { yield next$.value; } const iterator$ = iterators[index]; // Cancel/finish other iterators for (let i = 0; i < length; i++) { if (i === index) { continue; } const otherIterator = iterators[i]; if (otherIterator.return) { otherIterator.return(); } } let nextItem; while (!(nextItem = await iterator$.next()).done) { yield nextItem.value; } } } /** * Propagates the async sequence that reacts first. * * @param {...AsyncIterable<T>[]} sources The source sequences. * @return {AsyncIterable<T>} An async sequence that surfaces either of the given sequences, whichever reacted first. */ export function race<TSource>(...sources: AsyncIterable<TSource>[]): AsyncIterableX<TSource> { return new RaceAsyncIterable<TSource>(sources); } ```
/content/code_sandbox/src/asynciterable/race.ts
xml
2016-02-22T20:04:19
2024-08-09T18:46:41
IxJS
ReactiveX/IxJS
1,319
505
```xml <?xml version="1.0" encoding="UTF-8"?> <!-- or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file path_to_url Unless required by applicable law or agreed to in writing, "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY specific language governing permissions and limitations --> <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> <concept rev="1.2.1" id="sync_ddl"> <title>SYNC_DDL Query Option</title> <titlealts audience="PDF"><navtitle>SYNC DDL</navtitle></titlealts> <prolog> <metadata> <data name="Category" value="Impala"/> <data name="Category" value="Impala Query Options"/> <data name="Category" value="DDL"/> <data name="Category" value="SQL"/> <data name="Category" value="Developers"/> <data name="Category" value="Data Analysts"/> </metadata> </prolog> <conbody> <p> <indexterm audience="hidden">SYNC_DDL query option</indexterm> When enabled, causes any DDL operation such as <codeph>CREATE TABLE</codeph> or <codeph>ALTER TABLE</codeph> to return only when the changes have been propagated to all other Impala nodes in the cluster by the Impala catalog service. That way, if you issue a subsequent <codeph>CONNECT</codeph> statement in <cmdname>impala-shell</cmdname> to connect to a different node in the cluster, you can be sure that other node will already recognize any added or changed tables. (The catalog service automatically broadcasts the DDL changes to all nodes automatically, but without this option there could be a period of inconsistency if you quickly switched to another node, such as by issuing a subsequent query through a load-balancing proxy.) </p> <p> Although <codeph>INSERT</codeph> is classified as a DML statement, when the <codeph>SYNC_DDL</codeph> option is enabled, <codeph>INSERT</codeph> statements also delay their completion until all the underlying data and metadata changes are propagated to all Impala nodes and this option applies to all filesystem-based tables. Internally, Impala inserts have similarities with DDL statements in traditional database systems, because they create metadata needed to track HDFS block locations for new files and they potentially add new partitions to partitioned tables. </p> <note> Because this option can introduce a delay after each write operation, if you are running a sequence of <codeph>CREATE DATABASE</codeph>, <codeph>CREATE TABLE</codeph>, <codeph>ALTER TABLE</codeph>, <codeph>INSERT</codeph>, and similar statements within a setup script, to minimize the overall delay you can enable the <codeph>SYNC_DDL</codeph> query option only near the end, before the final DDL statement. </note> <p conref="../shared/impala_common.xml#common/type_boolean"/> <p conref="../shared/impala_common.xml#common/default_false_0"/> <!-- To do: Example could be useful here. --> <p conref="../shared/impala_common.xml#common/related_info"/> <p> <xref href="impala_ddl.xml#ddl"/> </p> </conbody> </concept> ```
/content/code_sandbox/docs/topics/impala_sync_ddl.xml
xml
2016-04-13T07:00:08
2024-08-16T10:10:44
impala
apache/impala
1,115
798
```xml /* * one or more contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright ownership. */ import {render, screen} from 'modules/testing-library'; import {AppHeader} from '../index'; import {authenticationStore} from 'modules/stores/authentication'; import {createUser} from 'modules/testUtils'; import {mockGetUser} from 'modules/mocks/api/getUser'; import {UserDto} from 'modules/api/getUser'; import {Wrapper as BaseWrapper} from './mocks'; import {useEffect} from 'react'; const Wrapper: React.FC<{children?: React.ReactNode}> = ({children}) => { useEffect(() => { return authenticationStore.reset; }, []); return <BaseWrapper>{children}</BaseWrapper>; }; describe('Info bar', () => { it('should render with correct links', async () => { const originalWindowOpen = window.open; const mockOpenFn = jest.fn(); window.open = mockOpenFn; const {user} = render(<AppHeader />, { wrapper: Wrapper, }); await user.click( await screen.findByRole('button', { name: /info/i, }), ); await user.click( await screen.findByRole('button', {name: 'Documentation'}), ); expect(mockOpenFn).toHaveBeenLastCalledWith( 'path_to_url '_blank', ); await user.click( await screen.findByRole('button', { name: /info/i, }), ); await user.click(screen.getByRole('button', {name: 'Camunda Academy'})); expect(mockOpenFn).toHaveBeenLastCalledWith( 'path_to_url '_blank', ); await user.click( await screen.findByRole('button', { name: /info/i, }), ); await user.click( screen.getByRole('button', {name: 'Slack Community Channel'}), ); expect(mockOpenFn).toHaveBeenLastCalledWith( 'path_to_url '_blank', ); window.open = originalWindowOpen; }); it.each<[UserDto['salesPlanType'], string]>([ ['free', 'path_to_url ['enterprise', 'path_to_url ['paid-cc', 'path_to_url ])( 'should render correct links for feedback and support - %p', async (salesPlanType, link) => { mockGetUser().withSuccess(createUser({salesPlanType})); await authenticationStore.authenticate(); const originalWindowOpen = window.open; const mockOpenFn = jest.fn(); window.open = mockOpenFn; const {user} = render(<AppHeader />, { wrapper: Wrapper, }); await user.click( await screen.findByRole('button', { name: /info/i, }), ); await user.click( screen.getByRole('button', {name: 'Feedback and Support'}), ); expect(mockOpenFn).toHaveBeenLastCalledWith(link, '_blank'); window.open = originalWindowOpen; }, ); }); ```
/content/code_sandbox/operate/client/src/App/Layout/AppHeader/tests/infoBar.test.tsx
xml
2016-03-20T03:38:04
2024-08-16T19:59:58
camunda
camunda/camunda
3,172
662
```xml import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { TreeDemoComponent } from './tree-demo.component'; const routes: Routes = [ { path: '', component: TreeDemoComponent, }, ]; @NgModule({ imports: [RouterModule.forChild(routes)], exports: [RouterModule], }) export class TreeDemoRoutingModule {} ```
/content/code_sandbox/apps/docs-app/src/app/content/echarts/echarts-demos/tree/demos/tree-demo-routing.module.ts
xml
2016-07-11T23:30:52
2024-08-15T15:20:45
covalent
Teradata/covalent
2,228
78
```xml <?xml version="1.0" encoding="UTF-8"?> <!-- ~ contributor license agreements. See the NOTICE file distributed with ~ this work for additional information regarding copyright ownership. ~ ~ path_to_url ~ ~ Unless required by applicable law or agreed to in writing, software ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --> <project xmlns="path_to_url" xmlns:xsi="path_to_url" xsi:schemaLocation="path_to_url path_to_url"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.shardingsphere</groupId> <artifactId>shardingsphere-cluster-mode-repository-provider</artifactId> <version>5.5.1-SNAPSHOT</version> </parent> <artifactId>shardingsphere-cluster-mode-repository-zookeeper</artifactId> <name>${project.artifactId}</name> <dependencies> <dependency> <groupId>org.apache.shardingsphere</groupId> <artifactId>shardingsphere-cluster-mode-repository-api</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.apache.shardingsphere</groupId> <artifactId>shardingsphere-cluster-mode-core</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.apache.shardingsphere</groupId> <artifactId>shardingsphere-test-util</artifactId> <version>${project.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.curator</groupId> <artifactId>curator-framework</artifactId> </dependency> <dependency> <groupId>org.apache.curator</groupId> <artifactId>curator-client</artifactId> </dependency> <dependency> <groupId>org.apache.curator</groupId> <artifactId>curator-recipes</artifactId> </dependency> <dependency> <groupId>org.apache.curator</groupId> <artifactId>curator-test</artifactId> </dependency> </dependencies> </project> ```
/content/code_sandbox/mode/type/cluster/repository/provider/zookeeper/pom.xml
xml
2016-01-18T12:49:26
2024-08-16T15:48:11
shardingsphere
apache/shardingsphere
19,707
499
```xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="path_to_url" xmlns:xsi="path_to_url" xsi:schemaLocation="path_to_url path_to_url"> <parent> <artifactId>whatsmars-reactor</artifactId> <groupId>org.hongxi</groupId> <version>2021.4.1</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>whatsmars-reactor-core</artifactId> <dependencies> <dependency> <groupId>io.projectreactor</groupId> <artifactId>reactor-core</artifactId> </dependency> </dependencies> </project> ```
/content/code_sandbox/whatsmars-reactor/whatsmars-reactor-core/pom.xml
xml
2016-04-01T10:33:04
2024-08-14T23:44:08
whatsmars
javahongxi/whatsmars
1,952
162
```xml <?xml version="1.0" encoding="UTF-8"?> <!-- ~ contributor license agreements. See the NOTICE file distributed with ~ this work for additional information regarding copyright ownership. ~ ~ path_to_url ~ ~ Unless required by applicable law or agreed to in writing, software ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --> <e2e-test-cases> <test-case sql="ALTER LOGIN login_dev WITH NAME = login_dev_new" db-types="SQLServer" /> <test-case sql="ALTER LOGIN login_dev WITH PASSWORD = 'passwd_dev'" db-types="SQLServer" /> <test-case sql="ALTER LOGIN login1 ADD CREDENTIAL credential" db-types="SQLServer" /> <test-case sql="ALTER LOGIN login1 ENABLE" db-types="SQLServer" /> <test-case sql="ALTER LOGIN login1_bak WITH NAME = login1" db-types="SQLServer" /> <test-case sql="ALTER LOGIN login1 WITH DEFAULT_DATABASE = database" db-types="SQLServer" /> <test-case sql="ALTER LOGIN login1 WITH PASSWORD = 0x01000CF35567C60BFB41EBDE4CF700A985A13D773D6B45B90900 HASHED" db-types="SQLServer" /> <test-case sql="ALTER LOGIN login1 WITH PASSWORD = 'password'" db-types="SQLServer" /> <test-case sql="ALTER LOGIN login1 WITH PASSWORD = 'password' OLD_PASSWORD = 'password'" db-types="SQLServer" /> <test-case sql="ALTER LOGIN login1 WITH PASSWORD = 'password' UNLOCK" db-types="SQLServer" /> </e2e-test-cases> ```
/content/code_sandbox/test/e2e/sql/src/test/resources/cases/dcl/e2e-dcl-alter-login.xml
xml
2016-01-18T12:49:26
2024-08-16T15:48:11
shardingsphere
apache/shardingsphere
19,707
371
```xml /** * @file Automatically generated by @tsed/barrels. */ export * from "./adapters/FileSyncAdapter.js"; export * from "./adapters/LowDbAdapter.js"; export * from "./adapters/MemoryAdapter.js"; export * from "./decorators/indexed.js"; export * from "./decorators/injectAdapter.js"; export * from "./domain/Adapter.js"; export * from "./domain/AdaptersSettings.js"; export * from "./services/Adapters.js"; ```
/content/code_sandbox/packages/orm/adapters/src/index.ts
xml
2016-02-21T18:38:47
2024-08-14T21:19:48
tsed
tsedio/tsed
2,817
98
```xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="path_to_url" xmlns:tools="path_to_url" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center" tools:context=".MainActivity"> <Button android:id="@+id/btn" android:layout_width="match_parent" android:layout_height="wrap_content" android:text=""/> <Button android:id="@+id/btn_k" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="k"/> <Button android:id="@+id/btn_fix" android:layout_width="match_parent" android:layout_height="wrap_content" android:visibility="gone" android:text=""/> </LinearLayout> ```
/content/code_sandbox/app/src/main/res/layout/activity_main.xml
xml
2016-05-18T03:51:41
2024-08-09T09:00:29
StockChart
AndroidJiang/StockChart
1,086
191
```xml import {shell} from 'electron'; class _ShellUtil { openExternal(url: string) { try { const urlObj = new URL(url); if (urlObj.protocol === 'http:' || urlObj.protocol === 'https:') { shell.openExternal(url); } else { console.error(`url is not valid. url = ${url}`); } } catch(e) { console.error(e); console.error(`url is not valid. url = ${url}`); } } } export const ShellUtil = new _ShellUtil(); ```
/content/code_sandbox/src/Renderer/Library/Util/ShellUtil.ts
xml
2016-05-10T12:55:31
2024-08-11T04:32:50
jasper
jasperapp/jasper
1,318
119
```xml <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="path_to_url"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform> <ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectGuid>{4598E620-3F15-4F66-B01A-B7F9E45CE659}</ProjectGuid> <OutputType>Exe</OutputType> <RootNamespace>MyMetalGame</RootNamespace> <IPhoneResourcePrefix>Resources</IPhoneResourcePrefix> <AssemblyName>MyMetalGame</AssemblyName> <LangVersion>latest</LangVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\iPhoneSimulator\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <MtouchArch>x86_64</MtouchArch> <MtouchLink>None</MtouchLink> <MtouchDebug>true</MtouchDebug> <MtouchProfiling>true</MtouchProfiling> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' "> <DebugType>full</DebugType> <Optimize>true</Optimize> <OutputPath>bin\iPhoneSimulator\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <MtouchArch>x86_64</MtouchArch> <MtouchLink>None</MtouchLink> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\iPhone\Debug</OutputPath> <DefineConstants>DEBUG;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <MtouchArch>ARM64</MtouchArch> <CodesignEntitlements>Entitlements.plist</CodesignEntitlements> <MtouchProfiling>true</MtouchProfiling> <CodesignKey>iPhone Developer</CodesignKey> <MtouchDebug>true</MtouchDebug> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' "> <DebugType>full</DebugType> <Optimize>true</Optimize> <OutputPath>bin\iPhone\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <CodesignEntitlements>Entitlements.plist</CodesignEntitlements> <MtouchArch>ARM64</MtouchArch> <CodesignKey>iPhone Developer</CodesignKey> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> <Reference Include="Xamarin.iOS" /> </ItemGroup> <ItemGroup> <ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Contents.json" /> </ItemGroup> <ItemGroup> <InterfaceDefinition Include="Resources\LaunchScreen.xib" /> <InterfaceDefinition Include="MainStoryboard_iPhone.storyboard" /> <InterfaceDefinition Include="MainStoryboard_iPad.storyboard" /> </ItemGroup> <ItemGroup> <Metal Include="Resources\Shaders.metal" /> </ItemGroup> <ItemGroup> <None Include="Info.plist" /> <None Include="Entitlements.plist" /> </ItemGroup> <ItemGroup> <Compile Include="Main.cs" /> <Compile Include="AppDelegate.cs" /> <Compile Include="GameViewController.cs" /> <Compile Include="GameViewController.designer.cs"> <DependentUpon>GameViewController.cs</DependentUpon> </Compile> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" /> <ItemGroup> <ProjectReference Include="..\MyKeyboardExtension\MyKeyboardExtension.csproj"> <Project>{20D55DE9-D8AF-4963-B2B4-D7E8A91FCA9C}</Project> <Name>MyKeyboardExtension</Name> <IsAppExtension>True</IsAppExtension> </ProjectReference> </ItemGroup> </Project> ```
/content/code_sandbox/tests/common/TestProjects/MyMetalGame/MyMetalGame.csproj
xml
2016-04-20T18:24:26
2024-08-16T13:29:19
xamarin-macios
xamarin/xamarin-macios
2,436
1,135
```xml import * as React from 'react'; import { AbstractReactFactory, GenerateWidgetEvent } from '@projectstorm/react-canvas-core'; import { DiagramEngine } from '@projectstorm/react-diagrams'; import { EditableLabelModel } from './EditableLabelModel'; import { EditableLabelWidget } from './EditableLabelWidget'; export class EditableLabelFactory extends AbstractReactFactory<EditableLabelModel, DiagramEngine> { constructor() { super('editable-label'); } generateModel(): EditableLabelModel { return new EditableLabelModel(); } generateReactWidget(event: GenerateWidgetEvent<EditableLabelModel>): JSX.Element { return <EditableLabelWidget model={event.model} />; } } ```
/content/code_sandbox/diagrams-demo-gallery/demos/demo-custom-link-label/EditableLabelFactory.tsx
xml
2016-06-03T09:10:01
2024-08-16T15:25:38
react-diagrams
projectstorm/react-diagrams
8,568
148
```xml import { IMSGraphService } from "./IMSGraphService"; import { IUserProperties } from "./IUserProperties"; import { MSGraphClient } from "@microsoft/sp-http"; import { Log } from "@microsoft/sp-core-library"; const LOG_SOURCE = "MSGraphService"; export class MSGraphService implements IMSGraphService{ public async getUserProperties(email:string,client:MSGraphClient):Promise<IUserProperties[]>{ const userProperties:IUserProperties[] = []; try { //let client:MSGraphClient = await context.msGraphClientFactory.getClient().then(); const endPoint = `/Users/${email}`; const response = await client.api(`${endPoint}`).version("v1.0").get(); if(response){ userProperties.push({ businessPhone:response.businessPhones[0], displayName:response.displayName, email:response.mail, JobTitle:response.jobTitle, OfficeLocation:response.officeLocation, mobilePhone:response.mobilePhone, preferredLanguage:response.preferredLanguage }); } } catch (error) { console.log(error); Log.error(LOG_SOURCE+"getUserProperties():",error); } return userProperties; } public async getUserPropertiesByLastName(searchFor:string,client:MSGraphClient):Promise<IUserProperties[]>{ const userProperties:IUserProperties[] = []; try { const res = await client.api("users") .version("v1.0") .filter(`(startswith(surname,'${escape(searchFor)}'))`).get(); if(res.value.length !== 0){ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any res.value.map((_userProperty:any,_index:any)=>{ if(_userProperty.mail !== null){ userProperties.push({ businessPhone:_userProperty.businessPhones[0], displayName:_userProperty.displayName, email:_userProperty.mail, JobTitle:_userProperty.jobTitle, OfficeLocation:_userProperty.officeLocation, mobilePhone:_userProperty.mobilePhone, preferredLanguage:_userProperty.preferredLanguage }); } }); } } catch (error) { console.log(error); Log.error(LOG_SOURCE+"getUserPropertiesByLastName():",error); } return userProperties; } public async getUserPropertiesByFirstName(searchFor:string,client:MSGraphClient):Promise<IUserProperties[]>{ const userProperties:IUserProperties[] = []; try { const res = await client.api("users") .version("v1.0") .filter(`(startswith(givenName,'${escape(searchFor)}'))`).get(); if(res.value.length !== 0){ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any res.value.map((_userProperty:any,_index:any)=>{ if(_userProperty.mail !== null){ userProperties.push({ businessPhone:_userProperty.businessPhones[0], displayName:_userProperty.displayName, email:_userProperty.mail, JobTitle:_userProperty.jobTitle, OfficeLocation:_userProperty.officeLocation, mobilePhone:_userProperty.mobilePhone, preferredLanguage:_userProperty.preferredLanguage }); } }); } } catch (error) { console.log(error); Log.error(LOG_SOURCE+"getUserPropertiesBySearch():",error); } return userProperties; } public async getUserPropertiesBySearch(searchFor:string,client:MSGraphClient):Promise<IUserProperties[]>{ const userProperties:IUserProperties[] = []; try { const res = await client.api("users") .version("v1.0") .filter(`(startswith(displayName,'${escape(searchFor)}'))`).get(); if(res.value.length !== 0){ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any res.value.map((_userProperty:any,_index:any)=>{ userProperties.push({ businessPhone:_userProperty.businessPhones[0], displayName:_userProperty.displayName, email:_userProperty.mail, JobTitle:_userProperty.jobTitle, OfficeLocation:_userProperty.officeLocation, mobilePhone:_userProperty.mobilePhone, preferredLanguage:_userProperty.preferredLanguage }); }); } } catch (error) { console.log(error); Log.error(LOG_SOURCE+"getUserPropertiesBySearch():",error); } return userProperties; } } ```
/content/code_sandbox/samples/react-graph-telephonedirectory/src/Services/MSGraphService.ts
xml
2016-08-30T17:21:43
2024-08-16T18:41:32
sp-dev-fx-webparts
pnp/sp-dev-fx-webparts
2,027
944
```xml interface i2 { foo: (/**param help*/b: number) => string; } ```
/content/code_sandbox/tests/format/typescript/compiler/commentsInterface.ts
xml
2016-11-29T17:13:37
2024-08-16T17:29:57
prettier
prettier/prettier
48,913
21
```xml import * as React from 'react'; import createSvgIcon from '../utils/createSvgIcon'; const DonutChartIcon = createSvgIcon({ svg: ({ classes }) => ( <svg xmlns="path_to_url" viewBox="0 0 2048 2048" className={classes.svg} focusable="false"> <path d="M1024 128q123 0 237 32t214 90 182 141 140 181 91 214 32 238q0 123-32 237t-90 214-141 182-181 140-214 91-238 32q-123 0-237-32t-214-90-182-141-140-181-91-214-32-238q0-123 32-237t90-214 141-182 181-140 214-91 238-32zm128 402q84 22 154 69t122 112 79 146 29 167h256q0-140-48-267t-133-228-203-169-256-93v263zm256 494q0-79-30-149t-82-122-123-83-149-30q-80 0-149 30t-122 82-83 123-30 149q0 80 30 149t82 122 122 83 150 30q79 0 149-30t122-82 83-122 30-150zm-384 768q140 0 267-48t228-133 169-203 93-256h-263q-22 84-69 154t-112 122-146 79-167 29q-106 0-199-40t-162-110-110-163-41-199q0-106 40-199t110-162 163-110 199-41V256q-106 0-204 27t-183 78-156 120-120 155-77 184-28 204q0 106 27 204t78 183 120 156 155 120 184 77 204 28z" /> </svg> ), displayName: 'DonutChartIcon', }); export default DonutChartIcon; ```
/content/code_sandbox/packages/react-icons-mdl2/src/components/DonutChartIcon.tsx
xml
2016-06-06T15:03:44
2024-08-16T18:49:29
fluentui
microsoft/fluentui
18,221
508
```xml <?xml version="1.0" encoding="utf-8"?> <doc> <assembly> <name>System.Linq</name> </assembly> <members> <member name="T:System.Linq.Enumerable"> <summary> <see cref="T:System.Collections.Generic.IEnumerable`1" /> static (Visual Basic Shared) </summary> </member> <member name="M:System.Linq.Enumerable.Aggregate``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``0,``0})"> <summary></summary> <returns></returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="func"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="func" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Aggregate``2(System.Collections.Generic.IEnumerable{``0},``1,System.Func{``1,``0,``1})"> <summary></summary> <returns></returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="seed"></param> <param name="func"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TAccumulate"></typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="func" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Aggregate``3(System.Collections.Generic.IEnumerable{``0},``1,System.Func{``1,``0,``1},System.Func{``1,``2})"> <summary></summary> <returns></returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="seed"></param> <param name="func"></param> <param name="resultSelector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TAccumulate"></typeparam> <typeparam name="TResult"></typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /><paramref name="func" /> <paramref name="resultSelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.All``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Boolean})"> <summary></summary> <returns> true false</returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="predicate"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="predicate" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Any``1(System.Collections.Generic.IEnumerable{``0})"> <summary></summary> <returns> true false</returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Any``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Boolean})"> <summary></summary> <returns> true false</returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="predicate"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="predicate" /> null </exception> </member> <member name="M:System.Linq.Enumerable.AsEnumerable``1(System.Collections.Generic.IEnumerable{``0})"> <summary> <see cref="T:System.Collections.Generic.IEnumerable`1" /> </summary> <returns> <see cref="T:System.Collections.Generic.IEnumerable`1" /> </returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /> </param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> </member> <member name="M:System.Linq.Enumerable.Average(System.Collections.Generic.IEnumerable{System.Decimal})"> <summary> <see cref="T:System.Decimal" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Decimal" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Average(System.Collections.Generic.IEnumerable{System.Double})"> <summary> <see cref="T:System.Double" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Double" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Average(System.Collections.Generic.IEnumerable{System.Int32})"> <summary> <see cref="T:System.Int32" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Int32" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Average(System.Collections.Generic.IEnumerable{System.Int64})"> <summary> <see cref="T:System.Int64" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Int64" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Average(System.Collections.Generic.IEnumerable{System.Nullable{System.Decimal}})"> <summary>null <see cref="T:System.Decimal" /> </summary> <returns> null null</returns> <param name="source"> null <see cref="T:System.Decimal" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Decimal.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Average(System.Collections.Generic.IEnumerable{System.Nullable{System.Double}})"> <summary>null <see cref="T:System.Double" /> </summary> <returns> null null</returns> <param name="source"> null <see cref="T:System.Double" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Average(System.Collections.Generic.IEnumerable{System.Nullable{System.Int32}})"> <summary>null <see cref="T:System.Int32" /> </summary> <returns> null null</returns> <param name="source"> null <see cref="T:System.Int32" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Int64.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Average(System.Collections.Generic.IEnumerable{System.Nullable{System.Int64}})"> <summary>null <see cref="T:System.Int64" /> </summary> <returns> null null</returns> <param name="source"> null <see cref="T:System.Int64" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Int64.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Average(System.Collections.Generic.IEnumerable{System.Nullable{System.Single}})"> <summary>null <see cref="T:System.Single" /> </summary> <returns> null null</returns> <param name="source"> null <see cref="T:System.Single" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Average(System.Collections.Generic.IEnumerable{System.Single})"> <summary> <see cref="T:System.Single" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Single" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Average``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Decimal})"> <summary> <see cref="T:System.Decimal" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Decimal.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Average``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Double})"> <summary> <see cref="T:System.Double" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Average``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Int32})"> <summary> <see cref="T:System.Int32" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Int64.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Average``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Int64})"> <summary> <see cref="T:System.Int64" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"></typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Int64.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Average``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Nullable{System.Decimal}})"> <summary> null <see cref="T:System.Decimal" /> </summary> <returns> null null</returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Decimal.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Average``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Nullable{System.Double}})"> <summary> null <see cref="T:System.Double" /> </summary> <returns> null null</returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Average``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Nullable{System.Int32}})"> <summary> null <see cref="T:System.Int32" /> </summary> <returns> null null</returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Int64.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Average``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Nullable{System.Int64}})"> <summary> null <see cref="T:System.Int64" /> </summary> <returns> null null</returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> </member> <member name="M:System.Linq.Enumerable.Average``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Nullable{System.Single}})"> <summary> null <see cref="T:System.Single" /> </summary> <returns> null null</returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Average``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Single})"> <summary> <see cref="T:System.Single" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Cast``1(System.Collections.IEnumerable)"> <summary> <see cref="T:System.Collections.IEnumerable" /> </summary> <returns> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="source"> <paramref name="TResult" /> <see cref="T:System.Collections.IEnumerable" /></param> <typeparam name="TResult"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.InvalidCastException"> <paramref name="TResult" /> </exception> </member> <member name="M:System.Linq.Enumerable.Concat``1(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``0})"> <summary>2 </summary> <returns>2 <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="first"></param> <param name="second"></param> <typeparam name="TSource"></typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="first" /> <paramref name="second" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Contains``1(System.Collections.Generic.IEnumerable{``0},``0)"> <summary></summary> <returns> true false</returns> <param name="source"></param> <param name="value"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Contains``1(System.Collections.Generic.IEnumerable{``0},``0,System.Collections.Generic.IEqualityComparer{``0})"> <summary> <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> </summary> <returns> true false</returns> <param name="source"></param> <param name="value"></param> <param name="comparer"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Count``1(System.Collections.Generic.IEnumerable{``0})"> <summary></summary> <returns></returns> <param name="source"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.OverflowException"> <paramref name="source" /> <see cref="F:System.Int32.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Count``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Boolean})"> <summary></summary> <returns></returns> <param name="source"></param> <param name="predicate"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="predicate" /> null </exception> <exception cref="T:System.OverflowException"> <paramref name="source" /> <see cref="F:System.Int32.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.DefaultIfEmpty``1(System.Collections.Generic.IEnumerable{``0})"> <summary> </summary> <returns> <paramref name="source" /> <paramref name="TSource" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /> <paramref name="source" /></returns> <param name="source"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.DefaultIfEmpty``1(System.Collections.Generic.IEnumerable{``0},``0)"> <summary> </summary> <returns> <paramref name="source" /> <paramref name="defaultValue" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /> <paramref name="source" /></returns> <param name="source"></param> <param name="defaultValue"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> </member> <member name="M:System.Linq.Enumerable.Distinct``1(System.Collections.Generic.IEnumerable{``0})"> <summary></summary> <returns> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="source"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Distinct``1(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEqualityComparer{``0})"> <summary> <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> </summary> <returns> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="source"></param> <param name="comparer"> <see cref="T:System.Collections.Generic.IEqualityComparer`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.ElementAt``1(System.Collections.Generic.IEnumerable{``0},System.Int32)"> <summary></summary> <returns> </returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="index">0 </param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.ArgumentOutOfRangeException"> <paramref name="index" /> 0 <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.ElementAtOrDefault``1(System.Collections.Generic.IEnumerable{``0},System.Int32)"> <summary></summary> <returns> default (<paramref name="TSource" />) </returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="index">0 </param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Empty``1"> <summary> <see cref="T:System.Collections.Generic.IEnumerable`1" /> </summary> <returns> <paramref name="TResult" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <typeparam name="TResult"> <see cref="T:System.Collections.Generic.IEnumerable`1" /> </typeparam> </member> <member name="M:System.Linq.Enumerable.Except``1(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``0})"> <summary>2 </summary> <returns>2 </returns> <param name="first"> <paramref name="second" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="second"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <typeparam name="TSource"></typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="first" /> <paramref name="second" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Except``1(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEqualityComparer{``0})"> <summary> <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> 2 </summary> <returns>2 </returns> <param name="first"> <paramref name="second" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="second"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="comparer"> <see cref="T:System.Collections.Generic.IEqualityComparer`1" /></param> <typeparam name="TSource"></typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="first" /> <paramref name="second" /> null </exception> </member> <member name="M:System.Linq.Enumerable.First``1(System.Collections.Generic.IEnumerable{``0})"> <summary></summary> <returns></returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.InvalidOperationException"> </exception> </member> <member name="M:System.Linq.Enumerable.First``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Boolean})"> <summary></summary> <returns></returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="predicate"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="predicate" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="predicate" /> </exception> </member> <member name="M:System.Linq.Enumerable.FirstOrDefault``1(System.Collections.Generic.IEnumerable{``0})"> <summary></summary> <returns> <paramref name="source" /> default(<paramref name="TSource" />) <paramref name="source" /> </returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.FirstOrDefault``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Boolean})"> <summary></summary> <returns> <paramref name="source" /> <paramref name="predicate" /> default(<paramref name="TSource" />)<paramref name="predicate" /> <paramref name="source" /> </returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="predicate"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="predicate" /> null </exception> </member> <member name="M:System.Linq.Enumerable.GroupBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1})"> <summary> </summary> <returns>C# IEnumerable&lt;IGrouping&lt;TKey, TSource&gt;&gt;Visual Basic IEnumerable(Of IGrouping(Of TKey, TSource)) <see cref="T:System.Linq.IGrouping`2" /> </returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="keySelector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="keySelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.GroupBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Collections.Generic.IEqualityComparer{``1})"> <summary> </summary> <returns>C# IEnumerable&lt;IGrouping&lt;TKey, TSource&gt;&gt;Visual Basic IEnumerable(Of IGrouping(Of TKey, TSource)) <see cref="T:System.Linq.IGrouping`2" /> </returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="keySelector"></param> <param name="comparer"> <see cref="T:System.Collections.Generic.IEqualityComparer`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="keySelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.GroupBy``3(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Func{``0,``2})"> <summary> </summary> <returns>C# IEnumerable&lt;IGrouping&lt;TKey, TElement&gt;&gt;Visual Basic IEnumerable(Of IGrouping(Of TKey, TElement)) <see cref="T:System.Linq.IGrouping`2" /> <paramref name="TElement" /> </returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="keySelector"></param> <param name="elementSelector"> <see cref="T:System.Linq.IGrouping`2" /> </param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <typeparam name="TElement"> <see cref="T:System.Linq.IGrouping`2" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /><paramref name="keySelector" /> <paramref name="elementSelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.GroupBy``3(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Func{``0,``2},System.Collections.Generic.IEqualityComparer{``1})"> <summary> </summary> <returns>C# IEnumerable&lt;IGrouping&lt;TKey, TElement&gt;&gt;Visual Basic IEnumerable(Of IGrouping(Of TKey, TElement)) <see cref="T:System.Linq.IGrouping`2" /> <paramref name="TElement" /> </returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="keySelector"></param> <param name="elementSelector"> <see cref="T:System.Linq.IGrouping`2" /> </param> <param name="comparer"> <see cref="T:System.Collections.Generic.IEqualityComparer`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <typeparam name="TElement"> <see cref="T:System.Linq.IGrouping`2" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /><paramref name="keySelector" /> <paramref name="elementSelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.GroupBy``4(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Func{``0,``2},System.Func{``1,System.Collections.Generic.IEnumerable{``2},``3})"> <summary> </summary> <returns> <paramref name="TResult" /> </returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="keySelector"></param> <param name="elementSelector"> <see cref="T:System.Linq.IGrouping`2" /> </param> <param name="resultSelector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <typeparam name="TElement"> <see cref="T:System.Linq.IGrouping`2" /> </typeparam> <typeparam name="TResult"> <paramref name="resultSelector" /> </typeparam> </member> <member name="M:System.Linq.Enumerable.GroupBy``4(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Func{``0,``2},System.Func{``1,System.Collections.Generic.IEnumerable{``2},``3},System.Collections.Generic.IEqualityComparer{``1})"> <summary> </summary> <returns> <paramref name="TResult" /> </returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="keySelector"></param> <param name="elementSelector"> <see cref="T:System.Linq.IGrouping`2" /> </param> <param name="resultSelector"></param> <param name="comparer"> <see cref="T:System.Collections.Generic.IEqualityComparer`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <typeparam name="TElement"> <see cref="T:System.Linq.IGrouping`2" /> </typeparam> <typeparam name="TResult"> <paramref name="resultSelector" /> </typeparam> </member> <member name="M:System.Linq.Enumerable.GroupBy``3(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Func{``1,System.Collections.Generic.IEnumerable{``0},``2})"> <summary> </summary> <returns> <paramref name="TResult" /> </returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="keySelector"></param> <param name="resultSelector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <typeparam name="TResult"> <paramref name="resultSelector" /> </typeparam> </member> <member name="M:System.Linq.Enumerable.GroupBy``3(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Func{``1,System.Collections.Generic.IEnumerable{``0},``2},System.Collections.Generic.IEqualityComparer{``1})"> <summary> </summary> <returns> <paramref name="TResult" /> </returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="keySelector"></param> <param name="resultSelector"></param> <param name="comparer"> <see cref="T:System.Collections.Generic.IEqualityComparer`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <typeparam name="TResult"> <paramref name="resultSelector" /> </typeparam> </member> <member name="M:System.Linq.Enumerable.GroupJoin``4(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Func{``0,System.Collections.Generic.IEnumerable{``1},``3})"> <summary> 2 </summary> <returns>2 <paramref name="TResult" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="outer"></param> <param name="inner"></param> <param name="outerKeySelector"></param> <param name="innerKeySelector">2 </param> <param name="resultSelector">2 </param> <typeparam name="TOuter"></typeparam> <typeparam name="TInner">2 </typeparam> <typeparam name="TKey"> </typeparam> <typeparam name="TResult"></typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="outer" /><paramref name="inner" /><paramref name="outerKeySelector" /><paramref name="innerKeySelector" /> <paramref name="resultSelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.GroupJoin``4(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Func{``0,System.Collections.Generic.IEnumerable{``1},``3},System.Collections.Generic.IEqualityComparer{``2})"> <summary> 2 <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> </summary> <returns>2 <paramref name="TResult" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="outer"></param> <param name="inner"></param> <param name="outerKeySelector"></param> <param name="innerKeySelector">2 </param> <param name="resultSelector">2 </param> <param name="comparer"> <see cref="T:System.Collections.Generic.IEqualityComparer`1" /></param> <typeparam name="TOuter"></typeparam> <typeparam name="TInner">2 </typeparam> <typeparam name="TKey"> </typeparam> <typeparam name="TResult"></typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="outer" /><paramref name="inner" /><paramref name="outerKeySelector" /><paramref name="innerKeySelector" /> <paramref name="resultSelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Intersect``1(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``0})"> <summary>2 </summary> <returns>2 </returns> <param name="first"> <paramref name="second" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="second"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <typeparam name="TSource"></typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="first" /> <paramref name="second" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Intersect``1(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEqualityComparer{``0})"> <summary> <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> 2 </summary> <returns>2 </returns> <param name="first"> <paramref name="second" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="second"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="comparer"> <see cref="T:System.Collections.Generic.IEqualityComparer`1" /></param> <typeparam name="TSource"></typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="first" /> <paramref name="second" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Join``4(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Func{``0,``1,``3})"> <summary> 2 </summary> <returns>2 <paramref name="TResult" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="outer"></param> <param name="inner"></param> <param name="outerKeySelector"></param> <param name="innerKeySelector">2 </param> <param name="resultSelector"> 2 </param> <typeparam name="TOuter"></typeparam> <typeparam name="TInner">2 </typeparam> <typeparam name="TKey"> </typeparam> <typeparam name="TResult"></typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="outer" /><paramref name="inner" /><paramref name="outerKeySelector" /><paramref name="innerKeySelector" /> <paramref name="resultSelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Join``4(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Func{``0,``1,``3},System.Collections.Generic.IEqualityComparer{``2})"> <summary> 2 <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> </summary> <returns>2 <paramref name="TResult" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="outer"></param> <param name="inner"></param> <param name="outerKeySelector"></param> <param name="innerKeySelector">2 </param> <param name="resultSelector"> 2 </param> <param name="comparer"> <see cref="T:System.Collections.Generic.IEqualityComparer`1" /></param> <typeparam name="TOuter"></typeparam> <typeparam name="TInner">2 </typeparam> <typeparam name="TKey"> </typeparam> <typeparam name="TResult"></typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="outer" /><paramref name="inner" /><paramref name="outerKeySelector" /><paramref name="innerKeySelector" /> <paramref name="resultSelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Last``1(System.Collections.Generic.IEnumerable{``0})"> <summary></summary> <returns> </returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.InvalidOperationException"> </exception> </member> <member name="M:System.Linq.Enumerable.Last``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Boolean})"> <summary></summary> <returns></returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="predicate"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="predicate" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="predicate" /> </exception> </member> <member name="M:System.Linq.Enumerable.LastOrDefault``1(System.Collections.Generic.IEnumerable{``0})"> <summary></summary> <returns> default (<paramref name="TSource" />) <see cref="T:System.Collections.Generic.IEnumerable`1" /> </returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.LastOrDefault``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Boolean})"> <summary></summary> <returns> default (<paramref name="TSource" />)</returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="predicate"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="predicate" /> null </exception> </member> <member name="M:System.Linq.Enumerable.LongCount``1(System.Collections.Generic.IEnumerable{``0})"> <summary> <see cref="T:System.Int64" /> </summary> <returns> </returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Int64.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.LongCount``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Boolean})"> <summary> <see cref="T:System.Int64" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="predicate"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="predicate" /> null </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Int64.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Max(System.Collections.Generic.IEnumerable{System.Decimal})"> <summary> <see cref="T:System.Decimal" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Decimal" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Max(System.Collections.Generic.IEnumerable{System.Double})"> <summary> <see cref="T:System.Double" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Double" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Max(System.Collections.Generic.IEnumerable{System.Int32})"> <summary> <see cref="T:System.Int32" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Int32" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Max(System.Collections.Generic.IEnumerable{System.Int64})"> <summary> <see cref="T:System.Int64" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Int64" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Max(System.Collections.Generic.IEnumerable{System.Nullable{System.Decimal}})"> <summary>null <see cref="T:System.Decimal" /> </summary> <returns> Nullable&lt;Decimal&gt; (C# ) Nullable(Of Decimal) (Visual Basic ) </returns> <param name="source"> null <see cref="T:System.Decimal" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Max(System.Collections.Generic.IEnumerable{System.Nullable{System.Double}})"> <summary>null <see cref="T:System.Double" /> </summary> <returns> Nullable&lt;Double&gt; (C# ) Nullable(Of Double) (Visual Basic ) </returns> <param name="source"> null <see cref="T:System.Double" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Max(System.Collections.Generic.IEnumerable{System.Nullable{System.Int32}})"> <summary>null <see cref="T:System.Int32" /> </summary> <returns> Nullable&lt;Int32&gt; (C# ) Nullable(Of Int32) (Visual Basic ) </returns> <param name="source"> null <see cref="T:System.Int32" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Max(System.Collections.Generic.IEnumerable{System.Nullable{System.Int64}})"> <summary>null <see cref="T:System.Int64" /> </summary> <returns> Nullable&lt;Int64&gt; (C# ) Nullable(Of Int64) (Visual Basic ) </returns> <param name="source"> null <see cref="T:System.Int64" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Max(System.Collections.Generic.IEnumerable{System.Nullable{System.Single}})"> <summary>null <see cref="T:System.Single" /> </summary> <returns> Nullable&lt;Single&gt; (C# ) Nullable(Of Single) (Visual Basic ) </returns> <param name="source"> null <see cref="T:System.Single" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Max(System.Collections.Generic.IEnumerable{System.Single})"> <summary> <see cref="T:System.Single" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Single" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Max``1(System.Collections.Generic.IEnumerable{``0})"> <summary> </summary> <returns></returns> <param name="source"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Max``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Decimal})"> <summary><see cref="T:System.Decimal" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Max``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Double})"> <summary><see cref="T:System.Double" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Max``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Int32})"> <summary><see cref="T:System.Int32" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Max``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Int64})"> <summary><see cref="T:System.Int64" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Max``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Nullable{System.Decimal}})"> <summary>null <see cref="T:System.Decimal" /> </summary> <returns> Nullable&lt;Decimal&gt; (C# ) Nullable(Of Decimal) (Visual Basic ) </returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Max``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Nullable{System.Double}})"> <summary>null <see cref="T:System.Double" /> </summary> <returns> Nullable&lt;Double&gt; (C# ) Nullable(Of Double) (Visual Basic ) </returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Max``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Nullable{System.Int32}})"> <summary>null <see cref="T:System.Int32" /> </summary> <returns> Nullable&lt;Int32&gt; (C# ) Nullable(Of Int32) (Visual Basic ) </returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Max``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Nullable{System.Int64}})"> <summary>null <see cref="T:System.Int64" /> </summary> <returns> Nullable&lt;Int64&gt; (C# ) Nullable(Of Int64) (Visual Basic ) </returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Max``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Nullable{System.Single}})"> <summary>null <see cref="T:System.Single" /> </summary> <returns> Nullable&lt;Single&gt; (C# ) Nullable(Of Single) (Visual Basic ) </returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Max``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Single})"> <summary><see cref="T:System.Single" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Max``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1})"> <summary> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TResult"> <paramref name="selector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Min(System.Collections.Generic.IEnumerable{System.Decimal})"> <summary> <see cref="T:System.Decimal" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Decimal" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Min(System.Collections.Generic.IEnumerable{System.Double})"> <summary> <see cref="T:System.Double" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Double" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Min(System.Collections.Generic.IEnumerable{System.Int32})"> <summary> <see cref="T:System.Int32" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Int32" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Min(System.Collections.Generic.IEnumerable{System.Int64})"> <summary> <see cref="T:System.Int64" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Int64" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Min(System.Collections.Generic.IEnumerable{System.Nullable{System.Decimal}})"> <summary>null <see cref="T:System.Decimal" /> </summary> <returns> Nullable&lt;Decimal&gt; (C# ) Nullable(Of Decimal) (Visual Basic ) </returns> <param name="source"> null <see cref="T:System.Decimal" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Min(System.Collections.Generic.IEnumerable{System.Nullable{System.Double}})"> <summary>null <see cref="T:System.Double" /> </summary> <returns> Nullable&lt;Double&gt; (C# ) Nullable(Of Double) (Visual Basic ) </returns> <param name="source"> null <see cref="T:System.Double" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Min(System.Collections.Generic.IEnumerable{System.Nullable{System.Int32}})"> <summary>null <see cref="T:System.Int32" /> </summary> <returns> Nullable&lt;Int32&gt; (C# ) Nullable(Of Int32) (Visual Basic ) </returns> <param name="source"> null <see cref="T:System.Int32" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Min(System.Collections.Generic.IEnumerable{System.Nullable{System.Int64}})"> <summary>null <see cref="T:System.Int64" /> </summary> <returns> Nullable&lt;Int64&gt; (C# ) Nullable(Of Int64) (Visual Basic ) </returns> <param name="source"> null <see cref="T:System.Int64" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Min(System.Collections.Generic.IEnumerable{System.Nullable{System.Single}})"> <summary>null <see cref="T:System.Single" /> </summary> <returns> Nullable&lt;Single&gt; (C# ) Nullable(Of Single) (Visual Basic ) </returns> <param name="source"> null <see cref="T:System.Single" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Min(System.Collections.Generic.IEnumerable{System.Single})"> <summary> <see cref="T:System.Single" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Single" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Min``1(System.Collections.Generic.IEnumerable{``0})"> <summary> </summary> <returns></returns> <param name="source"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Min``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Decimal})"> <summary><see cref="T:System.Decimal" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Min``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Double})"> <summary><see cref="T:System.Double" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Min``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Int32})"> <summary><see cref="T:System.Int32" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Min``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Int64})"> <summary><see cref="T:System.Int64" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Min``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Nullable{System.Decimal}})"> <summary>null <see cref="T:System.Decimal" /> </summary> <returns> Nullable&lt;Decimal&gt; (C# ) Nullable(Of Decimal) (Visual Basic ) </returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Min``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Nullable{System.Double}})"> <summary>null <see cref="T:System.Double" /> </summary> <returns> Nullable&lt;Double&gt; (C# ) Nullable(Of Double) (Visual Basic ) </returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Min``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Nullable{System.Int32}})"> <summary>null <see cref="T:System.Int32" /> </summary> <returns> Nullable&lt;Int32&gt; (C# ) Nullable(Of Int32) (Visual Basic ) </returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Min``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Nullable{System.Int64}})"> <summary>null <see cref="T:System.Int64" /> </summary> <returns> Nullable&lt;Int64&gt; (C# ) Nullable(Of Int64) (Visual Basic ) </returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Min``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Nullable{System.Single}})"> <summary>null <see cref="T:System.Single" /> </summary> <returns> Nullable&lt;Single&gt; (C# ) Nullable(Of Single) (Visual Basic ) </returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Min``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Single})"> <summary><see cref="T:System.Single" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="source" /> </exception> </member> <member name="M:System.Linq.Enumerable.Min``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1})"> <summary> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TResult"> <paramref name="selector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.OfType``1(System.Collections.IEnumerable)"> <summary> <see cref="T:System.Collections.IEnumerable" /> </summary> <returns> <paramref name="TResult" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="source"> <see cref="T:System.Collections.IEnumerable" /></param> <typeparam name="TResult"></typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.OrderBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1})"> <summary></summary> <returns> <see cref="T:System.Linq.IOrderedEnumerable`1" /></returns> <param name="source"></param> <param name="keySelector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="keySelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.OrderBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Collections.Generic.IComparer{``1})"> <summary></summary> <returns> <see cref="T:System.Linq.IOrderedEnumerable`1" /></returns> <param name="source"></param> <param name="keySelector"></param> <param name="comparer"> <see cref="T:System.Collections.Generic.IComparer`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="keySelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.OrderByDescending``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1})"> <summary></summary> <returns> <see cref="T:System.Linq.IOrderedEnumerable`1" /></returns> <param name="source"></param> <param name="keySelector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="keySelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.OrderByDescending``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Collections.Generic.IComparer{``1})"> <summary></summary> <returns> <see cref="T:System.Linq.IOrderedEnumerable`1" /></returns> <param name="source"></param> <param name="keySelector"></param> <param name="comparer"> <see cref="T:System.Collections.Generic.IComparer`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="keySelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Range(System.Int32,System.Int32)"> <summary></summary> <returns> IEnumerable&lt;Int32&gt; (C# ) IEnumerable(Of Int32) (Visual Basic )</returns> <param name="start"></param> <param name="count"></param> <exception cref="T:System.ArgumentOutOfRangeException"> <paramref name="count" /> 0 <paramref name="start" /> + <paramref name="count" /> -1 <see cref="F:System.Int32.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Repeat``1(``0,System.Int32)"> <summary> 1 </summary> <returns> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="element"></param> <param name="count"></param> <typeparam name="TResult"></typeparam> <exception cref="T:System.ArgumentOutOfRangeException"> <paramref name="count" /> 0 </exception> </member> <member name="M:System.Linq.Enumerable.Reverse``1(System.Collections.Generic.IEnumerable{``0})"> <summary></summary> <returns></returns> <param name="source"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Select``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1})"> <summary></summary> <returns> <paramref name="source" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TResult"> <paramref name="selector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Select``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Int32,``1})"> <summary></summary> <returns> <paramref name="source" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="source"></param> <param name="selector"> 2 </param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TResult"> <paramref name="selector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.SelectMany``3(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Collections.Generic.IEnumerable{``1}},System.Func{``0,``1,``2})"> <summary> <see cref="T:System.Collections.Generic.IEnumerable`1" /> 1 </summary> <returns> <paramref name="source" /> <paramref name="collectionSelector" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="source"></param> <param name="collectionSelector"></param> <param name="resultSelector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TCollection"> <paramref name="collectionSelector" /> </typeparam> <typeparam name="TResult"></typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /><paramref name="collectionSelector" /> <paramref name="resultSelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.SelectMany``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Collections.Generic.IEnumerable{``1}})"> <summary> <see cref="T:System.Collections.Generic.IEnumerable`1" /> 1 </summary> <returns> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TResult"> <paramref name="selector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.SelectMany``3(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Int32,System.Collections.Generic.IEnumerable{``1}},System.Func{``0,``1,``2})"> <summary> <see cref="T:System.Collections.Generic.IEnumerable`1" /> 1 </summary> <returns> <paramref name="source" /> <paramref name="collectionSelector" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="source"></param> <param name="collectionSelector"> 2 </param> <param name="resultSelector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TCollection"> <paramref name="collectionSelector" /> </typeparam> <typeparam name="TResult"></typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /><paramref name="collectionSelector" /> <paramref name="resultSelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.SelectMany``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Int32,System.Collections.Generic.IEnumerable{``1}})"> <summary> <see cref="T:System.Collections.Generic.IEnumerable`1" /> 1 </summary> <returns> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="source"></param> <param name="selector"> 2 </param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TResult"> <paramref name="selector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.SequenceEqual``1(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``0})"> <summary>2 </summary> <returns>2 true false</returns> <param name="first"> <paramref name="second" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="second"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <typeparam name="TSource"></typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="first" /> <paramref name="second" /> null </exception> </member> <member name="M:System.Linq.Enumerable.SequenceEqual``1(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEqualityComparer{``0})"> <summary> <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> 2 </summary> <returns>2 <paramref name="comparer" /> true false</returns> <param name="first"> <paramref name="second" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="second"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="comparer"> <see cref="T:System.Collections.Generic.IEqualityComparer`1" /></param> <typeparam name="TSource"></typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="first" /> <paramref name="second" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Single``1(System.Collections.Generic.IEnumerable{``0})"> <summary> 1 </summary> <returns> 1 </returns> <param name="source">1 <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.InvalidOperationException"></exception> </member> <member name="M:System.Linq.Enumerable.Single``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Boolean})"> <summary></summary> <returns> 1 </returns> <param name="source">1 <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="predicate"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="predicate" /> null </exception> <exception cref="T:System.InvalidOperationException"> <paramref name="predicate" /> <paramref name="predicate" /> </exception> </member> <member name="M:System.Linq.Enumerable.SingleOrDefault``1(System.Collections.Generic.IEnumerable{``0})"> <summary></summary> <returns> 1 default (<paramref name="TSource" />)</returns> <param name="source">1 <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.InvalidOperationException"></exception> </member> <member name="M:System.Linq.Enumerable.SingleOrDefault``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Boolean})"> <summary></summary> <returns> 1 default (<paramref name="TSource" />)</returns> <param name="source">1 <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="predicate"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="predicate" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Skip``1(System.Collections.Generic.IEnumerable{``0},System.Int32)"> <summary></summary> <returns> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="count"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.SkipWhile``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Boolean})"> <summary></summary> <returns> <paramref name="predicate" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="predicate"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="predicate" /> null </exception> </member> <member name="M:System.Linq.Enumerable.SkipWhile``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Int32,System.Boolean})"> <summary></summary> <returns> <paramref name="predicate" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="predicate"> 2 </param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="predicate" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Sum(System.Collections.Generic.IEnumerable{System.Decimal})"> <summary> <see cref="T:System.Decimal" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Decimal" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Decimal.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Sum(System.Collections.Generic.IEnumerable{System.Double})"> <summary> <see cref="T:System.Double" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Double" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Sum(System.Collections.Generic.IEnumerable{System.Int32})"> <summary> <see cref="T:System.Int32" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Int32" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Int32.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Sum(System.Collections.Generic.IEnumerable{System.Int64})"> <summary> <see cref="T:System.Int64" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Int64" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Int64.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Sum(System.Collections.Generic.IEnumerable{System.Nullable{System.Decimal}})"> <summary>null <see cref="T:System.Decimal" /> </summary> <returns></returns> <param name="source"> null <see cref="T:System.Decimal" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Decimal.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Sum(System.Collections.Generic.IEnumerable{System.Nullable{System.Double}})"> <summary>null <see cref="T:System.Double" /> </summary> <returns></returns> <param name="source"> null <see cref="T:System.Double" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Sum(System.Collections.Generic.IEnumerable{System.Nullable{System.Int32}})"> <summary>null <see cref="T:System.Int32" /> </summary> <returns></returns> <param name="source"> null <see cref="T:System.Int32" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Int32.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Sum(System.Collections.Generic.IEnumerable{System.Nullable{System.Int64}})"> <summary>null <see cref="T:System.Int64" /> </summary> <returns></returns> <param name="source"> null <see cref="T:System.Int64" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Int64.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Sum(System.Collections.Generic.IEnumerable{System.Nullable{System.Single}})"> <summary>null <see cref="T:System.Single" /> </summary> <returns></returns> <param name="source"> null <see cref="T:System.Single" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Sum(System.Collections.Generic.IEnumerable{System.Single})"> <summary> <see cref="T:System.Single" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Single" /> </param> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Sum``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Decimal})"> <summary> <see cref="T:System.Decimal" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Decimal.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Sum``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Double})"> <summary> <see cref="T:System.Double" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Sum``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Int32})"> <summary> <see cref="T:System.Int32" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Int32.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Sum``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Int64})"> <summary> <see cref="T:System.Int64" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Int64.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Sum``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Nullable{System.Decimal}})"> <summary> null <see cref="T:System.Decimal" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Decimal.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Sum``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Nullable{System.Double}})"> <summary> null <see cref="T:System.Double" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Sum``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Nullable{System.Int32}})"> <summary> null <see cref="T:System.Int32" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Int32.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Sum``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Nullable{System.Int64}})"> <summary> null <see cref="T:System.Int64" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> <exception cref="T:System.OverflowException"> <see cref="F:System.Int64.MaxValue" /> </exception> </member> <member name="M:System.Linq.Enumerable.Sum``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Nullable{System.Single}})"> <summary> null <see cref="T:System.Single" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Sum``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Single})"> <summary> <see cref="T:System.Single" /> </summary> <returns></returns> <param name="source"></param> <param name="selector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="selector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Take``1(System.Collections.Generic.IEnumerable{``0},System.Int32)"> <summary></summary> <returns> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="source"></param> <param name="count"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.TakeWhile``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Boolean})"> <summary></summary> <returns> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="source"></param> <param name="predicate"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="predicate" /> null </exception> </member> <member name="M:System.Linq.Enumerable.TakeWhile``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Int32,System.Boolean})"> <summary></summary> <returns> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="source"></param> <param name="predicate"> 2 </param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="predicate" /> null </exception> </member> <member name="M:System.Linq.Enumerable.ThenBy``2(System.Linq.IOrderedEnumerable{``0},System.Func{``0,``1})"> <summary></summary> <returns> <see cref="T:System.Linq.IOrderedEnumerable`1" /></returns> <param name="source"> <see cref="T:System.Linq.IOrderedEnumerable`1" /></param> <param name="keySelector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="keySelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.ThenBy``2(System.Linq.IOrderedEnumerable{``0},System.Func{``0,``1},System.Collections.Generic.IComparer{``1})"> <summary></summary> <returns> <see cref="T:System.Linq.IOrderedEnumerable`1" /></returns> <param name="source"> <see cref="T:System.Linq.IOrderedEnumerable`1" /></param> <param name="keySelector"></param> <param name="comparer"> <see cref="T:System.Collections.Generic.IComparer`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="keySelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.ThenByDescending``2(System.Linq.IOrderedEnumerable{``0},System.Func{``0,``1})"> <summary></summary> <returns> <see cref="T:System.Linq.IOrderedEnumerable`1" /></returns> <param name="source"> <see cref="T:System.Linq.IOrderedEnumerable`1" /></param> <param name="keySelector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="keySelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.ThenByDescending``2(System.Linq.IOrderedEnumerable{``0},System.Func{``0,``1},System.Collections.Generic.IComparer{``1})"> <summary></summary> <returns> <see cref="T:System.Linq.IOrderedEnumerable`1" /></returns> <param name="source"> <see cref="T:System.Linq.IOrderedEnumerable`1" /></param> <param name="keySelector"></param> <param name="comparer"> <see cref="T:System.Collections.Generic.IComparer`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="keySelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.ToArray``1(System.Collections.Generic.IEnumerable{``0})"> <summary> <see cref="T:System.Collections.Generic.IEnumerable`1" /> </summary> <returns></returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.ToDictionary``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1})"> <summary> <see cref="T:System.Collections.Generic.IEnumerable`1" /> <see cref="T:System.Collections.Generic.Dictionary`2" /> </summary> <returns> <see cref="T:System.Collections.Generic.Dictionary`2" /></returns> <param name="source"> <see cref="T:System.Collections.Generic.Dictionary`2" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="keySelector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="keySelector" /> null <paramref name="keySelector" /> null </exception> <exception cref="T:System.ArgumentException"> <paramref name="keySelector" /> 2 </exception> </member> <member name="M:System.Linq.Enumerable.ToDictionary``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Collections.Generic.IEqualityComparer{``1})"> <summary> <see cref="T:System.Collections.Generic.IEnumerable`1" /> <see cref="T:System.Collections.Generic.Dictionary`2" /> </summary> <returns> <see cref="T:System.Collections.Generic.Dictionary`2" /></returns> <param name="source"> <see cref="T:System.Collections.Generic.Dictionary`2" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="keySelector"></param> <param name="comparer"> <see cref="T:System.Collections.Generic.IEqualityComparer`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="keySelector" /> null <paramref name="keySelector" /> null </exception> <exception cref="T:System.ArgumentException"> <paramref name="keySelector" /> 2 </exception> </member> <member name="M:System.Linq.Enumerable.ToDictionary``3(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Func{``0,``2})"> <summary> <see cref="T:System.Collections.Generic.IEnumerable`1" /> <see cref="T:System.Collections.Generic.Dictionary`2" /> </summary> <returns> <paramref name="TElement" /> <see cref="T:System.Collections.Generic.Dictionary`2" /></returns> <param name="source"> <see cref="T:System.Collections.Generic.Dictionary`2" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="keySelector"></param> <param name="elementSelector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <typeparam name="TElement"> <paramref name="elementSelector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /><paramref name="keySelector" /> <paramref name="elementSelector" /> null <paramref name="keySelector" /> null </exception> <exception cref="T:System.ArgumentException"> <paramref name="keySelector" /> 2 </exception> </member> <member name="M:System.Linq.Enumerable.ToDictionary``3(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Func{``0,``2},System.Collections.Generic.IEqualityComparer{``1})"> <summary> <see cref="T:System.Collections.Generic.IEnumerable`1" /> <see cref="T:System.Collections.Generic.Dictionary`2" /> </summary> <returns> <paramref name="TElement" /> <see cref="T:System.Collections.Generic.Dictionary`2" /></returns> <param name="source"> <see cref="T:System.Collections.Generic.Dictionary`2" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="keySelector"></param> <param name="elementSelector"></param> <param name="comparer"> <see cref="T:System.Collections.Generic.IEqualityComparer`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <typeparam name="TElement"> <paramref name="elementSelector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /><paramref name="keySelector" /> <paramref name="elementSelector" /> null <paramref name="keySelector" /> null </exception> <exception cref="T:System.ArgumentException"> <paramref name="keySelector" /> 2 </exception> </member> <member name="M:System.Linq.Enumerable.ToList``1(System.Collections.Generic.IEnumerable{``0})"> <summary> <see cref="T:System.Collections.Generic.IEnumerable`1" /> <see cref="T:System.Collections.Generic.List`1" /> </summary> <returns> <see cref="T:System.Collections.Generic.List`1" /></returns> <param name="source"> <see cref="T:System.Collections.Generic.List`1" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> null </exception> </member> <member name="M:System.Linq.Enumerable.ToLookup``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1})"> <summary> <see cref="T:System.Collections.Generic.IEnumerable`1" /> <see cref="T:System.Linq.Lookup`2" /> </summary> <returns> <see cref="T:System.Linq.Lookup`2" /></returns> <param name="source"> <see cref="T:System.Linq.Lookup`2" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="keySelector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="keySelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.ToLookup``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Collections.Generic.IEqualityComparer{``1})"> <summary> <see cref="T:System.Collections.Generic.IEnumerable`1" /> <see cref="T:System.Linq.Lookup`2" /> </summary> <returns> <see cref="T:System.Linq.Lookup`2" /></returns> <param name="source"> <see cref="T:System.Linq.Lookup`2" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="keySelector"></param> <param name="comparer"> <see cref="T:System.Collections.Generic.IEqualityComparer`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="keySelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.ToLookup``3(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Func{``0,``2})"> <summary> <see cref="T:System.Collections.Generic.IEnumerable`1" /> <see cref="T:System.Linq.Lookup`2" /> </summary> <returns> <paramref name="TElement" /> <see cref="T:System.Linq.Lookup`2" /></returns> <param name="source"> <see cref="T:System.Linq.Lookup`2" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="keySelector"></param> <param name="elementSelector"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <typeparam name="TElement"> <paramref name="elementSelector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /><paramref name="keySelector" /> <paramref name="elementSelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.ToLookup``3(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Func{``0,``2},System.Collections.Generic.IEqualityComparer{``1})"> <summary> <see cref="T:System.Collections.Generic.IEnumerable`1" /> <see cref="T:System.Linq.Lookup`2" /> </summary> <returns> <paramref name="TElement" /> <see cref="T:System.Linq.Lookup`2" /></returns> <param name="source"> <see cref="T:System.Linq.Lookup`2" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="keySelector"></param> <param name="elementSelector"></param> <param name="comparer"> <see cref="T:System.Collections.Generic.IEqualityComparer`1" /></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <typeparam name="TElement"> <paramref name="elementSelector" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /><paramref name="keySelector" /> <paramref name="elementSelector" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Union``1(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``0})"> <summary>2 </summary> <returns>2 () <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="first"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="second"> 2 <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <typeparam name="TSource"></typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="first" /> <paramref name="second" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Union``1(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEqualityComparer{``0})"> <summary> <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> 2 </summary> <returns>2 () <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="first"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="second"> 2 <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="comparer"> <see cref="T:System.Collections.Generic.IEqualityComparer`1" /></param> <typeparam name="TSource"></typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="first" /> <paramref name="second" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Where``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Boolean})"> <summary></summary> <returns> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="predicate"></param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="predicate" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Where``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Int32,System.Boolean})"> <summary></summary> <returns> <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="source"> <see cref="T:System.Collections.Generic.IEnumerable`1" /></param> <param name="predicate"> 2 </param> <typeparam name="TSource"> <paramref name="source" /> </typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="source" /> <paramref name="predicate" /> null </exception> </member> <member name="M:System.Linq.Enumerable.Zip``3(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``1,``2})"> <summary>2 1 1 </summary> <returns>2 <see cref="T:System.Collections.Generic.IEnumerable`1" /></returns> <param name="first"> 1 </param> <param name="second"> 2 </param> <param name="resultSelector">2 </param> <typeparam name="TFirst">1 </typeparam> <typeparam name="TSecond">2 </typeparam> <typeparam name="TResult"></typeparam> <exception cref="T:System.ArgumentNullException"> <paramref name="first" /> <paramref name="second" /> null </exception> </member> <member name="T:System.Linq.IGrouping`2"> <summary></summary> <typeparam name="TKey"> <see cref="T:System.Linq.IGrouping`2" /> </typeparam> <typeparam name="TElement"> <see cref="T:System.Linq.IGrouping`2" /> </typeparam> <filterpriority>2</filterpriority> </member> <member name="P:System.Linq.IGrouping`2.Key"> <summary> <see cref="T:System.Linq.IGrouping`2" /> </summary> <returns> <see cref="T:System.Linq.IGrouping`2" /> </returns> </member> <member name="T:System.Linq.ILookup`2"> <summary> <see cref="T:System.Collections.Generic.IEnumerable`1" /> </summary> <typeparam name="TKey"> <see cref="T:System.Linq.ILookup`2" /> </typeparam> <typeparam name="TElement"> <see cref="T:System.Linq.ILookup`2" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /> </typeparam> <filterpriority>2</filterpriority> </member> <member name="M:System.Linq.ILookup`2.Contains(`0)"> <summary> <see cref="T:System.Linq.ILookup`2" /> </summary> <returns> <paramref name="key" /> <see cref="T:System.Linq.ILookup`2" /> true false</returns> <param name="key"> <see cref="T:System.Linq.ILookup`2" /> </param> </member> <member name="P:System.Linq.ILookup`2.Count"> <summary> <see cref="T:System.Linq.ILookup`2" /> </summary> <returns> <see cref="T:System.Linq.ILookup`2" /> </returns> </member> <member name="P:System.Linq.ILookup`2.Item(`0)"> <summary> <see cref="T:System.Collections.Generic.IEnumerable`1" /> </summary> <returns> <see cref="T:System.Collections.Generic.IEnumerable`1" /> </returns> <param name="key"></param> </member> <member name="T:System.Linq.IOrderedEnumerable`1"> <summary></summary> <typeparam name="TElement"></typeparam> <filterpriority>2</filterpriority> </member> <member name="M:System.Linq.IOrderedEnumerable`1.CreateOrderedEnumerable``1(System.Func{`0,``0},System.Collections.Generic.IComparer{``0},System.Boolean)"> <summary> <see cref="T:System.Linq.IOrderedEnumerable`1" /> </summary> <returns> <see cref="T:System.Linq.IOrderedEnumerable`1" /></returns> <param name="keySelector"> <see cref="T:System.Func`2" /></param> <param name="comparer"> <see cref="T:System.Collections.Generic.IComparer`1" /></param> <param name="descending"> true false</param> <typeparam name="TKey"> <paramref name="keySelector" /> </typeparam> <filterpriority>2</filterpriority> </member> <member name="T:System.Linq.Lookup`2"> <summary> 1 </summary> <typeparam name="TKey"> <see cref="T:System.Linq.Lookup`2" /> </typeparam> <typeparam name="TElement"> <see cref="T:System.Linq.Lookup`2" /> <see cref="T:System.Collections.Generic.IEnumerable`1" /> </typeparam> <filterpriority>2</filterpriority> </member> <member name="M:System.Linq.Lookup`2.ApplyResultSelector``1(System.Func{`0,System.Collections.Generic.IEnumerable{`1},``0})"> <summary></summary> <returns> <see cref="T:System.Linq.Lookup`2" /> 1 </returns> <param name="resultSelector"></param> <typeparam name="TResult"> <paramref name="resultSelector" /> </typeparam> <filterpriority>2</filterpriority> </member> <member name="M:System.Linq.Lookup`2.Contains(`0)"> <summary> <see cref="T:System.Linq.Lookup`2" /> </summary> <returns> <paramref name="key" /> <see cref="T:System.Linq.Lookup`2" /> true false</returns> <param name="key"> <see cref="T:System.Linq.Lookup`2" /> </param> </member> <member name="P:System.Linq.Lookup`2.Count"> <summary> <see cref="T:System.Linq.Lookup`2" /> </summary> <returns> <see cref="T:System.Linq.Lookup`2" /> </returns> </member> <member name="M:System.Linq.Lookup`2.GetEnumerator"> <summary> <see cref="T:System.Linq.Lookup`2" /> </summary> <returns> <see cref="T:System.Linq.Lookup`2" /> </returns> </member> <member name="P:System.Linq.Lookup`2.Item(`0)"> <summary></summary> <returns></returns> <param name="key"></param> </member> <member name="M:System.Linq.Lookup`2.System#Collections#IEnumerable#GetEnumerator"> <summary> <see cref="T:System.Linq.Lookup`2" /> </summary> <returns> <see cref="T:System.Linq.Lookup`2" /> </returns> </member> </members> </doc> ```
/content/code_sandbox/packages/System.Linq.4.0.0/ref/dotnet/ja/System.Linq.xml
xml
2016-04-24T09:50:47
2024-08-16T11:45:14
ILRuntime
Ourpalm/ILRuntime
2,976
28,143
```xml import { IContext } from '..'; import { IObjectTypeResolver } from '@graphql-tools/utils'; import { IPost } from '../../db/models/post'; const ForumPost: IObjectTypeResolver<IPost, IContext> = { async __resolveReference({ _id }, { models: { Post } }: IContext) { return Post.findById({ _id }); }, async category({ categoryId }, _, { models: { Category } }) { return categoryId && Category.findById(categoryId); }, async createdBy({ createdById }) { return createdById && { __typename: 'User', _id: createdById }; }, async updatedBy({ updatedById }) { return updatedById && { __typename: 'User', _id: updatedById }; }, async createdByCp({ createdByCpId }) { return ( createdByCpId && { __typename: 'ClientPortalUser', _id: createdByCpId } ); }, async updatedByCp({ updatedByCpId }) { return ( updatedByCpId && { __typename: 'ClientPortalUser', _id: updatedByCpId } ); }, async commentCount({ _id, commentCount }, _, { models: { Comment } }) { return commentCount || 0; }, async upVoteCount({ _id }, _, { models: { PostUpVote } }) { return PostUpVote.countDocuments({ contentId: _id }); }, async downVoteCount({ _id }, _, { models: { PostDownVote } }) { return PostDownVote.countDocuments({ contentId: _id }); }, async upVotes({ _id }, _, { models: { PostUpVote } }) { const upVotes = await PostUpVote.find({ contentId: _id }).lean(); return upVotes.map(v => ({ __typename: 'ClientPortalUser', _id: v.userId })); }, async downVotes({ _id }, _, { models: { PostDownVote } }) { const downVotes = await PostDownVote.find({ contentId: _id }).lean(); return downVotes.map(v => ({ __typename: 'ClientPortalUser', _id: v.userId })); }, async tags({ tagIds }) { return tagIds && tagIds.map(_id => ({ __typename: 'Tag', _id })); }, async pollOptions({ _id }, _, { models: { PollOption } }) { return PollOption.find({ postId: _id }) .sort({ order: 1 }) .lean(); }, async pollVoteCount({ _id }, _, { models: { PollVote, PollOption } }) { const pollOptions = await PollOption.find({ postId: _id }) .select('_id') .lean(); const pollOptionIds = pollOptions.map(o => o._id); return PollVote.countDocuments({ pollOptionId: { $in: pollOptionIds } }); }, async hasCurrentUserSavedIt({ _id }, _, { models: { SavedPost }, cpUser }) { if (!cpUser) { return false; } const savedPost = await SavedPost.findOne({ cpUserId: cpUser.userId, postId: _id }); return !!savedPost; }, async quizzes({ _id }, _, { models: { Quiz }, user }) { const query: any = { postId: _id }; if (!user) { query.state = 'PUBLISHED'; } return Quiz.find(query); } }; export default ForumPost; ```
/content/code_sandbox/packages/plugin-forum-api/src/graphql/resolvers/ForumPost.ts
xml
2016-11-11T06:54:50
2024-08-16T10:26:06
erxes
erxes/erxes
3,479
771
```xml /** * @file App logger * @module utils/logger * @author Surmon <path_to_url */ export const createLogger = (scope: string) => ({ // levels log: (...messages) => console.log('', `[${scope}]`, ...messages), info: (...messages) => console.info('', `[${scope}]`, ...messages), warn: (...messages) => console.warn('', `[${scope}]`, ...messages), error: (...messages) => console.error('', `[${scope}]`, ...messages), debug: (...messages) => console.debug('', `[${scope}]`, ...messages), // aliases success: (...messages) => console.log('', `[${scope}]`, ...messages), failure: (...messages) => console.warn('', `[${scope}]`, ...messages) }) export default createLogger('APP') ```
/content/code_sandbox/src/utils/logger.ts
xml
2016-09-23T02:02:33
2024-08-16T03:13:52
surmon.me
surmon-china/surmon.me
2,092
179
```xml export let input = { id: 'Parent', type: 'object', additionalProperties: false, patternProperties: { '^[a-zA-Z]+': { id: 'Child', type: 'object', properties: { aProperty: {type: 'string'}, }, }, }, } ```
/content/code_sandbox/test/e2e/patternProperties.3.ts
xml
2016-03-22T03:56:58
2024-08-12T18:37:05
json-schema-to-typescript
bcherny/json-schema-to-typescript
2,877
71
```xml import { SerializedSource } from '../../../interfaces/db/source' import { SerializedTeam } from '../../../interfaces/db/team' import { callApi } from '../../../lib/client' export async function listSources( team: SerializedTeam, filters?: { type: string } ) { const data = await callApi<{ sources: SerializedSource[] }>(`api/sources`, { method: 'get', search: { ...filters, teamId: team.id }, }) return data } export async function deleteSource(_team: SerializedTeam, sourceId: string) { const data = await callApi<{}>(`api/sources/${sourceId}`, { method: 'delete', }) return data } ```
/content/code_sandbox/src/cloud/api/teams/sources/index.ts
xml
2016-11-19T14:30:34
2024-08-16T03:13:45
BoostNote-App
BoostIO/BoostNote-App
3,745
149
```xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url"> <plist version="1.0"> <dict> <key>BuildVersion</key> <string>2465</string> <key>CFBundleShortVersionString</key> <string>8.0</string> <key>CFBundleVersion</key> <string>800.20.24</string> <key>ProjectName</key> <string>AirPortDriverBrcm4331</string> <key>SourceVersion</key> <string>800020024000000</string> </dict> </plist> ```
/content/code_sandbox/Clover-Configs/Asus/FX50J/CLOVER/kexts/10.12/IO80211Family.kext/Contents/PlugIns/AirPortBrcm4331.kext/Contents/version.plist
xml
2016-11-05T04:22:54
2024-08-12T19:25:53
Hackintosh-Installer-University
huangyz0918/Hackintosh-Installer-University
3,937
156
```xml <?xml version="1.0" encoding="UTF-8"?> <testsuites> <testsuite name="tensorflow/python/kernel_tests/spacetodepth_op_test" tests="1" failures="0" errors="0"> <testcase name="tensorflow/python/kernel_tests/spacetodepth_op_test" status="run"></testcase> </testsuite> </testsuites> ```
/content/code_sandbox/testlogs/python27/2016_07_17/tensorflow/python/kernel_tests/spacetodepth_op_test/test.xml
xml
2016-03-12T06:26:47
2024-08-12T19:21:52
tensorflow-on-raspberry-pi
samjabrahams/tensorflow-on-raspberry-pi
2,242
83
```xml import { Button, Dialog, Flex, Text } from '@fluentui/react-northstar'; import * as React from 'react'; const DialogExampleFooter: React.FC = () => ( <Dialog cancelButton="Cancel" confirmButton="Create" content="Are you sure you want to create a new project?" header="Project creation" trigger={<Button content="Open a dialog" />} footer={{ children: (Component, props) => { const { styles, ...rest } = props; return ( <Flex styles={styles}> <Text as="a" href="" target="_blank" content="Privacy notes" color="brand" /> <Flex.Item push> <Component {...rest} /> </Flex.Item> </Flex> ); }, }} /> ); export default DialogExampleFooter; ```
/content/code_sandbox/packages/fluentui/docs/src/examples/components/Dialog/Content/DialogExampleFooter.shorthand.tsx
xml
2016-06-06T15:03:44
2024-08-16T18:49:29
fluentui
microsoft/fluentui
18,221
180
```xml import * as React from 'react'; import { Button, Tab, TabList, Menu, MenuTrigger, MenuButton, MenuItem, MenuList, MenuPopover, Avatar, Text, Divider, makeStyles, } from '@fluentui/react-components'; import { Send24Regular, Mic24Regular, PeopleRegular, PersonDelete24Regular } from '@fluentui/react-icons'; import { FluentWapper } from './FluentUiWrapper.stories'; const useStyles = makeStyles({ visibleTextContainer: { marginTop: '10px', display: 'flex', width: '180px', justifyContent: 'space-between', }, divider: { marginTop: '10px', marginBottom: '10px', }, }); export const ActionAvoidBad = () => ( <FluentWapper> <Button aria-label="Click here to send message " size="small" icon={<Send24Regular />} /> </FluentWapper> ); export const ActionAvoidGood = () => ( <FluentWapper> <Button aria-label="Send message" size="small" icon={<Send24Regular />} /> </FluentWapper> ); export const ComponentTypeAvoidBad = () => ( <FluentWapper> <Button aria-label="Mute microphone button" size="small" icon={<Mic24Regular />} /> </FluentWapper> ); export const ComponentTypeAvoidGood = () => ( <FluentWapper> <Button aria-label="Mute microphone" size="small" icon={<Mic24Regular />} /> </FluentWapper> ); export const StateAvoidBad = () => ( <FluentWapper> <TabList defaultSelectedValue="Files"> <Tab value="Chat">Chat</Tab> <Tab value="Files" aria-label="Files tab is active"> Files </Tab> <Tab value="Activity">Activity</Tab> </TabList> </FluentWapper> ); export const StateAvoidGood = () => ( <FluentWapper> <TabList defaultSelectedValue="Files"> <Tab value="Chat">Chat</Tab> <Tab value="Files">Files</Tab> <Tab value="Activity">Activity</Tab> </TabList> </FluentWapper> ); export const CustomPositionAvoidBad = () => ( <FluentWapper> <Menu> <MenuTrigger> <MenuButton>Profile</MenuButton> </MenuTrigger> <MenuPopover> <MenuList> <MenuItem role="listitem" aria-label="Account settings..., first item of four"> Account settings... </MenuItem> <MenuItem role="listitem" aria-label="Change status message..., second item of four"> Change status message... </MenuItem> <MenuItem role="listitem" aria-label="Help, third item of four"> Help </MenuItem> <MenuItem role="listitem" aria-label="Sign out, fourth item of four"> Sign out </MenuItem> </MenuList> </MenuPopover> </Menu> </FluentWapper> ); export const CustomPositionAvoidGood = () => ( <FluentWapper> <Menu> <MenuTrigger> <MenuButton>Profile</MenuButton> </MenuTrigger> <MenuPopover> <MenuList> <MenuItem>Account settings...</MenuItem> <MenuItem>Change status message...</MenuItem> <MenuItem>Help</MenuItem> <MenuItem>Sign out</MenuItem> </MenuList> </MenuPopover> </Menu> </FluentWapper> ); export const TextRepeatAvoidBad = () => ( <FluentWapper> <Menu> <MenuTrigger> <Button aria-label="Participants" icon={<PeopleRegular />} /> </MenuTrigger> <MenuPopover> <MenuList> <MenuItem aria-label="Meeting participant Robert Tolbert" icon={<Avatar />}> Robert Tolbert </MenuItem> <MenuItem aria-label="Meeting participant Celeste Burton" icon={<Avatar />}> Celeste Burton </MenuItem> <MenuItem aria-label="Meeting participant Cecil Folk" icon={<Avatar />}> Cecil Folk </MenuItem> </MenuList> </MenuPopover> </Menu> </FluentWapper> ); export const TextRepeatAvoidGood = () => ( <FluentWapper> <Menu> <MenuTrigger> <Button aria-label="Participants" icon={<PeopleRegular />} /> </MenuTrigger> <MenuPopover> <MenuList aria-label="Meeting participants" aria-labelledby={undefined}> <MenuItem aria-label="Robert Tolbert" icon={<Avatar />}> Robert Tolbert </MenuItem> <MenuItem aria-label="Celeste Burton" icon={<Avatar />}> Celeste Burton </MenuItem> <MenuItem aria-label="Cecil Folk" icon={<Avatar />}> Cecil Folk </MenuItem> </MenuList> </MenuPopover> </Menu> </FluentWapper> ); export const FocusTextAvoidBad = () => { return ( <FluentWapper> <Text tabIndex={0} block> With this option, notifications won't be displayed anymore . You can miss information about latest news.{' '} </Text> <Button>Submit </Button> </FluentWapper> ); }; export const FocusTextAvoidGood = () => { const styles = useStyles(); return ( <FluentWapper> <Text id="notificationText" block> With this option, notifications won't be displayed anymore . You can miss information about latest news.{' '} </Text> <Button aria-describedby="notificationText">Submit </Button> <Divider className={styles.divider} /> <div id="testTitle">Summary of your order</div> <div role="group" aria-labelledby="testTitle"> <Button>Buy</Button> </div> </FluentWapper> ); }; export const ReuseVisibleTextBad = () => { const styles = useStyles(); return ( <FluentWapper> <h4>Members</h4> <div className={styles.visibleTextContainer}> <Avatar /> <span>Robert Tolbert</span> <Button icon={<PersonDelete24Regular />} aria-label="Remove Robert Tolbert" /> </div> </FluentWapper> ); }; export const ReuseVisibleTextGood = () => { const styles = useStyles(); return ( <FluentWapper> <h4>Members</h4> <div className={styles.visibleTextContainer}> <Avatar /> <span id="userNameId">Robert Tolbert</span> <Button icon={<PersonDelete24Regular />} aria-label="Remove" id="removeButtonId" aria-labelledby="removeButtonId userNameId" /> </div> </FluentWapper> ); }; ```
/content/code_sandbox/apps/public-docsite-v9/src/Concepts/Accessibility/LabellingExamples/Examples.stories.tsx
xml
2016-06-06T15:03:44
2024-08-16T18:49:29
fluentui
microsoft/fluentui
18,221
1,525
```xml import {MediaDTO} from './MediaDTO'; import {FileDTO} from './FileDTO'; import {CoverPhotoDTO} from './PhotoDTO'; import {Utils} from '../Utils'; export interface DirectoryPathDTO { name: string; path: string; } export interface DirectoryBaseDTO<S extends FileDTO = MediaDTO> extends DirectoryPathDTO { id: number; name: string; path: string; lastModified: number; lastScanned?: number; isPartial?: boolean; parent: DirectoryBaseDTO<S>; mediaCount: number; youngestMedia?: number; oldestMedia?: number; directories?: DirectoryBaseDTO<S>[]; media?: S[]; metaFile?: FileDTO[]; cover?: CoverPhotoDTO; validCover?: boolean; // does not go to the client side } export interface ParentDirectoryDTO<S extends FileDTO = MediaDTO> extends DirectoryBaseDTO<S> { id: number; name: string; path: string; lastModified: number; lastScanned?: number; isPartial?: boolean; parent: ParentDirectoryDTO<S>; mediaCount: number; youngestMedia?: number; oldestMedia?: number; directories: SubDirectoryDTO<S>[]; media: S[]; metaFile: FileDTO[]; } export interface SubDirectoryDTO<S extends FileDTO = MediaDTO> extends DirectoryBaseDTO<S> { id: number; name: string; path: string; lastModified: number; lastScanned: number; isPartial?: boolean; parent: ParentDirectoryDTO<S>; mediaCount: number; cover: CoverPhotoDTO; validCover?: boolean; // does not go to the client side } export const DirectoryDTOUtils = { addReferences: (dir: DirectoryBaseDTO): void => { dir.media.forEach((media: MediaDTO) => { media.directory = dir; }); if (dir.metaFile) { dir.metaFile.forEach((file: FileDTO) => { file.directory = dir; }); } if (dir.directories) { dir.directories.forEach((directory) => { DirectoryDTOUtils.addReferences(directory); directory.parent = dir; }); } }, removeReferences: (dir: DirectoryBaseDTO): DirectoryBaseDTO => { if (dir.cover) { dir.cover.directory = { path: dir.cover.directory.path, name: dir.cover.directory.name, } as DirectoryPathDTO; // make sure that it is not a same object as one of the photo in the media[] // as the next foreach would remove the directory dir.cover = Utils.clone(dir.cover); } if (dir.media) { dir.media.forEach((media: MediaDTO) => { media.directory = null; }); } if (dir.metaFile) { dir.metaFile.forEach((file: FileDTO) => { file.directory = null; }); } if (dir.directories) { dir.directories.forEach((directory) => { DirectoryDTOUtils.removeReferences(directory); directory.parent = null; }); } delete dir.validCover; // should not go to the client side; return dir; }, }; ```
/content/code_sandbox/src/common/entities/DirectoryDTO.ts
xml
2016-03-12T11:46:41
2024-08-16T19:56:44
pigallery2
bpatrik/pigallery2
1,727
697
```xml import { getPeerDependencyIssues } from '@pnpm/core' import { prepareEmpty } from '@pnpm/prepare' import { type ProjectRootDir } from '@pnpm/types' import { testDefaults } from './utils' test('cannot resolve peer dependency for top-level dependency', async () => { prepareEmpty() const peerDependencyIssues = await getPeerDependencyIssues([ { buildIndex: 0, manifest: { dependencies: { 'ajv-keywords': '1.5.0', }, }, rootDir: process.cwd() as ProjectRootDir, }, ], testDefaults()) expect(peerDependencyIssues['.'].missing).toHaveProperty('ajv') }) test('a conflict is detected when the same peer is required with ranges that do not overlap', async () => { prepareEmpty() const peerDependencyIssues = await getPeerDependencyIssues([ { buildIndex: 0, manifest: { dependencies: { '@pnpm.e2e/has-foo100-peer': '1.0.0', '@pnpm.e2e/has-foo101-peer': '1.0.0', }, }, rootDir: process.cwd() as ProjectRootDir, }, ], testDefaults()) expect(peerDependencyIssues['.'].conflicts.length).toBe(1) }) ```
/content/code_sandbox/pkg-manager/core/test/getPeerDependencyIssues.test.ts
xml
2016-01-28T07:40:43
2024-08-16T12:38:47
pnpm
pnpm/pnpm
28,869
288
```xml <?xml version="1.0" encoding="utf-8"?> <!-- <copyright file="WixUI_en-us.wxl" company="Outercurve Foundation"> The license and further copyright text can be found in the file LICENSE.TXT at the root directory of the distribution. </copyright> --> <WixLocalization Culture="en-US" Codepage="1252" xmlns="path_to_url"> <!-- _locID@Culture="en-US" _locComment="American English" --> <!-- _locID@Codepage="1252" _locComment="Windows-1252" --> <String Id="WixUIBack" Overridable="yes"><!-- _locID_text="WixUIBack" _locComment="WixUIBack" -->&amp;Back</String> <String Id="WixUINext" Overridable="yes"><!-- _locID_text="WixUINext" _locComment="WixUINext" -->&amp;Next</String> <String Id="WixUICancel" Overridable="yes"><!-- _locID_text="WixUICancel" _locComment="WixUICancel" -->Cancel</String> <String Id="WixUIFinish" Overridable="yes"><!-- _locID_text="WixUIFinish" _locComment="WixUIFinish" -->&amp;Finish</String> <String Id="WixUIRetry" Overridable="yes"><!-- _locID_text="WixUIRetry" _locComment="WixUIRetry" -->&amp;Retry</String> <String Id="WixUIIgnore" Overridable="yes"><!-- _locID_text="WixUIIgnore" _locComment="WixUIIgnore" -->&amp;Ignore</String> <String Id="WixUIYes" Overridable="yes"><!-- _locID_text="WixUIYes" _locComment="WixUIYes" -->&amp;Yes</String> <String Id="WixUINo" Overridable="yes"><!-- _locID_text="WixUINo" _locComment="WixUINo" -->&amp;No</String> <String Id="WixUIOK" Overridable="yes"><!-- _locID_text="WixUIOK" _locComment="WixUIOK" -->OK</String> <String Id="WixUIPrint" Overridable="yes"><!-- _locID_text="WixUIPrint" _locComment="WixUIPrint" -->&amp;Print</String> <String Id="UserNameDlg_Title" Overridable="yes">[ProductName] Setup</String> <String Id="UserNameDlgNameLabel" Overridable="yes">Name:</String> <String Id="UserNameDlgPasswordLabel" Overridable="yes">Password:</String> <String Id="UserNameDlgDomainLabel" Overridable="yes">Domain:</String> <String Id="UserNameDlgDomainTypeLabel" Overridable="yes">Domain type</String> <String Id="UserNameDlgLocalDomainLabel" Overridable="yes">Local</String> <String Id="UserNameDlgNetworkDomainLabel" Overridable="yes">Network</String> <String Id="UserNameDlgDescription" Overridable="yes">Provide credentials for the user to be created</String> <String Id="UserNameDlgTitle" Overridable="yes">Change user credentials</String> <String Id="AdvancedWelcomeEulaDlg_Title" Overridable="yes"><!-- _locID_text="AdvancedWelcomeEulaDlg_Title" _locComment="AdvancedWelcomeEulaDlg_Title" -->[ProductName] Setup</String> <String Id="AdvancedWelcomeEulaDlgBannerBitmap" Overridable="yes"><!-- _locID_text="AdvancedWelcomeEulaDlgBannerBitmap" _locComment="AdvancedWelcomeEulaDlgBannerBitmap" -->WixUI_Bmp_Banner</String> <String Id="AdvancedWelcomeEulaDlgDescriptionPerMachine" Overridable="yes"><!-- _locID_text="AdvancedWelcomeEulaDlgDescriptionPerMachine" _locComment="AdvancedWelcomeEulaDlgDescriptionPerMachine" -->Click Install to install the product with default options for all users. Click Advanced to change installation options.</String> <String Id="AdvancedWelcomeEulaDlgDescriptionPerUser" Overridable="yes"><!-- _locID_text="AdvancedWelcomeEulaDlgDescriptionPerUser" _locComment="AdvancedWelcomeEulaDlgDescriptionPerUser" -->Click Install to install the product with default options just for you. Click Advanced to change installation options.</String> <String Id="AdvancedWelcomeEulaDlgInstall" Overridable="yes"><!-- _locID_text="AdvancedWelcomeEulaDlgInstall" _locComment="AdvancedWelcomeEulaDlgInstall" -->&amp;Install</String> <String Id="AdvancedWelcomeEulaDlgAdvanced" Overridable="yes"><!-- _locID_text="AdvancedWelcomeEulaDlgAdvanced" _locComment="AdvancedWelcomeEulaDlgAdvanced" -->A&amp;dvanced</String> <String Id="Advanced_Font_Normal_Size" Overridable="yes"><!-- _locID_text="Advanced_Font_Normal_Size" _locComment="Advanced_Font_Normal_Size" -->8</String> <String Id="Advanced_Font_Bigger_Size" Overridable="yes"><!-- _locID_text="Advanced_Font_Bigger_Size" _locComment="Advanced_Font_Bigger_Size" -->12</String> <String Id="Advanced_Font_Title_Size" Overridable="yes"><!-- _locID_text="Advanced_Font_Title_Size" _locComment="Advanced_Font_Title_Size" -->9</String> <String Id="Advanced_Font_Emphasized_Size" Overridable="yes"><!-- _locID_text="Advanced_Font_Emphasized_Size" _locComment="Advanced_Font_Emphasized_Size" -->8</String> <String Id="Advanced_Font_FaceName" Overridable="yes"><!-- _locID_text="Advanced_Font_FaceName" _locComment="Advanced_Font_FaceName" -->Tahoma</String> <String Id="BrowseDlg_Title" Overridable="yes"><!-- _locID_text="BrowseDlg_Title" _locComment="BrowseDlg_Title" -->[ProductName] Setup</String> <String Id="BrowseDlgComboLabel" Overridable="yes"><!-- _locID_text="BrowseDlgComboLabel" _locComment="BrowseDlgComboLabel" -->&amp;Look in:</String> <String Id="BrowseDlgWixUI_Bmp_Up" Overridable="yes"><!-- _locID_text="BrowseDlgWixUI_Bmp_Up" _locComment="BrowseDlgWixUI_Bmp_Up" -->WixUI_Bmp_Up</String> <String Id="BrowseDlgWixUI_Bmp_UpTooltip" Overridable="yes"><!-- _locID_text="BrowseDlgWixUI_Bmp_UpTooltip" _locComment="BrowseDlgWixUI_Bmp_UpTooltip" -->Up one level</String> <String Id="BrowseDlgNewFolder" Overridable="yes"><!-- _locID_text="BrowseDlgNewFolder" _locComment="BrowseDlgNewFolder" -->WixUI_Bmp_New</String> <String Id="BrowseDlgNewFolderTooltip" Overridable="yes"><!-- _locID_text="BrowseDlgNewFolderTooltip" _locComment="BrowseDlgNewFolderTooltip" -->Create a new folder</String> <String Id="BrowseDlgPathLabel" Overridable="yes"><!-- _locID_text="BrowseDlgPathLabel" _locComment="BrowseDlgPathLabel" -->&amp;Folder name:</String> <String Id="BrowseDlgBannerBitmap" Overridable="yes"><!-- _locID_text="BrowseDlgBannerBitmap" _locComment="BrowseDlgBannerBitmap" -->WixUI_Bmp_Banner</String> <String Id="BrowseDlgDescription" Overridable="yes"><!-- _locID_text="BrowseDlgDescription" _locComment="BrowseDlgDescription" -->Browse to the destination folder</String> <String Id="BrowseDlgTitle" Overridable="yes"><!-- _locID_text="BrowseDlgTitle" _locComment="BrowseDlgTitle" -->{\WixUI_Font_Title}Change destination folder</String> <String Id="CancelDlg_Title" Overridable="yes"><!-- _locID_text="CancelDlg_Title" _locComment="CancelDlg_Title" -->[ProductName] Setup</String> <String Id="CancelDlgText" Overridable="yes"><!-- _locID_text="CancelDlgText" _locComment="CancelDlgText" -->Are you sure you want to cancel [ProductName] installation?</String> <String Id="CancelDlgIcon" Overridable="yes"><!-- _locID_text="CancelDlgIcon" _locComment="CancelDlgIcon" -->WixUI_Ico_Info</String> <String Id="CancelDlgIconTooltip" Overridable="yes"><!-- _locID_text="CancelDlgIconTooltip" _locComment="CancelDlgIconTooltip" -->Information icon</String> <String Id="CustomizeDlg_Title" Overridable="yes"><!-- _locID_text="CustomizeDlg_Title" _locComment="CustomizeDlg_Title" -->[ProductName] Setup</String> <String Id="CustomizeDlgTree" Overridable="yes"><!-- _locID_text="CustomizeDlgTree" _locComment="CustomizeDlgTree" -->Tree of selections</String> <String Id="CustomizeDlgBrowse" Overridable="yes"><!-- _locID_text="CustomizeDlgBrowse" _locComment="CustomizeDlgBrowse" -->B&amp;rowse...</String> <String Id="CustomizeDlgReset" Overridable="yes"><!-- _locID_text="CustomizeDlgReset" _locComment="CustomizeDlgReset" -->Re&amp;set</String> <String Id="CustomizeDlgDiskCost" Overridable="yes"><!-- _locID_text="CustomizeDlgDiskCost" _locComment="CustomizeDlgDiskCost" -->Disk &amp;Usage</String> <String Id="CustomizeDlgBannerBitmap" Overridable="yes"><!-- _locID_text="CustomizeDlgBannerBitmap" _locComment="CustomizeDlgBannerBitmap" -->WixUI_Bmp_Banner</String> <String Id="CustomizeDlgText" Overridable="yes"><!-- _locID_text="CustomizeDlgText" _locComment="CustomizeDlgText" -->Click the icons in the tree below to change the way features will be installed.</String> <String Id="CustomizeDlgDescription" Overridable="yes"><!-- _locID_text="CustomizeDlgDescription" _locComment="CustomizeDlgDescription" -->Select the way you want features to be installed.</String> <String Id="CustomizeDlgTitle" Overridable="yes"><!-- _locID_text="CustomizeDlgTitle" _locComment="CustomizeDlgTitle" -->{\WixUI_Font_Title}Custom Setup</String> <String Id="CustomizeDlgItemDescription" Overridable="yes"><!-- _locID_text="CustomizeDlgItemDescription" _locComment="CustomizeDlgItemDescription" -->CustomizeDlgItemDescription-CustomizeDlgItemDescription</String> <String Id="CustomizeDlgItemSize" Overridable="yes"><!-- _locID_text="CustomizeDlgItemSize" _locComment="CustomizeDlgItemSize" -->CustomizeDlgItemSize-CustomizeDlgItemSize</String> <String Id="CustomizeDlgLocation" Overridable="yes"><!-- _locID_text="CustomizeDlgLocation" _locComment="CustomizeDlgLocation" -->CustomizeDlgLocation-CustomizeDlgLocation</String> <String Id="CustomizeDlgLocationLabel" Overridable="yes"><!-- _locID_text="CustomizeDlgLocationLabel" _locComment="CustomizeDlgLocationLabel" -->Location:</String> <String Id="DiskCostDlg_Title" Overridable="yes"><!-- _locID_text="DiskCostDlg_Title" _locComment="DiskCostDlg_Title" -->[ProductName] Setup</String> <String Id="DiskCostDlgBannerBitmap" Overridable="yes"><!-- _locID_text="DiskCostDlgBannerBitmap" _locComment="DiskCostDlgBannerBitmap" -->WixUI_Bmp_Banner</String> <String Id="DiskCostDlgText" Overridable="yes"><!-- _locID_text="DiskCostDlgText" _locComment="DiskCostDlgText" -->Highlighted volumes do not have enough disk space available for selected features. You can either remove some files from the highlighted volumes, install fewer features, or select different destination drives.</String> <String Id="DiskCostDlgDescription" Overridable="yes"><!-- _locID_text="DiskCostDlgDescription" _locComment="DiskCostDlgDescription" -->The disk space required for the installation of the selected features.</String> <String Id="DiskCostDlgTitle" Overridable="yes"><!-- _locID_text="DiskCostDlgTitle" _locComment="DiskCostDlgTitle" -->{\WixUI_Font_Title}Disk Space Requirements</String> <String Id="DiskCostDlgVolumeList" Overridable="yes"><!-- _locID_text="DiskCostDlgVolumeList" _locComment="DiskCostDlgVolumeList" -->{120}{70}{70}{70}{70}</String> <String Id="ErrorDlg_Title" Overridable="yes"><!-- _locID_text="ErrorDlg_Title" _locComment="ErrorDlg_Title" -->[ProductName] Setup</String> <String Id="ErrorDlgErrorText" Overridable="yes"><!-- _locID_text="ErrorDlgErrorText" _locComment="ErrorDlgErrorText" -->Information text</String> <String Id="ErrorDlgErrorIcon" Overridable="yes"><!-- _locID_text="ErrorDlgErrorIcon" _locComment="ErrorDlgErrorIcon" -->WixUI_Ico_Info</String> <String Id="ErrorDlgErrorIconTooltip" Overridable="yes"><!-- _locID_text="ErrorDlgErrorIconTooltip" _locComment="ErrorDlgErrorIconTooltip" -->Information icon</String> <String Id="ExitDialog_Title" Overridable="yes"><!-- _locID_text="ExitDialog_Title" _locComment="ExitDialog_Title" -->[ProductName] Setup</String> <String Id="ExitDialogBitmap" Overridable="yes"><!-- _locID_text="ExitDialogBitmap" _locComment="ExitDialogBitmap" -->WixUI_Bmp_Dialog</String> <String Id="ExitDialogDescription" Overridable="yes"><!-- _locID_text="ExitDialogDescription" _locComment="ExitDialogDescription" -->Click the Finish button to exit the Setup Wizard.</String> <String Id="ExitDialogTitle" Overridable="yes"><!-- _locID_text="ExitDialogTitle" _locComment="ExitDialogTitle" -->{\WixUI_Font_Bigger}Completed the [ProductName] Setup Wizard</String> <String Id="FatalError_Title" Overridable="yes"><!-- _locID_text="FatalError_Title" _locComment="FatalError_Title" -->[ProductName] Setup</String> <String Id="FatalErrorBitmap" Overridable="yes"><!-- _locID_text="FatalErrorBitmap" _locComment="FatalErrorBitmap" -->WixUI_Bmp_Dialog</String> <String Id="FatalErrorTitle" Overridable="yes"><!-- _locID_text="FatalErrorTitle" _locComment="FatalErrorTitle" -->{\WixUI_Font_Bigger}[ProductName] Setup Wizard ended prematurely</String> <String Id="FatalErrorDescription1" Overridable="yes"><!-- _locID_text="FatalErrorDescription1" _locComment="FatalErrorDescription1" -->[ProductName] Setup Wizard ended prematurely because of an error. Your system has not been modified. To install this program at a later time, run Setup Wizard again.</String> <String Id="FatalErrorDescription2" Overridable="yes"><!-- _locID_text="FatalErrorDescription2" _locComment="FatalErrorDescription2" -->Click the Finish button to exit the Setup Wizard.</String> <String Id="FeaturesDlg_Title" Overridable="yes"><!-- _locID_text="FeaturesDlg_Title" _locComment="FeaturesDlg_Title" -->[ProductName] Setup</String> <String Id="FeaturesDlgTree" Overridable="yes"><!-- _locID_text="FeaturesDlgTree" _locComment="FeaturesDlgTree" -->Product features</String> <String Id="FeaturesDlgBannerBitmap" Overridable="yes"><!-- _locID_text="FeaturesDlgBannerBitmap" _locComment="FeaturesDlgBannerBitmap" -->WixUI_Bmp_Banner</String> <String Id="FeaturesDlgDescription" Overridable="yes"><!-- _locID_text="FeaturesDlgDescription" _locComment="FeaturesDlgDescription" -->Select the way you want features to be installed.</String> <String Id="FeaturesDlgTitle" Overridable="yes"><!-- _locID_text="FeaturesDlgTitle" _locComment="FeaturesDlgTitle" -->{\WixUI_Font_Title}Product Features</String> <String Id="FeaturesDlgItemDescription" Overridable="yes"><!-- _locID_text="FeaturesDlgItemDescription" _locComment="FeaturesDlgItemDescription" -->FeaturesDlgItemDescription</String> <String Id="FeaturesDlgItemSize" Overridable="yes"><!-- _locID_text="FeaturesDlgItemSize" _locComment="FeaturesDlgItemSize" -->FeaturesDlgItemSize</String> <String Id="FeaturesDlgInstall" Overridable="yes"><!-- _locID_text="FeaturesDlgInstall" _locComment="FeaturesDlgInstall" -->&amp;Install</String> <String Id="FeaturesDlgChange" Overridable="yes"><!-- _locID_text="FeaturesDlgChange" _locComment="FeaturesDlgChange" -->&amp;Change</String> <String Id="FilesInUse_Title" Overridable="yes"><!-- _locID_text="FilesInUse_Title" _locComment="FilesInUse_Title" -->[ProductName] Setup</String> <String Id="FilesInUseExit" Overridable="yes"><!-- _locID_text="FilesInUseExit" _locComment="FilesInUseExit" -->E&amp;xit</String> <String Id="FilesInUseBannerBitmap" Overridable="yes"><!-- _locID_text="FilesInUseBannerBitmap" _locComment="FilesInUseBannerBitmap" -->WixUI_Bmp_Banner</String> <String Id="FilesInUseText" Overridable="yes"><!-- _locID_text="FilesInUseText" _locComment="FilesInUseText" -->The following applications are using files that need to be updated by this setup. Close these applications and then click &amp;Retry to continue setup or Exit to exit it.</String> <String Id="FilesInUseDescription" Overridable="yes"><!-- _locID_text="FilesInUseDescription" _locComment="FilesInUseDescription" -->Some files that need to be updated are currently in use.</String> <String Id="FilesInUseTitle" Overridable="yes"><!-- _locID_text="FilesInUseTitle" _locComment="FilesInUseTitle" -->{\WixUI_Font_Title}Files in Use</String> <String Id="InstallDirDlg_Title" Overridable="yes"><!-- _locID_text="InstallDirDlg_Title" _locComment="InstallDirDlg_Title" -->[ProductName] Setup</String> <String Id="InstallDirDlgChange" Overridable="yes"><!-- _locID_text="InstallDirDlgChange" _locComment="InstallDirDlgChange" -->&amp;Change...</String> <String Id="InstallDirDlgTitle" Overridable="yes"><!-- _locID_text="InstallDirDlgTitle" _locComment="InstallDirDlgTitle" -->{\WixUI_Font_Title}Destination Folder</String> <String Id="InstallDirDlgDescription" Overridable="yes"><!-- _locID_text="InstallDirDlgDescription" _locComment="InstallDirDlgDescription" -->Click Next to install to the default folder or click Change to choose another.</String> <String Id="InstallDirDlgBannerBitmap" Overridable="yes"><!-- _locID_text="InstallDirDlgBannerBitmap" _locComment="InstallDirDlgBannerBitmap" -->WixUI_Bmp_Banner</String> <String Id="InstallDirDlgFolderLabel" Overridable="yes"><!-- _locID_text="InstallDirDlgFolderLabel" _locComment="InstallDirDlgFolderLabel" -->Install [ProductName] to:</String> <String Id="InstallScopeDlg_Title" Overridable="yes"><!-- _locID_text="InstallScopeDlg_Title" _locComment="InstallScopeDlg_Title" -->[ProductName] Setup</String> <String Id="InstallScopeDlgBannerBitmap" Overridable="yes"><!-- _locID_text="InstallScopeDlgBannerBitmap" _locComment="InstallScopeDlgBannerBitmap" -->WixUI_Bmp_Banner</String> <String Id="InstallScopeDlgDescription" Overridable="yes"><!-- _locID_text="InstallScopeDlgDescription" _locComment="InstallScopeDlgDescription" -->Choose the installation scope and folder</String> <String Id="InstallScopeDlgTitle" Overridable="yes"><!-- _locID_text="InstallScopeDlgTitle" _locComment="InstallScopeDlgTitle" -->{\WixUI_Font_Title}Installation Scope</String> <String Id="InstallScopeDlgPerUser" Overridable="yes"><!-- _locID_text="InstallScopeDlgPerUser" _locComment="InstallScopeDlgPerUser" -->{\WixUI_Font_Emphasized}Install &amp;just for you ([LogonUser])</String> <String Id="InstallScopeDlgPerUserDescription" Overridable="yes"><!-- _locID_text="InstallScopeDlgPerUserDescription" _locComment="InstallScopeDlgPerUserDescription" -->[ProductName] will be installed in a per-user folder and be available just for your user account. You do not need local Administrator privileges.</String> <String Id="InstallScopeDlgNoPerUserDescription" Overridable="yes"><!-- _locID_text="InstallScopeDlgNoPerUserDescription" _locComment="InstallScopeDlgNoPerUserDescription" -->[ProductName] does not support per-user installation.</String> <String Id="InstallScopeDlgPerMachine" Overridable="yes"><!-- _locID_text="InstallScopeDlgPerMachine" _locComment="InstallScopeDlgPerMachine" -->{\WixUI_Font_Emphasized}Install for all users of this &amp;machine</String> <String Id="InstallScopeDlgPerMachineDescription" Overridable="yes"><!-- _locID_text="InstallScopeDlgPerMachineDescription" _locComment="InstallScopeDlgPerMachineDescription" -->[ProductName] will be installed in a per-machine folder by default and be available for all users. You can change the default installation folder. You must have local Administrator privileges.</String> <String Id="InstallScopeDlgFolderLabel" Overridable="yes"><!-- _locID_text="InstallScopeDlgFolderLabel" _locComment="InstallScopeDlgFolderLabel" -->Installation &amp;folder:</String> <String Id="InstallScopeDlgChange" Overridable="yes"><!-- _locID_text="InstallScopeDlgChange" _locComment="InstallScopeDlgChange" -->&amp;Change...</String> <String Id="InvalidDirDlg_Title" Overridable="yes"><!-- _locID_text="InvalidDirDlg_Title" _locComment="InvalidDirDlg_Title" -->[ProductName] Setup</String> <String Id="InvalidDirDlgText" Overridable="yes"><!-- _locID_text="InvalidDirDlgText" _locComment="InvalidDirDlgText" -->Installation directory must be on a local hard drive.</String> <String Id="InvalidDirDlgIcon" Overridable="yes"><!-- _locID_text="InvalidDirDlgIcon" _locComment="InvalidDirDlgIcon" -->WixUI_Ico_Info</String> <String Id="InvalidDirDlgIconTooltip" Overridable="yes"><!-- _locID_text="InvalidDirDlgIconTooltip" _locComment="InvalidDirDlgIconTooltip" -->Information icon</String> <String Id="MaintenanceTypeDlg_Title" Overridable="yes"><!-- _locID_text="MaintenanceTypeDlg_Title" _locComment="MaintenanceTypeDlg_Title" -->[ProductName] Setup</String> <String Id="MaintenanceTypeDlgChangeButton" Overridable="yes"><!-- _locID_text="MaintenanceTypeDlgChangeButton" _locComment="MaintenanceTypeDlgChangeButton" -->&amp;Change</String> <String Id="MaintenanceTypeDlgChangeButtonTooltip" Overridable="yes"><!-- _locID_text="MaintenanceTypeDlgChangeButtonTooltip" _locComment="MaintenanceTypeDlgChangeButtonTooltip" -->Change Installation</String> <String Id="MaintenanceTypeDlgRepairButton" Overridable="yes"><!-- _locID_text="MaintenanceTypeDlgRepairButton" _locComment="MaintenanceTypeDlgRepairButton" -->Re&amp;pair</String> <String Id="MaintenanceTypeDlgRepairButtonTooltip" Overridable="yes"><!-- _locID_text="MaintenanceTypeDlgRepairButtonTooltip" _locComment="MaintenanceTypeDlgRepairButtonTooltip" -->Repair Installation</String> <String Id="MaintenanceTypeDlgRemoveButton" Overridable="yes"><!-- _locID_text="MaintenanceTypeDlgRemoveButton" _locComment="MaintenanceTypeDlgRemoveButton" -->&amp;Remove</String> <String Id="MaintenanceTypeDlgRemoveButtonTooltip" Overridable="yes"><!-- _locID_text="MaintenanceTypeDlgRemoveButtonTooltip" _locComment="MaintenanceTypeDlgRemoveButtonTooltip" -->Remove Installation</String> <String Id="MaintenanceTypeDlgBannerBitmap" Overridable="yes"><!-- _locID_text="MaintenanceTypeDlgBannerBitmap" _locComment="MaintenanceTypeDlgBannerBitmap" -->WixUI_Bmp_Banner</String> <String Id="MaintenanceTypeDlgDescription" Overridable="yes"><!-- _locID_text="MaintenanceTypeDlgDescription" _locComment="MaintenanceTypeDlgDescription" -->Select the operation you wish to perform.</String> <String Id="MaintenanceTypeDlgTitle" Overridable="yes"><!-- _locID_text="MaintenanceTypeDlgTitle" _locComment="MaintenanceTypeDlgTitle" -->{\WixUI_Font_Title}Change, repair, or remove installation</String> <String Id="MaintenanceTypeDlgChangeText" Overridable="yes"><!-- _locID_text="MaintenanceTypeDlgChangeText" _locComment="MaintenanceTypeDlgChangeText" -->Lets you change the way features are installed.</String> <String Id="MaintenanceTypeDlgChangeDisabledText" Overridable="yes"><!-- _locID_text="MaintenanceTypeDlgChangeDisabledText" _locComment="MaintenanceTypeDlgChangeDisabledText" -->[ProductName] has no independently selectable features.</String> <String Id="MaintenanceTypeDlgRemoveText" Overridable="yes"><!-- _locID_text="MaintenanceTypeDlgRemoveText" _locComment="MaintenanceTypeDlgRemoveText" -->Removes [ProductName] from your computer.</String> <String Id="MaintenanceTypeDlgRemoveDisabledText" Overridable="yes"><!-- _locID_text="MaintenanceTypeDlgRemoveDisabledText" _locComment="MaintenanceTypeDlgRemoveDisabledText" -->[ProductName] cannot be removed.</String> <String Id="MaintenanceTypeDlgRepairText" Overridable="yes"><!-- _locID_text="MaintenanceTypeDlgRepairText" _locComment="MaintenanceTypeDlgRepairText" -->Repairs errors in the most recent installation by fixing missing and corrupt files, shortcuts, and registry entries.</String> <String Id="MaintenanceTypeDlgRepairDisabledText" Overridable="yes"><!-- _locID_text="MaintenanceTypeDlgRepairDisabledText" _locComment="MaintenanceTypeDlgRepairDisabledText" -->[ProductName] cannot be repaired.</String> <String Id="MaintenanceWelcomeDlg_Title" Overridable="yes"><!-- _locID_text="MaintenanceWelcomeDlg_Title" _locComment="MaintenanceWelcomeDlg_Title" -->[ProductName] Setup</String> <String Id="MaintenanceWelcomeDlgBitmap" Overridable="yes"><!-- _locID_text="MaintenanceWelcomeDlgBitmap" _locComment="MaintenanceWelcomeDlgBitmap" -->WixUI_Bmp_Dialog</String> <String Id="MaintenanceWelcomeDlgDescription" Overridable="yes"><!-- _locID_text="MaintenanceWelcomeDlgDescription" _locComment="MaintenanceWelcomeDlgDescription" -->The Setup Wizard allows you to change the way [ProductName] features are installed on your computer or to remove it from your computer. Click Next to continue or Cancel to exit the Setup Wizard.</String> <String Id="MaintenanceWelcomeDlgTitle" Overridable="yes"><!-- _locID_text="MaintenanceWelcomeDlgTitle" _locComment="MaintenanceWelcomeDlgTitle" -->{\WixUI_Font_Bigger}Welcome to the [ProductName] Setup Wizard</String> <String Id="MsiRMFilesInUse_Title" Overridable="yes"><!-- _locID_text="MsiRMFilesInUse_Title" _locComment="MsiRMFilesInUse_Title" -->[ProductName] Setup</String> <String Id="MsiRMFilesInUseBannerBitmap" Overridable="yes"><!-- _locID_text="MsiRMFilesInUseBannerBitmap" _locComment="MsiRMFilesInUseBannerBitmap" -->WixUI_Bmp_Banner</String> <String Id="MsiRMFilesInUseText" Overridable="yes"><!-- _locID_text="MsiRMFilesInUseText" _locComment="MsiRMFilesInUseText" -->The following applications are using files that need to be updated by this setup. You can let Setup Wizard close them and attempt to restart them or reboot the machine later.</String> <String Id="MsiRMFilesInUseDescription" Overridable="yes"><!-- _locID_text="MsiRMFilesInUseDescription" _locComment="MsiRMFilesInUseDescription" -->Some files that need to be updated are currently in use.</String> <String Id="MsiRMFilesInUseTitle" Overridable="yes"><!-- _locID_text="MsiRMFilesInUseTitle" _locComment="MsiRMFilesInUseTitle" -->{\WixUI_Font_Title}Files in Use</String> <String Id="MsiRMFilesInUseUseRM" Overridable="yes"><!-- _locID_text="MsiRMFilesInUseUseRM" _locComment="MsiRMFilesInUseUseRM" -->&amp;Close the applications and attempt to restart them.</String> <String Id="MsiRMFilesInUseDontUseRM" Overridable="yes"><!-- _locID_text="MsiRMFilesInUseDontUseRM" _locComment="MsiRMFilesInUseDontUseRM" -->&amp;Do not close applications. A reboot will be required.</String> <String Id="OutOfDiskDlg_Title" Overridable="yes"><!-- _locID_text="OutOfDiskDlg_Title" _locComment="OutOfDiskDlg_Title" -->[ProductName] Setup</String> <String Id="OutOfDiskDlgBannerBitmap" Overridable="yes"><!-- _locID_text="OutOfDiskDlgBannerBitmap" _locComment="OutOfDiskDlgBannerBitmap" -->WixUI_Bmp_Banner</String> <String Id="OutOfDiskDlgText" Overridable="yes"><!-- _locID_text="OutOfDiskDlgText" _locComment="OutOfDiskDlgText" -->The highlighted volumes do not have enough disk space available for the currently selected features. You can remove some files from the highlighted volumes, install fewer features, or select a different destination drive.</String> <String Id="OutOfDiskDlgDescription" Overridable="yes"><!-- _locID_text="OutOfDiskDlgDescription" _locComment="OutOfDiskDlgDescription" -->Disk space required for the installation exceeds available disk space.</String> <String Id="OutOfDiskDlgTitle" Overridable="yes"><!-- _locID_text="OutOfDiskDlgTitle" _locComment="OutOfDiskDlgTitle" -->{\WixUI_Font_Title}Out of Disk Space</String> <String Id="OutOfDiskDlgVolumeList" Overridable="yes"><!-- _locID_text="OutOfDiskDlgVolumeList" _locComment="OutOfDiskDlgVolumeList" -->{120}{70}{70}{70}{70}</String> <String Id="OutOfRbDiskDlg_Title" Overridable="yes"><!-- _locID_text="OutOfRbDiskDlg_Title" _locComment="OutOfRbDiskDlg_Title" -->[ProductName] Setup</String> <String Id="OutOfRbDiskDlgBannerBitmap" Overridable="yes"><!-- _locID_text="OutOfRbDiskDlgBannerBitmap" _locComment="OutOfRbDiskDlgBannerBitmap" -->WixUI_Bmp_Banner</String> <String Id="OutOfRbDiskDlgText" Overridable="yes"><!-- _locID_text="OutOfRbDiskDlgText" _locComment="OutOfRbDiskDlgText" -->The highlighted volumes do not have enough disk space available for the currently selected features. You can remove some files from the highlighted volumes, install fewer features, or select a different destination drive.</String> <String Id="OutOfRbDiskDlgDescription" Overridable="yes"><!-- _locID_text="OutOfRbDiskDlgDescription" _locComment="OutOfRbDiskDlgDescription" -->Disk space required for the installation exceeds available disk space.</String> <String Id="OutOfRbDiskDlgTitle" Overridable="yes"><!-- _locID_text="OutOfRbDiskDlgTitle" _locComment="OutOfRbDiskDlgTitle" -->{\WixUI_Font_Title}Out of Disk Space</String> <String Id="OutOfRbDiskDlgVolumeList" Overridable="yes"><!-- _locID_text="OutOfRbDiskDlgVolumeList" _locComment="OutOfRbDiskDlgVolumeList" -->{120}{70}{70}{70}{70}</String> <String Id="OutOfRbDiskDlgText2" Overridable="yes"><!-- _locID_text="OutOfRbDiskDlgText2" _locComment="OutOfRbDiskDlgText2" -->Alternatively, you may choose to disable the installer's rollback functionality. Disabling rollback prevents the installer from restoring your computer's original state should the installation be interrupted in any way. Click Yes if you wish to take the risk of disabling rollback.</String> <String Id="PrepareDlg_Title" Overridable="yes"><!-- _locID_text="PrepareDlg_Title" _locComment="PrepareDlg_Title" -->[ProductName] Setup</String> <String Id="PrepareDlgBitmap" Overridable="yes"><!-- _locID_text="PrepareDlgBitmap" _locComment="PrepareDlgBitmap" -->WixUI_Bmp_Dialog</String> <String Id="PrepareDlgDescription" Overridable="yes"><!-- _locID_text="PrepareDlgDescription" _locComment="PrepareDlgDescription" -->Please wait while the Setup Wizard prepares to guide you through the installation.</String> <String Id="PrepareDlgTitle" Overridable="yes"><!-- _locID_text="PrepareDlgTitle" _locComment="PrepareDlgTitle" -->{\WixUI_Font_Bigger}Welcome to the [ProductName] Setup Wizard</String> <String Id="ProgressDlg_Title" Overridable="yes"><!-- _locID_text="ProgressDlg_Title" _locComment="ProgressDlg_Title" -->[ProductName] Setup</String> <String Id="ProgressDlgBannerBitmap" Overridable="yes"><!-- _locID_text="ProgressDlgBannerBitmap" _locComment="ProgressDlgBannerBitmap" -->WixUI_Bmp_Banner</String> <String Id="ProgressDlgTextInstalling" Overridable="yes"><!-- _locID_text="ProgressDlgTextInstalling" _locComment="ProgressDlgTextInstalling" -->Please wait while the Setup Wizard installs [ProductName].</String> <String Id="ProgressDlgTitleInstalling" Overridable="yes"><!-- _locID_text="ProgressDlgTitleInstalling" _locComment="ProgressDlgTitleInstalling" -->{\WixUI_Font_Title}Installing [ProductName]</String> <String Id="ProgressDlgTextChanging" Overridable="yes"><!-- _locID_text="ProgressDlgTextChanging" _locComment="ProgressDlgTextChanging" -->Please wait while the Setup Wizard changes [ProductName].</String> <String Id="ProgressDlgTitleChanging" Overridable="yes"><!-- _locID_text="ProgressDlgTitleChanging" _locComment="ProgressDlgTitleChanging" -->{\WixUI_Font_Title}Changing [ProductName]</String> <String Id="ProgressDlgTextRepairing" Overridable="yes"><!-- _locID_text="ProgressDlgTextRepairing" _locComment="ProgressDlgTextRepairing" -->Please wait while the Setup Wizard repairs [ProductName].</String> <String Id="ProgressDlgTitleRepairing" Overridable="yes"><!-- _locID_text="ProgressDlgTitleRepairing" _locComment="ProgressDlgTitleRepairing" -->{\WixUI_Font_Title}Repairing [ProductName]</String> <String Id="ProgressDlgTextRemoving" Overridable="yes"><!-- _locID_text="ProgressDlgTextRemoving" _locComment="ProgressDlgTextRemoving" -->Please wait while the Setup Wizard removes [ProductName].</String> <String Id="ProgressDlgTitleRemoving" Overridable="yes"><!-- _locID_text="ProgressDlgTitleRemoving" _locComment="ProgressDlgTitleRemoving" -->{\WixUI_Font_Title}Removing [ProductName]</String> <String Id="ProgressDlgTextUpdating" Overridable="yes"><!-- _locID_text="ProgressDlgTextUpdating" _locComment="ProgressDlgTextUpdating" -->Please wait while the Setup Wizard updates [ProductName].</String> <String Id="ProgressDlgTitleUpdating" Overridable="yes"><!-- _locID_text="ProgressDlgTitleUpdating" _locComment="ProgressDlgTitleUpdating" -->{\WixUI_Font_Title}Updating [ProductName]</String> <String Id="ProgressDlgProgressBar" Overridable="yes"><!-- _locID_text="ProgressDlgProgressBar" _locComment="ProgressDlgProgressBar" -->Progress done</String> <String Id="ProgressDlgStatusLabel" Overridable="yes"><!-- _locID_text="ProgressDlgStatusLabel" _locComment="ProgressDlgStatusLabel" -->Status:</String> <String Id="ResumeDlg_Title" Overridable="yes"><!-- _locID_text="ResumeDlg_Title" _locComment="ResumeDlg_Title" -->[ProductName] Setup</String> <String Id="ResumeDlgInstall" Overridable="yes"><!-- _locID_text="ResumeDlgInstall" _locComment="ResumeDlgInstall" -->&amp;Install</String> <String Id="ResumeDlgBitmap" Overridable="yes"><!-- _locID_text="ResumeDlgBitmap" _locComment="ResumeDlgBitmap" -->WixUI_Bmp_Dialog</String> <String Id="ResumeDlgDescription" Overridable="yes"><!-- _locID_text="ResumeDlgDescription" _locComment="ResumeDlgDescription" -->The Setup Wizard will complete the installation of [ProductName] on your computer. Click Install to continue or Cancel to exit the Setup Wizard.</String> <String Id="ResumeDlgTitle" Overridable="yes"><!-- _locID_text="ResumeDlgTitle" _locComment="ResumeDlgTitle" -->{\WixUI_Font_Bigger}Resuming the [ProductName] Setup Wizard</String> <String Id="SetupTypeDlg_Title" Overridable="yes"><!-- _locID_text="SetupTypeDlg_Title" _locComment="SetupTypeDlg_Title" -->[ProductName] Setup</String> <String Id="SetupTypeDlgTypicalButton" Overridable="yes"><!-- _locID_text="SetupTypeDlgTypicalButton" _locComment="SetupTypeDlgTypicalButton" -->&amp;Typical</String> <String Id="SetupTypeDlgTypicalButtonTooltip" Overridable="yes"><!-- _locID_text="SetupTypeDlgTypicalButtonTooltip" _locComment="SetupTypeDlgTypicalButtonTooltip" -->Typical Installation</String> <String Id="SetupTypeDlgCustomButton" Overridable="yes"><!-- _locID_text="SetupTypeDlgCustomButton" _locComment="SetupTypeDlgCustomButton" -->C&amp;ustom</String> <String Id="SetupTypeDlgCustomButtonTooltip" Overridable="yes"><!-- _locID_text="SetupTypeDlgCustomButtonTooltip" _locComment="SetupTypeDlgCustomButtonTooltip" -->Custom Installation</String> <String Id="SetupTypeDlgCompleteButton" Overridable="yes"><!-- _locID_text="SetupTypeDlgCompleteButton" _locComment="SetupTypeDlgCompleteButton" -->C&amp;omplete</String> <String Id="SetupTypeDlgCompleteButtonTooltip" Overridable="yes"><!-- _locID_text="SetupTypeDlgCompleteButtonTooltip" _locComment="SetupTypeDlgCompleteButtonTooltip" -->Complete Installation</String> <String Id="SetupTypeDlgBannerBitmap" Overridable="yes"><!-- _locID_text="SetupTypeDlgBannerBitmap" _locComment="SetupTypeDlgBannerBitmap" -->WixUI_Bmp_Banner</String> <String Id="SetupTypeDlgTitle" Overridable="yes"><!-- _locID_text="SetupTypeDlgTitle" _locComment="SetupTypeDlgTitle" -->{\WixUI_Font_Title}Choose Setup Type</String> <String Id="SetupTypeDlgDescription" Overridable="yes"><!-- _locID_text="SetupTypeDlgDescription" _locComment="SetupTypeDlgDescription" -->Choose the setup type that best suits your needs</String> <String Id="SetupTypeDlgTypicalText" Overridable="yes"><!-- _locID_text="SetupTypeDlgTypicalText" _locComment="SetupTypeDlgTypicalText" -->Installs the most common program features. Recommended for most users.</String> <String Id="SetupTypeDlgCustomText" Overridable="yes"><!-- _locID_text="SetupTypeDlgCustomText" _locComment="SetupTypeDlgCustomText" -->Allows users to choose which program features will be installed and where they will be installed. Recommended for advanced users.</String> <String Id="SetupTypeDlgCompleteText" Overridable="yes"><!-- _locID_text="SetupTypeDlgCompleteText" _locComment="SetupTypeDlgCompleteText" -->All program features will be installed. Requires the most disk space.</String> <String Id="UserExit_Title" Overridable="yes"><!-- _locID_text="UserExit_Title" _locComment="UserExit_Title" -->[ProductName] Setup</String> <String Id="UserExitBitmap" Overridable="yes"><!-- _locID_text="UserExitBitmap" _locComment="UserExitBitmap" -->WixUI_Bmp_Dialog</String> <String Id="UserExitTitle" Overridable="yes"><!-- _locID_text="UserExitTitle" _locComment="UserExitTitle" -->{\WixUI_Font_Bigger}[ProductName] Setup Wizard was interrupted</String> <String Id="UserExitDescription1" Overridable="yes"><!-- _locID_text="UserExitDescription1" _locComment="UserExitDescription1" -->[ProductName] setup was interrupted. Your system has not been modified. To install this program at a later time, please run the installation again.</String> <String Id="UserExitDescription2" Overridable="yes"><!-- _locID_text="UserExitDescription2" _locComment="UserExitDescription2" -->Click the Finish button to exit the Setup Wizard.</String> <String Id="VerifyReadyDlg_Title" Overridable="yes"><!-- _locID_text="VerifyReadyDlg_Title" _locComment="VerifyReadyDlg_Title" -->[ProductName] Setup</String> <String Id="VerifyReadyDlgBannerBitmap" Overridable="yes"><!-- _locID_text="VerifyReadyDlgBannerBitmap" _locComment="VerifyReadyDlgBannerBitmap" -->WixUI_Bmp_Banner</String> <String Id="VerifyReadyDlgInstall" Overridable="yes"><!-- _locID_text="VerifyReadyDlgInstall" _locComment="VerifyReadyDlgInstall" -->&amp;Install</String> <String Id="VerifyReadyDlgInstallText" Overridable="yes"><!-- _locID_text="VerifyReadyDlgInstallText" _locComment="VerifyReadyDlgInstallText" -->Click Install to begin the installation. Click Back to review or change any of your installation settings. Click Cancel to exit the wizard.</String> <String Id="VerifyReadyDlgInstallTitle" Overridable="yes"><!-- _locID_text="VerifyReadyDlgInstallTitle" _locComment="VerifyReadyDlgInstallTitle" -->{\WixUI_Font_Title}Ready to install [ProductName]</String> <String Id="VerifyReadyDlgChange" Overridable="yes"><!-- _locID_text="VerifyReadyDlgChange" _locComment="VerifyReadyDlgChange" -->&amp;Change</String> <String Id="VerifyReadyDlgChangeText" Overridable="yes"><!-- _locID_text="VerifyReadyDlgChangeText" _locComment="VerifyReadyDlgChangeText" -->Click Change to begin the installation. Click Back to review or change any of your installation settings. Click Cancel to exit the wizard.</String> <String Id="VerifyReadyDlgChangeTitle" Overridable="yes"><!-- _locID_text="VerifyReadyDlgChangeTitle" _locComment="VerifyReadyDlgChangeTitle" -->{\WixUI_Font_Title}Ready to change [ProductName]</String> <String Id="VerifyReadyDlgRepair" Overridable="yes"><!-- _locID_text="VerifyReadyDlgRepair" _locComment="VerifyReadyDlgRepair" -->Re&amp;pair</String> <String Id="VerifyReadyDlgRepairText" Overridable="yes"><!-- _locID_text="VerifyReadyDlgRepairText" _locComment="VerifyReadyDlgRepairText" -->Click Repair to repair the installation of [ProductName]. Click Back to review or change any of your installation settings. Click Cancel to exit the wizard.</String> <String Id="VerifyReadyDlgRepairTitle" Overridable="yes"><!-- _locID_text="VerifyReadyDlgRepairTitle" _locComment="VerifyReadyDlgRepairTitle" -->{\WixUI_Font_Title}Ready to repair [ProductName]</String> <String Id="VerifyReadyDlgRemove" Overridable="yes"><!-- _locID_text="VerifyReadyDlgRemove" _locComment="VerifyReadyDlgRemove" -->&amp;Remove</String> <String Id="VerifyReadyDlgRemoveText" Overridable="yes"><!-- _locID_text="VerifyReadyDlgRemoveText" _locComment="VerifyReadyDlgRemoveText" -->Click Remove to remove [ProductName] from your computer. Click Back to review or change any of your installation settings. Click Cancel to exit the wizard.</String> <String Id="VerifyReadyDlgRemoveTitle" Overridable="yes"><!-- _locID_text="VerifyReadyDlgRemoveTitle" _locComment="VerifyReadyDlgRemoveTitle" -->{\WixUI_Font_Title}Ready to remove [ProductName]</String> <String Id="VerifyReadyDlgUpdate" Overridable="yes"><!-- _locID_text="VerifyReadyDlgUpdate" _locComment="VerifyReadyDlgUpdate" -->&amp;Update</String> <String Id="VerifyReadyDlgUpdateText" Overridable="yes"><!-- _locID_text="VerifyReadyDlgUpdateText" _locComment="VerifyReadyDlgUpdateText" -->Click Update to update [ProductName] from your computer. Click Back to review or change any of your installation settings. Click Cancel to exit the wizard.</String> <String Id="VerifyReadyDlgUpdateTitle" Overridable="yes"><!-- _locID_text="VerifyReadyDlgUpdateTitle" _locComment="VerifyReadyDlgUpdateTitle" -->{\WixUI_Font_Title}Ready to update [ProductName]</String> <String Id="WaitForCostingDlg_Title" Overridable="yes"><!-- _locID_text="WaitForCostingDlg_Title" _locComment="WaitForCostingDlg_Title" -->[ProductName] Setup</String> <String Id="WaitForCostingDlgReturn" Overridable="yes"><!-- _locID_text="WaitForCostingDlgReturn" _locComment="WaitForCostingDlgReturn" -->&amp;Return</String> <String Id="WaitForCostingDlgText" Overridable="yes"><!-- _locID_text="WaitForCostingDlgText" _locComment="WaitForCostingDlgText" -->Please wait while the installer finishes determining your disk space requirements.</String> <String Id="WaitForCostingDlgIcon" Overridable="yes"><!-- _locID_text="WaitForCostingDlgIcon" _locComment="WaitForCostingDlgIcon" -->WixUI_Ico_Exclam</String> <String Id="WaitForCostingDlgIconTooltip" Overridable="yes"><!-- _locID_text="WaitForCostingDlgIconTooltip" _locComment="WaitForCostingDlgIconTooltip" -->Exclamation icon</String> <String Id="WelcomeDlg_Title" Overridable="yes"><!-- _locID_text="WelcomeDlg_Title" _locComment="WelcomeDlg_Title" -->[ProductName] Setup</String> <String Id="WelcomeDlgBitmap" Overridable="yes"><!-- _locID_text="WelcomeDlgBitmap" _locComment="WelcomeDlgBitmap" -->WixUI_Bmp_Dialog</String> <String Id="WelcomeDlgDescription" Overridable="yes"><!-- _locID_text="WelcomeDlgDescription" _locComment="WelcomeDlgDescription" -->The Setup Wizard will install [ProductName] on your computer. Click Next to continue or Cancel to exit the Setup Wizard.</String> <String Id="WelcomeUpdateDlgDescriptionUpdate" Overridable="yes"><!-- _locID_text="WelcomeUpdateDlgDescriptionUpdate" _locComment="WelcomeUpdateDlgDescriptionUpdate" -->The Setup Wizard will update [ProductName] on your computer. Click Next to continue or Cancel to exit the Setup Wizard.</String> <String Id="WelcomeDlgTitle" Overridable="yes"><!-- _locID_text="WelcomeDlgTitle" _locComment="WelcomeDlgTitle" -->{\WixUI_Font_Bigger}Welcome to the [ProductName] Setup Wizard</String> <String Id="WelcomeEulaDlg_Title" Overridable="yes"><!-- _locID_text="WelcomeEulaDlg_Title" _locComment="WelcomeEulaDlg_Title" -->[ProductName] Setup</String> <String Id="WelcomeEulaDlgBitmap" Overridable="yes"><!-- _locID_text="WelcomeEulaDlgBitmap" _locComment="WelcomeEulaDlgBitmap" -->WixUI_Bmp_Dialog</String> <String Id="WelcomeEulaDlgInstall" Overridable="yes"><!-- _locID_text="WelcomeEulaDlgInstall" _locComment="WelcomeEulaDlgInstall" -->&amp;Install</String> <String Id="WelcomeEulaDlgUpdate" Overridable="yes"><!-- _locID_text="WelcomeEulaDlgUpdate" _locComment="WelcomeEulaDlgUpdate" -->&amp;Update</String> <String Id="ProgressTextInstallValidate" Overridable="yes"><!-- _locID_text="ProgressTextInstallValidate" _locComment="ProgressTextInstallValidate" -->Validating install</String> <String Id="ProgressTextInstallFiles" Overridable="yes"><!-- _locID_text="ProgressTextInstallFiles" _locComment="ProgressTextInstallFiles" -->Copying new files</String> <String Id="ProgressTextInstallFilesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextInstallFilesTemplate" _locComment="ProgressTextInstallFilesTemplate" -->File: [1], Directory: [9], Size: [6]</String> <String Id="ProgressTextInstallAdminPackage" Overridable="yes"><!-- _locID_text="ProgressTextInstallAdminPackage" _locComment="ProgressTextInstallAdminPackage" -->Copying network install files</String> <String Id="ProgressTextInstallAdminPackageTemplate" Overridable="yes"><!-- _locID_text="ProgressTextInstallAdminPackageTemplate" _locComment="ProgressTextInstallAdminPackageTemplate" -->File: [1], Directory: [9], Size: [6]</String> <String Id="ProgressTextFileCost" Overridable="yes"><!-- _locID_text="ProgressTextFileCost" _locComment="ProgressTextFileCost" -->Computing space requirements</String> <String Id="ProgressTextCostInitialize" Overridable="yes"><!-- _locID_text="ProgressTextCostInitialize" _locComment="ProgressTextCostInitialize" -->Computing space requirements</String> <String Id="ProgressTextCostFinalize" Overridable="yes"><!-- _locID_text="ProgressTextCostFinalize" _locComment="ProgressTextCostFinalize" -->Computing space requirements</String> <String Id="ProgressTextCreateShortcuts" Overridable="yes"><!-- _locID_text="ProgressTextCreateShortcuts" _locComment="ProgressTextCreateShortcuts" -->Creating shortcuts</String> <String Id="ProgressTextCreateShortcutsTemplate" Overridable="yes"><!-- _locID_text="ProgressTextCreateShortcutsTemplate" _locComment="ProgressTextCreateShortcutsTemplate" -->Shortcut: [1]</String> <String Id="ProgressTextPublishComponents" Overridable="yes"><!-- _locID_text="ProgressTextPublishComponents" _locComment="ProgressTextPublishComponents" -->Publishing Qualified Components</String> <String Id="ProgressTextPublishComponentsTemplate" Overridable="yes"><!-- _locID_text="ProgressTextPublishComponentsTemplate" _locComment="ProgressTextPublishComponentsTemplate" -->Component ID: [1], Qualifier: [2]</String> <String Id="ProgressTextPublishFeatures" Overridable="yes"><!-- _locID_text="ProgressTextPublishFeatures" _locComment="ProgressTextPublishFeatures" -->Publishing Product Features</String> <String Id="ProgressTextPublishFeaturesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextPublishFeaturesTemplate" _locComment="ProgressTextPublishFeaturesTemplate" -->Feature: [1]</String> <String Id="ProgressTextPublishProduct" Overridable="yes"><!-- _locID_text="ProgressTextPublishProduct" _locComment="ProgressTextPublishProduct" -->Publishing product information</String> <String Id="ProgressTextRegisterClassInfo" Overridable="yes"><!-- _locID_text="ProgressTextRegisterClassInfo" _locComment="ProgressTextRegisterClassInfo" -->Registering Class servers</String> <String Id="ProgressTextRegisterClassInfoTemplate" Overridable="yes"><!-- _locID_text="ProgressTextRegisterClassInfoTemplate" _locComment="ProgressTextRegisterClassInfoTemplate" -->Class Id: [1]</String> <String Id="ProgressTextRegisterExtensionInfo" Overridable="yes"><!-- _locID_text="ProgressTextRegisterExtensionInfo" _locComment="ProgressTextRegisterExtensionInfo" -->Registering extension servers</String> <String Id="ProgressTextRegisterExtensionInfoTemplate" Overridable="yes"><!-- _locID_text="ProgressTextRegisterExtensionInfoTemplate" _locComment="ProgressTextRegisterExtensionInfoTemplate" -->Extension: [1]</String> <String Id="ProgressTextRegisterMIMEInfo" Overridable="yes"><!-- _locID_text="ProgressTextRegisterMIMEInfo" _locComment="ProgressTextRegisterMIMEInfo" -->Registering MIME info</String> <String Id="ProgressTextRegisterMIMEInfoTemplate" Overridable="yes"><!-- _locID_text="ProgressTextRegisterMIMEInfoTemplate" _locComment="ProgressTextRegisterMIMEInfoTemplate" -->MIME Content Type: [1], Extension: [2]</String> <String Id="ProgressTextRegisterProgIdInfo" Overridable="yes"><!-- _locID_text="ProgressTextRegisterProgIdInfo" _locComment="ProgressTextRegisterProgIdInfo" -->Registering program identifiers</String> <String Id="ProgressTextRegisterProgIdInfoTemplate" Overridable="yes"><!-- _locID_text="ProgressTextRegisterProgIdInfoTemplate" _locComment="ProgressTextRegisterProgIdInfoTemplate" -->ProgId: [1]</String> <String Id="ProgressTextAllocateRegistrySpace" Overridable="yes"><!-- _locID_text="ProgressTextAllocateRegistrySpace" _locComment="ProgressTextAllocateRegistrySpace" -->Allocating registry space</String> <String Id="ProgressTextAllocateRegistrySpaceTemplate" Overridable="yes"><!-- _locID_text="ProgressTextAllocateRegistrySpaceTemplate" _locComment="ProgressTextAllocateRegistrySpaceTemplate" -->Free space: [1]</String> <String Id="ProgressTextAppSearch" Overridable="yes"><!-- _locID_text="ProgressTextAppSearch" _locComment="ProgressTextAppSearch" -->Searching for installed applications</String> <String Id="ProgressTextAppSearchTemplate" Overridable="yes"><!-- _locID_text="ProgressTextAppSearchTemplate" _locComment="ProgressTextAppSearchTemplate" -->Property: [1], Signature: [2]</String> <String Id="ProgressTextBindImage" Overridable="yes"><!-- _locID_text="ProgressTextBindImage" _locComment="ProgressTextBindImage" -->Binding executables</String> <String Id="ProgressTextBindImageTemplate" Overridable="yes"><!-- _locID_text="ProgressTextBindImageTemplate" _locComment="ProgressTextBindImageTemplate" -->File: [1]</String> <String Id="ProgressTextCCPSearch" Overridable="yes"><!-- _locID_text="ProgressTextCCPSearch" _locComment="ProgressTextCCPSearch" -->Searching for qualifying products</String> <String Id="ProgressTextCreateFolders" Overridable="yes"><!-- _locID_text="ProgressTextCreateFolders" _locComment="ProgressTextCreateFolders" -->Creating folders</String> <String Id="ProgressTextCreateFoldersTemplate" Overridable="yes"><!-- _locID_text="ProgressTextCreateFoldersTemplate" _locComment="ProgressTextCreateFoldersTemplate" -->Folder: [1]</String> <String Id="ProgressTextDeleteServices" Overridable="yes"><!-- _locID_text="ProgressTextDeleteServices" _locComment="ProgressTextDeleteServices" -->Deleting services</String> <String Id="ProgressTextDeleteServicesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextDeleteServicesTemplate" _locComment="ProgressTextDeleteServicesTemplate" -->Service: [1]</String> <String Id="ProgressTextDuplicateFiles" Overridable="yes"><!-- _locID_text="ProgressTextDuplicateFiles" _locComment="ProgressTextDuplicateFiles" -->Creating duplicate files</String> <String Id="ProgressTextDuplicateFilesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextDuplicateFilesTemplate" _locComment="ProgressTextDuplicateFilesTemplate" -->File: [1], Directory: [9], Size: [6]</String> <String Id="ProgressTextFindRelatedProducts" Overridable="yes"><!-- _locID_text="ProgressTextFindRelatedProducts" _locComment="ProgressTextFindRelatedProducts" -->Searching for related applications</String> <String Id="ProgressTextFindRelatedProductsTemplate" Overridable="yes"><!-- _locID_text="ProgressTextFindRelatedProductsTemplate" _locComment="ProgressTextFindRelatedProductsTemplate" -->Found application: [1]</String> <String Id="ProgressTextInstallODBC" Overridable="yes"><!-- _locID_text="ProgressTextInstallODBC" _locComment="ProgressTextInstallODBC" -->Installing ODBC components</String> <String Id="ProgressTextInstallServices" Overridable="yes"><!-- _locID_text="ProgressTextInstallServices" _locComment="ProgressTextInstallServices" -->Installing new services</String> <String Id="ProgressTextInstallServicesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextInstallServicesTemplate" _locComment="ProgressTextInstallServicesTemplate" -->Service: [2]</String> <String Id="ProgressTextLaunchConditions" Overridable="yes"><!-- _locID_text="ProgressTextLaunchConditions" _locComment="ProgressTextLaunchConditions" -->Evaluating launch conditions</String> <String Id="ProgressTextMigrateFeatureStates" Overridable="yes"><!-- _locID_text="ProgressTextMigrateFeatureStates" _locComment="ProgressTextMigrateFeatureStates" -->Migrating feature states from related applications</String> <String Id="ProgressTextMigrateFeatureStatesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextMigrateFeatureStatesTemplate" _locComment="ProgressTextMigrateFeatureStatesTemplate" -->Application: [1]</String> <String Id="ProgressTextMoveFiles" Overridable="yes"><!-- _locID_text="ProgressTextMoveFiles" _locComment="ProgressTextMoveFiles" -->Moving files</String> <String Id="ProgressTextMoveFilesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextMoveFilesTemplate" _locComment="ProgressTextMoveFilesTemplate" -->File: [1], Directory: [9], Size: [6]</String> <String Id="ProgressTextPatchFiles" Overridable="yes"><!-- _locID_text="ProgressTextPatchFiles" _locComment="ProgressTextPatchFiles" -->Patching files</String> <String Id="ProgressTextPatchFilesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextPatchFilesTemplate" _locComment="ProgressTextPatchFilesTemplate" -->File: [1], Directory: [2], Size: [3]</String> <String Id="ProgressTextProcessComponents" Overridable="yes"><!-- _locID_text="ProgressTextProcessComponents" _locComment="ProgressTextProcessComponents" -->Updating component registration</String> <String Id="ProgressTextRegisterComPlus" Overridable="yes"><!-- _locID_text="ProgressTextRegisterComPlus" _locComment="ProgressTextRegisterComPlus" -->Registering COM+ Applications and Components</String> <String Id="ProgressTextRegisterComPlusTemplate" Overridable="yes"><!-- _locID_text="ProgressTextRegisterComPlusTemplate" _locComment="ProgressTextRegisterComPlusTemplate" -->AppId: [1]{{, AppType: [2], Users: [3], RSN: [4]}}</String> <String Id="ProgressTextRegisterFonts" Overridable="yes"><!-- _locID_text="ProgressTextRegisterFonts" _locComment="ProgressTextRegisterFonts" -->Registering fonts</String> <String Id="ProgressTextRegisterFontsTemplate" Overridable="yes"><!-- _locID_text="ProgressTextRegisterFontsTemplate" _locComment="ProgressTextRegisterFontsTemplate" -->Font: [1]</String> <String Id="ProgressTextRegisterProduct" Overridable="yes"><!-- _locID_text="ProgressTextRegisterProduct" _locComment="ProgressTextRegisterProduct" -->Registering product</String> <String Id="ProgressTextRegisterProductTemplate" Overridable="yes"><!-- _locID_text="ProgressTextRegisterProductTemplate" _locComment="ProgressTextRegisterProductTemplate" -->[1]</String> <String Id="ProgressTextRegisterTypeLibraries" Overridable="yes"><!-- _locID_text="ProgressTextRegisterTypeLibraries" _locComment="ProgressTextRegisterTypeLibraries" -->Registering type libraries</String> <String Id="ProgressTextRegisterTypeLibrariesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextRegisterTypeLibrariesTemplate" _locComment="ProgressTextRegisterTypeLibrariesTemplate" -->LibID: [1]</String> <String Id="ProgressTextRegisterUser" Overridable="yes"><!-- _locID_text="ProgressTextRegisterUser" _locComment="ProgressTextRegisterUser" -->Registering user</String> <String Id="ProgressTextRegisterUserTemplate" Overridable="yes"><!-- _locID_text="ProgressTextRegisterUserTemplate" _locComment="ProgressTextRegisterUserTemplate" -->[1]</String> <String Id="ProgressTextRemoveDuplicateFiles" Overridable="yes"><!-- _locID_text="ProgressTextRemoveDuplicateFiles" _locComment="ProgressTextRemoveDuplicateFiles" -->Removing duplicated files</String> <String Id="ProgressTextRemoveDuplicateFilesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextRemoveDuplicateFilesTemplate" _locComment="ProgressTextRemoveDuplicateFilesTemplate" -->File: [1], Directory: [9]</String> <String Id="ProgressTextRemoveEnvironmentStrings" Overridable="yes"><!-- _locID_text="ProgressTextRemoveEnvironmentStrings" _locComment="ProgressTextRemoveEnvironmentStrings" -->Updating environment strings</String> <String Id="ProgressTextRemoveEnvironmentStringsTemplate" Overridable="yes"><!-- _locID_text="ProgressTextRemoveEnvironmentStringsTemplate" _locComment="ProgressTextRemoveEnvironmentStringsTemplate" -->Name: [1], Value: [2], Action [3]</String> <String Id="ProgressTextRemoveExistingProducts" Overridable="yes"><!-- _locID_text="ProgressTextRemoveExistingProducts" _locComment="ProgressTextRemoveExistingProducts" -->Removing applications</String> <String Id="ProgressTextRemoveExistingProductsTemplate" Overridable="yes"><!-- _locID_text="ProgressTextRemoveExistingProductsTemplate" _locComment="ProgressTextRemoveExistingProductsTemplate" -->Application: [1], Command line: [2]</String> <String Id="ProgressTextRemoveFiles" Overridable="yes"><!-- _locID_text="ProgressTextRemoveFiles" _locComment="ProgressTextRemoveFiles" -->Removing files</String> <String Id="ProgressTextRemoveFilesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextRemoveFilesTemplate" _locComment="ProgressTextRemoveFilesTemplate" -->File: [1], Directory: [9]</String> <String Id="ProgressTextRemoveFolders" Overridable="yes"><!-- _locID_text="ProgressTextRemoveFolders" _locComment="ProgressTextRemoveFolders" -->Removing folders</String> <String Id="ProgressTextRemoveFoldersTemplate" Overridable="yes"><!-- _locID_text="ProgressTextRemoveFoldersTemplate" _locComment="ProgressTextRemoveFoldersTemplate" -->Folder: [1]</String> <String Id="ProgressTextRemoveIniValues" Overridable="yes"><!-- _locID_text="ProgressTextRemoveIniValues" _locComment="ProgressTextRemoveIniValues" -->Removing INI files entries</String> <String Id="ProgressTextRemoveIniValuesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextRemoveIniValuesTemplate" _locComment="ProgressTextRemoveIniValuesTemplate" -->File: [1], Section: [2], Key: [3], Value: [4]</String> <String Id="ProgressTextRemoveODBC" Overridable="yes"><!-- _locID_text="ProgressTextRemoveODBC" _locComment="ProgressTextRemoveODBC" -->Removing ODBC components</String> <String Id="ProgressTextRemoveRegistryValues" Overridable="yes"><!-- _locID_text="ProgressTextRemoveRegistryValues" _locComment="ProgressTextRemoveRegistryValues" -->Removing system registry values</String> <String Id="ProgressTextRemoveRegistryValuesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextRemoveRegistryValuesTemplate" _locComment="ProgressTextRemoveRegistryValuesTemplate" -->Key: [1], Name: [2]</String> <String Id="ProgressTextRemoveShortcuts" Overridable="yes"><!-- _locID_text="ProgressTextRemoveShortcuts" _locComment="ProgressTextRemoveShortcuts" -->Removing shortcuts</String> <String Id="ProgressTextRemoveShortcutsTemplate" Overridable="yes"><!-- _locID_text="ProgressTextRemoveShortcutsTemplate" _locComment="ProgressTextRemoveShortcutsTemplate" -->Shortcut: [1]</String> <String Id="ProgressTextRMCCPSearch" Overridable="yes"><!-- _locID_text="ProgressTextRMCCPSearch" _locComment="ProgressTextRMCCPSearch" -->Searching for qualifying products</String> <String Id="ProgressTextSelfRegModules" Overridable="yes"><!-- _locID_text="ProgressTextSelfRegModules" _locComment="ProgressTextSelfRegModules" -->Registering modules</String> <String Id="ProgressTextSelfRegModulesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextSelfRegModulesTemplate" _locComment="ProgressTextSelfRegModulesTemplate" -->File: [1], Folder: [2]</String> <String Id="ProgressTextSelfUnregModules" Overridable="yes"><!-- _locID_text="ProgressTextSelfUnregModules" _locComment="ProgressTextSelfUnregModules" -->Unregistering modules</String> <String Id="ProgressTextSelfUnregModulesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextSelfUnregModulesTemplate" _locComment="ProgressTextSelfUnregModulesTemplate" -->File: [1], Folder: [2]</String> <String Id="ProgressTextSetODBCFolders" Overridable="yes"><!-- _locID_text="ProgressTextSetODBCFolders" _locComment="ProgressTextSetODBCFolders" -->Initializing ODBC directories</String> <String Id="ProgressTextStartServices" Overridable="yes"><!-- _locID_text="ProgressTextStartServices" _locComment="ProgressTextStartServices" -->Starting services</String> <String Id="ProgressTextStartServicesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextStartServicesTemplate" _locComment="ProgressTextStartServicesTemplate" -->Service: [1]</String> <String Id="ProgressTextStopServices" Overridable="yes"><!-- _locID_text="ProgressTextStopServices" _locComment="ProgressTextStopServices" -->Stopping services</String> <String Id="ProgressTextStopServicesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextStopServicesTemplate" _locComment="ProgressTextStopServicesTemplate" -->Service: [1]</String> <String Id="ProgressTextUnpublishComponents" Overridable="yes"><!-- _locID_text="ProgressTextUnpublishComponents" _locComment="ProgressTextUnpublishComponents" -->Unpublishing Qualified Components</String> <String Id="ProgressTextUnpublishComponentsTemplate" Overridable="yes"><!-- _locID_text="ProgressTextUnpublishComponentsTemplate" _locComment="ProgressTextUnpublishComponentsTemplate" -->Component ID: [1], Qualifier: [2]</String> <String Id="ProgressTextUnpublishFeatures" Overridable="yes"><!-- _locID_text="ProgressTextUnpublishFeatures" _locComment="ProgressTextUnpublishFeatures" -->Unpublishing Product Features</String> <String Id="ProgressTextUnpublishFeaturesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextUnpublishFeaturesTemplate" _locComment="ProgressTextUnpublishFeaturesTemplate" -->Feature: [1]</String> <String Id="ProgressTextUnregisterClassInfo" Overridable="yes"><!-- _locID_text="ProgressTextUnregisterClassInfo" _locComment="ProgressTextUnregisterClassInfo" -->Unregister Class servers</String> <String Id="ProgressTextUnregisterClassInfoTemplate" Overridable="yes"><!-- _locID_text="ProgressTextUnregisterClassInfoTemplate" _locComment="ProgressTextUnregisterClassInfoTemplate" -->Class Id: [1]</String> <String Id="ProgressTextUnregisterComPlus" Overridable="yes"><!-- _locID_text="ProgressTextUnregisterComPlus" _locComment="ProgressTextUnregisterComPlus" -->Unregistering COM+ Applications and Components</String> <String Id="ProgressTextUnregisterComPlusTemplate" Overridable="yes"><!-- _locID_text="ProgressTextUnregisterComPlusTemplate" _locComment="ProgressTextUnregisterComPlusTemplate" -->AppId: [1]{{, AppType: [2]}}</String> <String Id="ProgressTextUnregisterExtensionInfo" Overridable="yes"><!-- _locID_text="ProgressTextUnregisterExtensionInfo" _locComment="ProgressTextUnregisterExtensionInfo" -->Unregistering extension servers</String> <String Id="ProgressTextUnregisterExtensionInfoTemplate" Overridable="yes"><!-- _locID_text="ProgressTextUnregisterExtensionInfoTemplate" _locComment="ProgressTextUnregisterExtensionInfoTemplate" -->Extension: [1]</String> <String Id="ProgressTextUnregisterFonts" Overridable="yes"><!-- _locID_text="ProgressTextUnregisterFonts" _locComment="ProgressTextUnregisterFonts" -->Unregistering fonts</String> <String Id="ProgressTextUnregisterFontsTemplate" Overridable="yes"><!-- _locID_text="ProgressTextUnregisterFontsTemplate" _locComment="ProgressTextUnregisterFontsTemplate" -->Font: [1]</String> <String Id="ProgressTextUnregisterMIMEInfo" Overridable="yes"><!-- _locID_text="ProgressTextUnregisterMIMEInfo" _locComment="ProgressTextUnregisterMIMEInfo" -->Unregistering MIME info</String> <String Id="ProgressTextUnregisterMIMEInfoTemplate" Overridable="yes"><!-- _locID_text="ProgressTextUnregisterMIMEInfoTemplate" _locComment="ProgressTextUnregisterMIMEInfoTemplate" -->MIME Content Type: [1], Extension: [2]</String> <String Id="ProgressTextUnregisterProgIdInfo" Overridable="yes"><!-- _locID_text="ProgressTextUnregisterProgIdInfo" _locComment="ProgressTextUnregisterProgIdInfo" -->Unregistering program identifiers</String> <String Id="ProgressTextUnregisterProgIdInfoTemplate" Overridable="yes"><!-- _locID_text="ProgressTextUnregisterProgIdInfoTemplate" _locComment="ProgressTextUnregisterProgIdInfoTemplate" -->ProgId: [1]</String> <String Id="ProgressTextUnregisterTypeLibraries" Overridable="yes"><!-- _locID_text="ProgressTextUnregisterTypeLibraries" _locComment="ProgressTextUnregisterTypeLibraries" -->Unregistering type libraries</String> <String Id="ProgressTextUnregisterTypeLibrariesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextUnregisterTypeLibrariesTemplate" _locComment="ProgressTextUnregisterTypeLibrariesTemplate" -->LibID: [1]</String> <String Id="ProgressTextWriteEnvironmentStrings" Overridable="yes"><!-- _locID_text="ProgressTextWriteEnvironmentStrings" _locComment="ProgressTextWriteEnvironmentStrings" -->Updating environment strings</String> <String Id="ProgressTextWriteEnvironmentStringsTemplate" Overridable="yes"><!-- _locID_text="ProgressTextWriteEnvironmentStringsTemplate" _locComment="ProgressTextWriteEnvironmentStringsTemplate" -->Name: [1], Value: [2], Action [3]</String> <String Id="ProgressTextWriteIniValues" Overridable="yes"><!-- _locID_text="ProgressTextWriteIniValues" _locComment="ProgressTextWriteIniValues" -->Writing INI files values</String> <String Id="ProgressTextWriteIniValuesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextWriteIniValuesTemplate" _locComment="ProgressTextWriteIniValuesTemplate" -->File: [1], Section: [2], Key: [3], Value: [4]</String> <String Id="ProgressTextWriteRegistryValues" Overridable="yes"><!-- _locID_text="ProgressTextWriteRegistryValues" _locComment="ProgressTextWriteRegistryValues" -->Writing system registry values</String> <String Id="ProgressTextWriteRegistryValuesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextWriteRegistryValuesTemplate" _locComment="ProgressTextWriteRegistryValuesTemplate" -->Key: [1], Name: [2], Value: [3]</String> <String Id="ProgressTextAdvertise" Overridable="yes"><!-- _locID_text="ProgressTextAdvertise" _locComment="ProgressTextAdvertise" -->Advertising application</String> <String Id="ProgressTextGenerateScript" Overridable="yes"><!-- _locID_text="ProgressTextGenerateScript" _locComment="ProgressTextGenerateScript" -->Generating script operations for action:</String> <String Id="ProgressTextGenerateScriptTemplate" Overridable="yes"><!-- _locID_text="ProgressTextGenerateScriptTemplate" _locComment="ProgressTextGenerateScriptTemplate" -->[1]</String> <String Id="ProgressTextInstallSFPCatalogFile" Overridable="yes"><!-- _locID_text="ProgressTextInstallSFPCatalogFile" _locComment="ProgressTextInstallSFPCatalogFile" -->Installing system catalog</String> <String Id="ProgressTextInstallSFPCatalogFileTemplate" Overridable="yes"><!-- _locID_text="ProgressTextInstallSFPCatalogFileTemplate" _locComment="ProgressTextInstallSFPCatalogFileTemplate" -->File: [1], Dependencies: [2]</String> <String Id="ProgressTextMsiPublishAssemblies" Overridable="yes"><!-- _locID_text="ProgressTextMsiPublishAssemblies" _locComment="ProgressTextMsiPublishAssemblies" -->Publishing assembly information</String> <String Id="ProgressTextMsiPublishAssembliesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextMsiPublishAssembliesTemplate" _locComment="ProgressTextMsiPublishAssembliesTemplate" -->Application Context:[1], Assembly Name:[2]</String> <String Id="ProgressTextMsiUnpublishAssemblies" Overridable="yes"><!-- _locID_text="ProgressTextMsiUnpublishAssemblies" _locComment="ProgressTextMsiUnpublishAssemblies" -->Unpublishing assembly information</String> <String Id="ProgressTextMsiUnpublishAssembliesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextMsiUnpublishAssembliesTemplate" _locComment="ProgressTextMsiUnpublishAssembliesTemplate" -->Application Context:[1], Assembly Name:[2]</String> <String Id="ProgressTextRollback" Overridable="yes"><!-- _locID_text="ProgressTextRollback" _locComment="ProgressTextRollback" -->Rolling back action:</String> <String Id="ProgressTextRollbackTemplate" Overridable="yes"><!-- _locID_text="ProgressTextRollbackTemplate" _locComment="ProgressTextRollbackTemplate" -->[1]</String> <String Id="ProgressTextRollbackCleanup" Overridable="yes"><!-- _locID_text="ProgressTextRollbackCleanup" _locComment="ProgressTextRollbackCleanup" -->Removing backup files</String> <String Id="ProgressTextRollbackCleanupTemplate" Overridable="yes"><!-- _locID_text="ProgressTextRollbackCleanupTemplate" _locComment="ProgressTextRollbackCleanupTemplate" -->File: [1]</String> <String Id="ProgressTextUnmoveFiles" Overridable="yes"><!-- _locID_text="ProgressTextUnmoveFiles" _locComment="ProgressTextUnmoveFiles" -->Removing moved files</String> <String Id="ProgressTextUnmoveFilesTemplate" Overridable="yes"><!-- _locID_text="ProgressTextUnmoveFilesTemplate" _locComment="ProgressTextUnmoveFilesTemplate" -->File: [1], Directory: [9]</String> <String Id="ProgressTextUnpublishProduct" Overridable="yes"><!-- _locID_text="ProgressTextUnpublishProduct" _locComment="ProgressTextUnpublishProduct" -->Unpublishing product information</String> <String Id="Error0" Overridable="yes"><!-- _locID_text="Error0" _locComment="Error0" -->{{Fatal error: }}</String> <String Id="Error1" Overridable="yes"><!-- _locID_text="Error1" _locComment="Error1" -->{{Error [1]. }}</String> <String Id="Error2" Overridable="yes"><!-- _locID_text="Error2" _locComment="Error2" -->Warning [1]. </String> <String Id="Error4" Overridable="yes"><!-- _locID_text="Error4" _locComment="Error4" -->Info [1]. </String> <String Id="Error5" Overridable="yes"><!-- _locID_text="Error5" _locComment="Error5" -->The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is [1]. {{The arguments are: [2], [3], [4]}}</String> <String Id="Error7" Overridable="yes"><!-- _locID_text="Error7" _locComment="Error7" -->{{Disk full: }}</String> <String Id="Error8" Overridable="yes"><!-- _locID_text="Error8" _locComment="Error8" -->Action [Time]: [1]. [2]</String> <String Id="Error9" Overridable="yes"><!-- _locID_text="Error9" _locComment="Error9" -->[ProductName]</String> <String Id="Error10" Overridable="yes"><!-- _locID_text="Error10" _locComment="Error10" -->{[2]}{, [3]}{, [4]}</String> <String Id="Error11" Overridable="yes"><!-- _locID_text="Error11" _locComment="Error11" -->Message type: [1], Argument: [2]</String> <String Id="Error12" Overridable="yes"><!-- _locID_text="Error12" _locComment="Error12" -->=== Logging started: [Date] [Time] ===</String> <String Id="Error13" Overridable="yes"><!-- _locID_text="Error13" _locComment="Error13" -->=== Logging stopped: [Date] [Time] ===</String> <String Id="Error14" Overridable="yes"><!-- _locID_text="Error14" _locComment="Error14" -->Action start [Time]: [1].</String> <String Id="Error15" Overridable="yes"><!-- _locID_text="Error15" _locComment="Error15" -->Action ended [Time]: [1]. Return value [2].</String> <String Id="Error16" Overridable="yes"><!-- _locID_text="Error16" _locComment="Error16" -->Time remaining: {[1] minutes }{[2] seconds}</String> <String Id="Error17" Overridable="yes"><!-- _locID_text="Error17" _locComment="Error17" -->Out of memory. Shut down other applications before retrying.</String> <String Id="Error18" Overridable="yes"><!-- _locID_text="Error18" _locComment="Error18" -->Installer is no longer responding.</String> <String Id="Error19" Overridable="yes"><!-- _locID_text="Error19" _locComment="Error19" -->Installer stopped prematurely.</String> <String Id="Error20" Overridable="yes"><!-- _locID_text="Error20" _locComment="Error20" -->Please wait while Windows configures [ProductName]</String> <String Id="Error21" Overridable="yes"><!-- _locID_text="Error21" _locComment="Error21" -->Gathering required information...</String> <String Id="Error22" Overridable="yes"><!-- _locID_text="Error22" _locComment="Error22" -->Removing older versions of this application...</String> <String Id="Error23" Overridable="yes"><!-- _locID_text="Error23" _locComment="Error23" -->Preparing to remove older versions of this application...</String> <String Id="Error32" Overridable="yes"><!-- _locID_text="Error32" _locComment="Error32" -->{[ProductName] }Setup completed successfully.</String> <String Id="Error33" Overridable="yes"><!-- _locID_text="Error33" _locComment="Error33" -->{[ProductName] }Setup failed.</String> <String Id="Error1101" Overridable="yes"><!-- _locID_text="Error1101" _locComment="Error1101" -->Error reading from file: [2]. {{ System error [3].}} Verify that the file exists and that you can access it.</String> <String Id="Error1301" Overridable="yes"><!-- _locID_text="Error1301" _locComment="Error1301" -->Cannot create the file '[2]'. A directory with this name already exists. Cancel the install and try installing to a different location.</String> <String Id="Error1302" Overridable="yes"><!-- _locID_text="Error1302" _locComment="Error1302" -->Please insert the disk: [2]</String> <String Id="Error1303" Overridable="yes"><!-- _locID_text="Error1303" _locComment="Error1303" -->The installer has insufficient privileges to access this directory: [2]. The installation cannot continue. Log on as administrator or contact your system administrator.</String> <String Id="Error1304" Overridable="yes"><!-- _locID_text="Error1304" _locComment="Error1304" -->Error writing to file: [2]. Verify that you have access to that directory.</String> <String Id="Error1305" Overridable="yes"><!-- _locID_text="Error1305" _locComment="Error1305" -->Error reading from file [2]. {{ System error [3].}} Verify that the file exists and that you can access it.</String> <String Id="Error1306" Overridable="yes"><!-- _locID_text="Error1306" _locComment="Error1306" -->Another application has exclusive access to the file '[2]'. Please shut down all other applications, then click Retry.</String> <String Id="Error1307" Overridable="yes"><!-- _locID_text="Error1307" _locComment="Error1307" -->There is not enough disk space to install this file: [2]. Free some disk space and click Retry, or click Cancel to exit.</String> <String Id="Error1308" Overridable="yes"><!-- _locID_text="Error1308" _locComment="Error1308" -->Source file not found: [2]. Verify that the file exists and that you can access it.</String> <String Id="Error1309" Overridable="yes"><!-- _locID_text="Error1309" _locComment="Error1309" -->Error reading from file: [3]. {{ System error [2].}} Verify that the file exists and that you can access it.</String> <String Id="Error1310" Overridable="yes"><!-- _locID_text="Error1310" _locComment="Error1310" -->Error writing to file: [3]. {{ System error [2].}} Verify that you have access to that directory.</String> <String Id="Error1311" Overridable="yes"><!-- _locID_text="Error1311" _locComment="Error1311" -->Source file not found{{(cabinet)}}: [2]. Verify that the file exists and that you can access it.</String> <String Id="Error1312" Overridable="yes"><!-- _locID_text="Error1312" _locComment="Error1312" -->Cannot create the directory '[2]'. A file with this name already exists. Please rename or remove the file and click Retry, or click Cancel to exit.</String> <String Id="Error1313" Overridable="yes"><!-- _locID_text="Error1313" _locComment="Error1313" -->The volume [2] is currently unavailable. Please select another.</String> <String Id="Error1314" Overridable="yes"><!-- _locID_text="Error1314" _locComment="Error1314" -->The specified path '[2]' is unavailable.</String> <String Id="Error1315" Overridable="yes"><!-- _locID_text="Error1315" _locComment="Error1315" -->Unable to write to the specified folder: [2].</String> <String Id="Error1316" Overridable="yes"><!-- _locID_text="Error1316" _locComment="Error1316" -->A network error occurred while attempting to read from the file: [2]</String> <String Id="Error1317" Overridable="yes"><!-- _locID_text="Error1317" _locComment="Error1317" -->An error occurred while attempting to create the directory: [2]</String> <String Id="Error1318" Overridable="yes"><!-- _locID_text="Error1318" _locComment="Error1318" -->A network error occurred while attempting to create the directory: [2]</String> <String Id="Error1319" Overridable="yes"><!-- _locID_text="Error1319" _locComment="Error1319" -->A network error occurred while attempting to open the source file cabinet: [2]</String> <String Id="Error1320" Overridable="yes"><!-- _locID_text="Error1320" _locComment="Error1320" -->The specified path is too long: [2]</String> <String Id="Error1321" Overridable="yes"><!-- _locID_text="Error1321" _locComment="Error1321" -->The Installer has insufficient privileges to modify this file: [2].</String> <String Id="Error1322" Overridable="yes"><!-- _locID_text="Error1322" _locComment="Error1322" -->A portion of the folder path '[2]' is invalid. It is either empty or exceeds the length allowed by the system.</String> <String Id="Error1323" Overridable="yes"><!-- _locID_text="Error1323" _locComment="Error1323" -->The folder path '[2]' contains words that are not valid in folder paths.</String> <String Id="Error1324" Overridable="yes"><!-- _locID_text="Error1324" _locComment="Error1324" -->The folder path '[2]' contains an invalid character.</String> <String Id="Error1325" Overridable="yes"><!-- _locID_text="Error1325" _locComment="Error1325" -->'[2]' is not a valid short file name.</String> <String Id="Error1326" Overridable="yes"><!-- _locID_text="Error1326" _locComment="Error1326" -->Error getting file security: [3] GetLastError: [2]</String> <String Id="Error1327" Overridable="yes"><!-- _locID_text="Error1327" _locComment="Error1327" -->Invalid Drive: [2]</String> <String Id="Error1328" Overridable="yes"><!-- _locID_text="Error1328" _locComment="Error1328" -->Error applying patch to file [2]. It has probably been updated by other means, and can no longer be modified by this patch. For more information contact your patch vendor. {{System Error: [3]}}</String> <String Id="Error1329" Overridable="yes"><!-- _locID_text="Error1329" _locComment="Error1329" -->A file that is required cannot be installed because the cabinet file [2] is not digitally signed. This may indicate that the cabinet file is corrupt.</String> <String Id="Error1330" Overridable="yes"><!-- _locID_text="Error1330" _locComment="Error1330" -->A file that is required cannot be installed because the cabinet file [2] has an invalid digital signature. This may indicate that the cabinet file is corrupt.{{ Error [3] was returned by WinVerifyTrust.}}</String> <String Id="Error1331" Overridable="yes"><!-- _locID_text="Error1331" _locComment="Error1331" -->Failed to correctly copy [2] file: CRC error.</String> <String Id="Error1332" Overridable="yes"><!-- _locID_text="Error1332" _locComment="Error1332" -->Failed to correctly move [2] file: CRC error.</String> <String Id="Error1333" Overridable="yes"><!-- _locID_text="Error1333" _locComment="Error1333" -->Failed to correctly patch [2] file: CRC error.</String> <String Id="Error1334" Overridable="yes"><!-- _locID_text="Error1334" _locComment="Error1334" -->The file '[2]' cannot be installed because the file cannot be found in cabinet file '[3]'. This could indicate a network error, an error reading from the CD-ROM, or a problem with this package.</String> <String Id="Error1335" Overridable="yes"><!-- _locID_text="Error1335" _locComment="Error1335" -->The cabinet file '[2]' required for this installation is corrupt and cannot be used. This could indicate a network error, an error reading from the CD-ROM, or a problem with this package.</String> <String Id="Error1336" Overridable="yes"><!-- _locID_text="Error1336" _locComment="Error1336" -->There was an error creating a temporary file that is needed to complete this installation.{{ Folder: [3]. System error code: [2]}}</String> <String Id="Error1401" Overridable="yes"><!-- _locID_text="Error1401" _locComment="Error1401" -->Could not create key: [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel. </String> <String Id="Error1402" Overridable="yes"><!-- _locID_text="Error1402" _locComment="Error1402" -->Could not open key: [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel. </String> <String Id="Error1403" Overridable="yes"><!-- _locID_text="Error1403" _locComment="Error1403" -->Could not delete value [2] from key [3]. {{ System error [4].}} Verify that you have sufficient access to that key, or contact your support personnel. </String> <String Id="Error1404" Overridable="yes"><!-- _locID_text="Error1404" _locComment="Error1404" -->Could not delete key [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel. </String> <String Id="Error1405" Overridable="yes"><!-- _locID_text="Error1405" _locComment="Error1405" -->Could not read value [2] from key [3]. {{ System error [4].}} Verify that you have sufficient access to that key, or contact your support personnel. </String> <String Id="Error1406" Overridable="yes"><!-- _locID_text="Error1406" _locComment="Error1406" -->Could not write value [2] to key [3]. {{ System error [4].}} Verify that you have sufficient access to that key, or contact your support personnel.</String> <String Id="Error1407" Overridable="yes"><!-- _locID_text="Error1407" _locComment="Error1407" -->Could not get value names for key [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel.</String> <String Id="Error1408" Overridable="yes"><!-- _locID_text="Error1408" _locComment="Error1408" -->Could not get sub key names for key [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel.</String> <String Id="Error1409" Overridable="yes"><!-- _locID_text="Error1409" _locComment="Error1409" -->Could not read security information for key [2]. {{ System error [3].}} Verify that you have sufficient access to that key, or contact your support personnel.</String> <String Id="Error1410" Overridable="yes"><!-- _locID_text="Error1410" _locComment="Error1410" -->Could not increase the available registry space. [2] KB of free registry space is required for the installation of this application.</String> <String Id="Error1500" Overridable="yes"><!-- _locID_text="Error1500" _locComment="Error1500" -->Another installation is in progress. You must complete that installation before continuing this one.</String> <String Id="Error1501" Overridable="yes"><!-- _locID_text="Error1501" _locComment="Error1501" -->Error accessing secured data. Please make sure the Windows Installer is configured properly and try the install again.</String> <String Id="Error1502" Overridable="yes"><!-- _locID_text="Error1502" _locComment="Error1502" -->User '[2]' has previously initiated an install for product '[3]'. That user will need to run that install again before they can use that product. Your current install will now continue.</String> <String Id="Error1503" Overridable="yes"><!-- _locID_text="Error1503" _locComment="Error1503" -->User '[2]' has previously initiated an install for product '[3]'. That user will need to run that install again before they can use that product.</String> <String Id="Error1601" Overridable="yes"><!-- _locID_text="Error1601" _locComment="Error1601" -->Out of disk space -- Volume: '[2]'; required space: [3] KB; available space: [4] KB. Free some disk space and retry.</String> <String Id="Error1602" Overridable="yes"><!-- _locID_text="Error1602" _locComment="Error1602" -->Are you sure you want to cancel?</String> <String Id="Error1603" Overridable="yes"><!-- _locID_text="Error1603" _locComment="Error1603" -->The file [2][3] is being held in use{ by the following process: Name: [4], Id: [5], Window Title: '[6]'}. Close that application and retry.</String> <String Id="Error1604" Overridable="yes"><!-- _locID_text="Error1604" _locComment="Error1604" -->The product '[2]' is already installed, preventing the installation of this product. The two products are incompatible.</String> <String Id="Error1605" Overridable="yes"><!-- _locID_text="Error1605" _locComment="Error1605" -->There is not enough disk space on the volume '[2]' to continue the install with recovery enabled. [3] KB are required, but only [4] KB are available. Click Ignore to continue the install without saving recovery information, click Retry to check for available space again, or click Cancel to quit the installation.</String> <String Id="Error1606" Overridable="yes"><!-- _locID_text="Error1606" _locComment="Error1606" -->Could not access network location [2].</String> <String Id="Error1607" Overridable="yes"><!-- _locID_text="Error1607" _locComment="Error1607" -->The following applications should be closed before continuing the install:</String> <String Id="Error1608" Overridable="yes"><!-- _locID_text="Error1608" _locComment="Error1608" -->Could not find any previously installed compliant products on the machine for installing this product.</String> <String Id="Error1609" Overridable="yes"><!-- _locID_text="Error1609" _locComment="Error1609" -->An error occurred while applying security settings. [2] is not a valid user or group. This could be a problem with the package, or a problem connecting to a domain controller on the network. Check your network connection and click Retry, or Cancel to end the install. {{Unable to locate the user's SID, system error [3]}}</String> <String Id="Error1701" Overridable="yes"><!-- _locID_text="Error1701" _locComment="Error1701" -->The key [2] is not valid. Verify that you entered the correct key.</String> <String Id="Error1702" Overridable="yes"><!-- _locID_text="Error1702" _locComment="Error1702" -->The installer must restart your system before configuration of [2] can continue. Click Yes to restart now or No if you plan to manually restart later.</String> <String Id="Error1703" Overridable="yes"><!-- _locID_text="Error1703" _locComment="Error1703" -->You must restart your system for the configuration changes made to [2] to take effect. Click Yes to restart now or No if you plan to manually restart later.</String> <String Id="Error1704" Overridable="yes"><!-- _locID_text="Error1704" _locComment="Error1704" -->An installation for [2] is currently suspended. You must undo the changes made by that installation to continue. Do you want to undo those changes?</String> <String Id="Error1705" Overridable="yes"><!-- _locID_text="Error1705" _locComment="Error1705" -->A previous installation for this product is in progress. You must undo the changes made by that installation to continue. Do you want to undo those changes?</String> <String Id="Error1706" Overridable="yes"><!-- _locID_text="Error1706" _locComment="Error1706" -->An installation package for the product [2] cannot be found. Try the installation again using a valid copy of the installation package '[3]'.</String> <String Id="Error1707" Overridable="yes"><!-- _locID_text="Error1707" _locComment="Error1707" -->Installation completed successfully.</String> <String Id="Error1708" Overridable="yes"><!-- _locID_text="Error1708" _locComment="Error1708" -->Installation failed.</String> <String Id="Error1709" Overridable="yes"><!-- _locID_text="Error1709" _locComment="Error1709" -->Product: [2] -- [3]</String> <String Id="Error1710" Overridable="yes"><!-- _locID_text="Error1710" _locComment="Error1710" -->You may either restore your computer to its previous state or continue the install later. Would you like to restore?</String> <String Id="Error1711" Overridable="yes"><!-- _locID_text="Error1711" _locComment="Error1711" -->An error occurred while writing installation information to disk. Check to make sure enough disk space is available, and click Retry, or Cancel to end the install.</String> <String Id="Error1712" Overridable="yes"><!-- _locID_text="Error1712" _locComment="Error1712" -->One or more of the files required to restore your computer to its previous state could not be found. Restoration will not be possible.</String> <String Id="Error1713" Overridable="yes"><!-- _locID_text="Error1713" _locComment="Error1713" -->[2] cannot install one of its required products. Contact your technical support group. {{System Error: [3].}}</String> <String Id="Error1714" Overridable="yes"><!-- _locID_text="Error1714" _locComment="Error1714" -->The older version of [2] cannot be removed. Contact your technical support group. {{System Error [3].}}</String> <String Id="Error1715" Overridable="yes"><!-- _locID_text="Error1715" _locComment="Error1715" -->Installed [2]</String> <String Id="Error1716" Overridable="yes"><!-- _locID_text="Error1716" _locComment="Error1716" -->Configured [2]</String> <String Id="Error1717" Overridable="yes"><!-- _locID_text="Error1717" _locComment="Error1717" -->Removed [2]</String> <String Id="Error1718" Overridable="yes"><!-- _locID_text="Error1718" _locComment="Error1718" -->File [2] was rejected by digital signature policy.</String> <String Id="Error1719" Overridable="yes"><!-- _locID_text="Error1719" _locComment="Error1719" -->The Windows Installer Service could not be accessed. This can occur if you are running Windows in safe mode, or if the Windows Installer is not correctly installed. Contact your support personnel for assistance.</String> <String Id="Error1720" Overridable="yes"><!-- _locID_text="Error1720" _locComment="Error1720" -->There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. {{Custom action [2] script error [3], [4]: [5] Line [6], Column [7], [8] }}</String> <String Id="Error1721" Overridable="yes"><!-- _locID_text="Error1721" _locComment="Error1721" -->There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. {{Action: [2], location: [3], command: [4] }}</String> <String Id="Error1722" Overridable="yes"><!-- _locID_text="Error1722" _locComment="Error1722" -->There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor. {{Action [2], location: [3], command: [4] }}</String> <String Id="Error1723" Overridable="yes"><!-- _locID_text="Error1723" _locComment="Error1723" -->There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support personnel or package vendor. {{Action [2], entry: [3], library: [4] }}</String> <String Id="Error1724" Overridable="yes"><!-- _locID_text="Error1724" _locComment="Error1724" -->Removal completed successfully.</String> <String Id="Error1725" Overridable="yes"><!-- _locID_text="Error1725" _locComment="Error1725" -->Removal failed.</String> <String Id="Error1726" Overridable="yes"><!-- _locID_text="Error1726" _locComment="Error1726" -->Advertisement completed successfully.</String> <String Id="Error1727" Overridable="yes"><!-- _locID_text="Error1727" _locComment="Error1727" -->Advertisement failed.</String> <String Id="Error1728" Overridable="yes"><!-- _locID_text="Error1728" _locComment="Error1728" -->Configuration completed successfully.</String> <String Id="Error1729" Overridable="yes"><!-- _locID_text="Error1729" _locComment="Error1729" -->Configuration failed.</String> <String Id="Error1730" Overridable="yes"><!-- _locID_text="Error1730" _locComment="Error1730" -->You must be an Administrator to remove this application. To remove this application, you can log on as an Administrator, or contact your technical support group for assistance.</String> <String Id="Error1731" Overridable="yes"><!-- _locID_text="Error1731" _locComment="Error1731" -->The source installation package for the product [2] is out of sync with the client package. Try the installation again using a valid copy of the installation package '[3]'.</String> <String Id="Error1732" Overridable="yes"><!-- _locID_text="Error1732" _locComment="Error1732" -->In order to complete the installation of [2], you must restart the computer. Other users are currently logged on to this computer, and restarting may cause them to lose their work. Do you want to restart now?</String> <String Id="Error1801" Overridable="yes"><!-- _locID_text="Error1801" _locComment="Error1801" -->The path [2] is not valid. Please specify a valid path.</String> <String Id="Error1802" Overridable="yes"><!-- _locID_text="Error1802" _locComment="Error1802" -->Out of memory. Shut down other applications before retrying.</String> <String Id="Error1803" Overridable="yes"><!-- _locID_text="Error1803" _locComment="Error1803" -->There is no disk in drive [2]. Please insert one and click Retry, or click Cancel to go back to the previously selected volume.</String> <String Id="Error1804" Overridable="yes"><!-- _locID_text="Error1804" _locComment="Error1804" -->There is no disk in drive [2]. Please insert one and click Retry, or click Cancel to return to the browse dialog and select a different volume.</String> <String Id="Error1805" Overridable="yes"><!-- _locID_text="Error1805" _locComment="Error1805" -->The folder [2] does not exist. Please enter a path to an existing folder.</String> <String Id="Error1806" Overridable="yes"><!-- _locID_text="Error1806" _locComment="Error1806" -->You have insufficient privileges to read this folder.</String> <String Id="Error1807" Overridable="yes"><!-- _locID_text="Error1807" _locComment="Error1807" -->A valid destination folder for the install could not be determined.</String> <String Id="Error1901" Overridable="yes"><!-- _locID_text="Error1901" _locComment="Error1901" -->Error attempting to read from the source install database: [2].</String> <String Id="Error1902" Overridable="yes"><!-- _locID_text="Error1902" _locComment="Error1902" -->Scheduling reboot operation: Renaming file [2] to [3]. Must reboot to complete operation.</String> <String Id="Error1903" Overridable="yes"><!-- _locID_text="Error1903" _locComment="Error1903" -->Scheduling reboot operation: Deleting file [2]. Must reboot to complete operation.</String> <String Id="Error1904" Overridable="yes"><!-- _locID_text="Error1904" _locComment="Error1904" -->Module [2] failed to register. HRESULT [3]. Contact your support personnel.</String> <String Id="Error1905" Overridable="yes"><!-- _locID_text="Error1905" _locComment="Error1905" -->Module [2] failed to unregister. HRESULT [3]. Contact your support personnel.</String> <String Id="Error1906" Overridable="yes"><!-- _locID_text="Error1906" _locComment="Error1906" -->Failed to cache package [2]. Error: [3]. Contact your support personnel.</String> <String Id="Error1907" Overridable="yes"><!-- _locID_text="Error1907" _locComment="Error1907" -->Could not register font [2]. Verify that you have sufficient permissions to install fonts, and that the system supports this font.</String> <String Id="Error1908" Overridable="yes"><!-- _locID_text="Error1908" _locComment="Error1908" -->Could not unregister font [2]. Verify that you that you have sufficient permissions to remove fonts.</String> <String Id="Error1909" Overridable="yes"><!-- _locID_text="Error1909" _locComment="Error1909" -->Could not create Shortcut [2]. Verify that the destination folder exists and that you can access it.</String> <String Id="Error1910" Overridable="yes"><!-- _locID_text="Error1910" _locComment="Error1910" -->Could not remove Shortcut [2]. Verify that the shortcut file exists and that you can access it.</String> <String Id="Error1911" Overridable="yes"><!-- _locID_text="Error1911" _locComment="Error1911" -->Could not register type library for file [2]. Contact your support personnel.</String> <String Id="Error1912" Overridable="yes"><!-- _locID_text="Error1912" _locComment="Error1912" -->Could not unregister type library for file [2]. Contact your support personnel.</String> <String Id="Error1913" Overridable="yes"><!-- _locID_text="Error1913" _locComment="Error1913" -->Could not update the ini file [2][3]. Verify that the file exists and that you can access it.</String> <String Id="Error1914" Overridable="yes"><!-- _locID_text="Error1914" _locComment="Error1914" -->Could not schedule file [2] to replace file [3] on reboot. Verify that you have write permissions to file [3].</String> <String Id="Error1915" Overridable="yes"><!-- _locID_text="Error1915" _locComment="Error1915" -->Error removing ODBC driver manager, ODBC error [2]: [3]. Contact your support personnel.</String> <String Id="Error1916" Overridable="yes"><!-- _locID_text="Error1916" _locComment="Error1916" -->Error installing ODBC driver manager, ODBC error [2]: [3]. Contact your support personnel.</String> <String Id="Error1917" Overridable="yes"><!-- _locID_text="Error1917" _locComment="Error1917" -->Error removing ODBC driver: [4], ODBC error [2]: [3]. Verify that you have sufficient privileges to remove ODBC drivers.</String> <String Id="Error1918" Overridable="yes"><!-- _locID_text="Error1918" _locComment="Error1918" -->Error installing ODBC driver: [4], ODBC error [2]: [3]. Verify that the file [4] exists and that you can access it.</String> <String Id="Error1919" Overridable="yes"><!-- _locID_text="Error1919" _locComment="Error1919" -->Error configuring ODBC data source: [4], ODBC error [2]: [3]. Verify that the file [4] exists and that you can access it.</String> <String Id="Error1920" Overridable="yes"><!-- _locID_text="Error1920" _locComment="Error1920" -->Service '[2]' ([3]) failed to start. Verify that you have sufficient privileges to start system services.</String> <String Id="Error1921" Overridable="yes"><!-- _locID_text="Error1921" _locComment="Error1921" -->Service '[2]' ([3]) could not be stopped. Verify that you have sufficient privileges to stop system services.</String> <String Id="Error1922" Overridable="yes"><!-- _locID_text="Error1922" _locComment="Error1922" -->Service '[2]' ([3]) could not be deleted. Verify that you have sufficient privileges to remove system services.</String> <String Id="Error1923" Overridable="yes"><!-- _locID_text="Error1923" _locComment="Error1923" -->Service '[2]' ([3]) could not be installed. Verify that you have sufficient privileges to install system services.</String> <String Id="Error1924" Overridable="yes"><!-- _locID_text="Error1924" _locComment="Error1924" -->Could not update environment variable '[2]'. Verify that you have sufficient privileges to modify environment variables.</String> <String Id="Error1925" Overridable="yes"><!-- _locID_text="Error1925" _locComment="Error1925" -->You do not have sufficient privileges to complete this installation for all users of the machine. Log on as administrator and then retry this installation.</String> <String Id="Error1926" Overridable="yes"><!-- _locID_text="Error1926" _locComment="Error1926" -->Could not set file security for file '[3]'. Error: [2]. Verify that you have sufficient privileges to modify the security permissions for this file.</String> <String Id="Error1927" Overridable="yes"><!-- _locID_text="Error1927" _locComment="Error1927" -->Component Services (COM+ 1.0) are not installed on this computer. This installation requires Component Services in order to complete successfully. Component Services are available on Windows 2000.</String> <String Id="Error1928" Overridable="yes"><!-- _locID_text="Error1928" _locComment="Error1928" -->Error registering COM+ Application. Contact your support personnel for more information.</String> <String Id="Error1929" Overridable="yes"><!-- _locID_text="Error1929" _locComment="Error1929" -->Error unregistering COM+ Application. Contact your support personnel for more information.</String> <String Id="Error1930" Overridable="yes"><!-- _locID_text="Error1930" _locComment="Error1930" -->The description for service '[2]' ([3]) could not be changed.</String> <String Id="Error1931" Overridable="yes"><!-- _locID_text="Error1931" _locComment="Error1931" -->The Windows Installer service cannot update the system file [2] because the file is protected by Windows. You may need to update your operating system for this program to work correctly. {{Package version: [3], OS Protected version: [4]}}</String> <String Id="Error1932" Overridable="yes"><!-- _locID_text="Error1932" _locComment="Error1932" -->The Windows Installer service cannot update the protected Windows file [2]. {{Package version: [3], OS Protected version: [4], SFP Error: [5]}}</String> <String Id="Error1933" Overridable="yes"><!-- _locID_text="Error1933" _locComment="Error1933" -->The Windows Installer service cannot update one or more protected Windows files. {{SFP Error: [2]. List of protected files:\r\n[3]}}</String> <String Id="Error1934" Overridable="yes"><!-- _locID_text="Error1934" _locComment="Error1934" -->User installations are disabled via policy on the machine.</String> <String Id="Error1935" Overridable="yes"><!-- _locID_text="Error1935" _locComment="Error1935" -->An error occurred during the installation of assembly '[6]'. Please refer to Help and Support for more information. HRESULT: [3]. {{assembly interface: [4], function: [5], component: [2]}}</String> <String Id="Error1936" Overridable="yes"><!-- _locID_text="Error1936" _locComment="Error1936" -->An error occurred during the installation of assembly '[6]'. The assembly is not strongly named or is not signed with the minimal key length. HRESULT: [3]. {{assembly interface: [4], function: [5], component: [2]}}</String> <String Id="Error1937" Overridable="yes"><!-- _locID_text="Error1937" _locComment="Error1937" -->An error occurred during the installation of assembly '[6]'. The signature or catalog could not be verified or is not valid. HRESULT: [3]. {{assembly interface: [4], function: [5], component: [2]}}</String> <String Id="Error1938" Overridable="yes"><!-- _locID_text="Error1938" _locComment="Error1938" -->An error occurred during the installation of assembly '[6]'. One or more modules of the assembly could not be found. HRESULT: [3]. {{assembly interface: [4], function: [5], component: [2]}}</String> <String Id="UITextbytes" Overridable="yes"><!-- _locID_text="UITextbytes" _locComment="UITextbytes" -->bytes</String> <String Id="UITextGB" Overridable="yes"><!-- _locID_text="UITextGB" _locComment="UITextGB" -->GB</String> <String Id="UITextKB" Overridable="yes"><!-- _locID_text="UITextKB" _locComment="UITextKB" -->KB</String> <String Id="UITextMB" Overridable="yes"><!-- _locID_text="UITextMB" _locComment="UITextMB" -->MB</String> <String Id="UITextMenuAbsent" Overridable="yes"><!-- _locID_text="UITextMenuAbsent" _locComment="UITextMenuAbsent" -->Entire feature will be unavailable</String> <String Id="UITextMenuAdvertise" Overridable="yes"><!-- _locID_text="UITextMenuAdvertise" _locComment="UITextMenuAdvertise" -->Feature will be installed when required</String> <String Id="UITextMenuAllCD" Overridable="yes"><!-- _locID_text="UITextMenuAllCD" _locComment="UITextMenuAllCD" -->Entire feature will be installed to run from CD</String> <String Id="UITextMenuAllLocal" Overridable="yes"><!-- _locID_text="UITextMenuAllLocal" _locComment="UITextMenuAllLocal" -->Entire feature will be installed on local hard drive</String> <String Id="UITextMenuAllNetwork" Overridable="yes"><!-- _locID_text="UITextMenuAllNetwork" _locComment="UITextMenuAllNetwork" -->Entire feature will be installed to run from network</String> <String Id="UITextMenuCD" Overridable="yes"><!-- _locID_text="UITextMenuCD" _locComment="UITextMenuCD" -->Will be installed to run from CD</String> <String Id="UITextMenuLocal" Overridable="yes"><!-- _locID_text="UITextMenuLocal" _locComment="UITextMenuLocal" -->Will be installed on local hard drive</String> <String Id="UITextMenuNetwork" Overridable="yes"><!-- _locID_text="UITextMenuNetwork" _locComment="UITextMenuNetwork" -->Will be installed to run from network</String> <String Id="UITextNewFolder" Overridable="yes"><!-- _locID_text="UITextNewFolder" _locComment="UITextNewFolder" -->Folder|New Folder</String> <String Id="UITextScriptInProgress" Overridable="yes"><!-- _locID_text="UITextScriptInProgress" _locComment="UITextScriptInProgress" -->Gathering required information...</String> <String Id="UITextSelAbsentAbsent" Overridable="yes"><!-- _locID_text="UITextSelAbsentAbsent" _locComment="UITextSelAbsentAbsent" -->This feature will remain uninstalled</String> <String Id="UITextSelAbsentAdvertise" Overridable="yes"><!-- _locID_text="UITextSelAbsentAdvertise" _locComment="UITextSelAbsentAdvertise" -->This feature will be set to be installed when required</String> <String Id="UITextSelAbsentCD" Overridable="yes"><!-- _locID_text="UITextSelAbsentCD" _locComment="UITextSelAbsentCD" -->This feature will be installed to run from CD</String> <String Id="UITextSelAbsentLocal" Overridable="yes"><!-- _locID_text="UITextSelAbsentLocal" _locComment="UITextSelAbsentLocal" -->This feature will be installed on the local hard drive</String> <String Id="UITextSelAbsentNetwork" Overridable="yes"><!-- _locID_text="UITextSelAbsentNetwork" _locComment="UITextSelAbsentNetwork" -->This feature will be installed to run from the network</String> <String Id="UITextSelAdvertiseAbsent" Overridable="yes"><!-- _locID_text="UITextSelAdvertiseAbsent" _locComment="UITextSelAdvertiseAbsent" -->This feature will become unavailable</String> <String Id="UITextSelAdvertiseAdvertise" Overridable="yes"><!-- _locID_text="UITextSelAdvertiseAdvertise" _locComment="UITextSelAdvertiseAdvertise" -->Will be installed when required</String> <String Id="UITextSelAdvertiseCD" Overridable="yes"><!-- _locID_text="UITextSelAdvertiseCD" _locComment="UITextSelAdvertiseCD" -->This feature will be available to run from CD</String> <String Id="UITextSelAdvertiseLocal" Overridable="yes"><!-- _locID_text="UITextSelAdvertiseLocal" _locComment="UITextSelAdvertiseLocal" -->This feature will be installed on your local hard drive</String> <String Id="UITextSelAdvertiseNetwork" Overridable="yes"><!-- _locID_text="UITextSelAdvertiseNetwork" _locComment="UITextSelAdvertiseNetwork" -->This feature will be available to run from the network</String> <String Id="UITextSelCDAbsent" Overridable="yes"><!-- _locID_text="UITextSelCDAbsent" _locComment="UITextSelCDAbsent" -->This feature will be uninstalled completely, you won't be able to run it from CD</String> <String Id="UITextSelCDAdvertise" Overridable="yes"><!-- _locID_text="UITextSelCDAdvertise" _locComment="UITextSelCDAdvertise" -->This feature will change from run from CD state to set to be installed when required</String> <String Id="UITextSelCDCD" Overridable="yes"><!-- _locID_text="UITextSelCDCD" _locComment="UITextSelCDCD" -->This feature will remain to be run from CD</String> <String Id="UITextSelCDLocal" Overridable="yes"><!-- _locID_text="UITextSelCDLocal" _locComment="UITextSelCDLocal" -->This feature will change from run from CD state to be installed on the local hard drive</String> <String Id="UITextSelChildCostNeg" Overridable="yes"><!-- _locID_text="UITextSelChildCostNeg" _locComment="UITextSelChildCostNeg" -->This feature frees up [1] on your hard drive.</String> <String Id="UITextSelChildCostPos" Overridable="yes"><!-- _locID_text="UITextSelChildCostPos" _locComment="UITextSelChildCostPos" -->This feature requires [1] on your hard drive.</String> <String Id="UITextSelCostPending" Overridable="yes"><!-- _locID_text="UITextSelCostPending" _locComment="UITextSelCostPending" -->Compiling cost for this feature...</String> <String Id="UITextSelLocalAbsent" Overridable="yes"><!-- _locID_text="UITextSelLocalAbsent" _locComment="UITextSelLocalAbsent" -->This feature will be completely removed</String> <String Id="UITextSelLocalAdvertise" Overridable="yes"><!-- _locID_text="UITextSelLocalAdvertise" _locComment="UITextSelLocalAdvertise" -->This feature will be removed from your local hard drive, but will be set to be installed when required</String> <String Id="UITextSelLocalCD" Overridable="yes"><!-- _locID_text="UITextSelLocalCD" _locComment="UITextSelLocalCD" -->This feature will be removed from your local hard drive, but will be still available to run from CD</String> <String Id="UITextSelLocalLocal" Overridable="yes"><!-- _locID_text="UITextSelLocalLocal" _locComment="UITextSelLocalLocal" -->This feature will remain on your local hard drive</String> <String Id="UITextSelLocalNetwork" Overridable="yes"><!-- _locID_text="UITextSelLocalNetwork" _locComment="UITextSelLocalNetwork" -->This feature will be removed from your local hard drive, but will be still available to run from the network</String> <String Id="UITextSelNetworkAbsent" Overridable="yes"><!-- _locID_text="UITextSelNetworkAbsent" _locComment="UITextSelNetworkAbsent" -->This feature will be uninstalled completely, you won't be able to run it from the network</String> <String Id="UITextSelNetworkAdvertise" Overridable="yes"><!-- _locID_text="UITextSelNetworkAdvertise" _locComment="UITextSelNetworkAdvertise" -->This feature will change from run from network state to set to be installed when required</String> <String Id="UITextSelNetworkLocal" Overridable="yes"><!-- _locID_text="UITextSelNetworkLocal" _locComment="UITextSelNetworkLocal" -->This feature will change from run from network state to be installed on the local hard drive</String> <String Id="UITextSelNetworkNetwork" Overridable="yes"><!-- _locID_text="UITextSelNetworkNetwork" _locComment="UITextSelNetworkNetwork" -->This feature will remain to be run from the network</String> <String Id="UITextSelParentCostNegNeg" Overridable="yes"><!-- _locID_text="UITextSelParentCostNegNeg" _locComment="UITextSelParentCostNegNeg" -->This feature frees up [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures free up [4] on your hard drive.</String> <String Id="UITextSelParentCostNegPos" Overridable="yes"><!-- _locID_text="UITextSelParentCostNegPos" _locComment="UITextSelParentCostNegPos" -->This feature frees up [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures require [4] on your hard drive.</String> <String Id="UITextSelParentCostPosNeg" Overridable="yes"><!-- _locID_text="UITextSelParentCostPosNeg" _locComment="UITextSelParentCostPosNeg" -->This feature requires [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures free up [4] on your hard drive.</String> <String Id="UITextSelParentCostPosPos" Overridable="yes"><!-- _locID_text="UITextSelParentCostPosPos" _locComment="UITextSelParentCostPosPos" -->This feature requires [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures require [4] on your hard drive.</String> <String Id="UITextTimeRemaining" Overridable="yes"><!-- _locID_text="UITextTimeRemaining" _locComment="UITextTimeRemaining" -->Time remaining: {[1] minutes }{[2] seconds}</String> <String Id="UITextVolumeCostAvailable" Overridable="yes"><!-- _locID_text="UITextVolumeCostAvailable" _locComment="UITextVolumeCostAvailable" -->Available</String> <String Id="UITextVolumeCostDifference" Overridable="yes"><!-- _locID_text="UITextVolumeCostDifference" _locComment="UITextVolumeCostDifference" -->Difference</String> <String Id="UITextVolumeCostRequired" Overridable="yes"><!-- _locID_text="UITextVolumeCostRequired" _locComment="UITextVolumeCostRequired" -->Required</String> <String Id="UITextVolumeCostSize" Overridable="yes"><!-- _locID_text="UITextVolumeCostSize" _locComment="UITextVolumeCostSize" -->Disk Size</String> <String Id="UITextVolumeCostVolume" Overridable="yes"><!-- _locID_text="UITextVolumeCostVolume" _locComment="UITextVolumeCostVolume" -->Volume</String> </WixLocalization> ```
/content/code_sandbox/Source/src/WixSharp.Samples/Wix# Samples/Managed Setup/CustomUI.Dialog/MyProduct.en-us.wxl
xml
2016-01-16T05:51:01
2024-08-16T12:26:25
wixsharp
oleg-shilo/wixsharp
1,077
28,984
```xml /* * Wire * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see path_to_url */ import {program as commander} from 'commander'; import path from 'path'; import {checkCommanderOptions, getLogger} from '../bin-utils'; import {S3Deployer} from './lib/S3Deployer'; const toolName = path.basename(__filename).replace(/\.[jt]s$/, ''); const logger = getLogger('deploy-tools', toolName); commander .name(toolName) .description('Upload files to S3') .option('-b, --bucket <id>', 'Specify the S3 bucket to upload to') .option('-d, --dry-run', 'Just log without actually uploading') .option('-i, --key-id <id>', 'Specify the AWS access key ID') .option('-k, --secret-key <id>', 'Specify the AWS secret access key ID') .option('-p, --path <path>', 'Specify the local path to search for files (e.g. "../../wrap")') .option('-s, --s3path <path>', 'Specify the base path on S3 (e.g. "apps/windows")') .option('-w, --wrapper-build <build>', 'Specify the wrapper build (e.g. "Linux#3.7.1234")') .parse(process.argv); const commanderOptions = commander.opts(); checkCommanderOptions(commanderOptions, logger, ['bucket', 'keyId', 'secretKey', 'wrapperBuild']); if (!commanderOptions.wrapperBuild.includes('#')) { logger.error(`Invalid wrapper build id "${commanderOptions.wrapperBuild}"`); commander.outputHelp(); process.exit(1); } (async () => { const searchBasePath = commanderOptions.path || path.join(__dirname, '../../wrap'); const s3BasePath = `${commanderOptions.s3path || ''}/`; const [platform, version] = commanderOptions.wrapperBuild.toLowerCase().split('#'); const {bucket, secretKey: secretAccessKey, keyId: accessKeyId} = commanderOptions; const s3Deployer = new S3Deployer({accessKeyId, dryRun: commanderOptions.dryRun || false, secretAccessKey}); const files = await s3Deployer.findUploadFiles(platform, searchBasePath, version); for (let index = 0; index < files.length; index++) { const file = files[index]; const {fileName, filePath} = file; const s3Path = `${s3BasePath}${fileName}`.replace('//', '/'); await s3Deployer.uploadToS3({ bucket, filePath, s3Path, }); } logger.log('Done uploading to AWS S3 bucket.'); })().catch(error => { logger.error(error); process.exit(1); }); ```
/content/code_sandbox/bin/deploy-tools/s3-cli.ts
xml
2016-07-26T13:55:48
2024-08-16T03:45:51
wire-desktop
wireapp/wire-desktop
1,075
666
```xml <vector xmlns:android="path_to_url" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> <path android:fillColor="#FFF" android:pathData="M16.05,8.696a0.598,0.588 90,0 0,0 0.825,0.553 0.544,90 0,0 0.788,0 2.388,2.352 90,0 0,-0.002 -3.301,0.553 0.544,90 0,0 -0.787,0 0.598,0.588 90,0 0,0 0.825c0.435,0.456 0.436,1.195 0.001,1.651m2.36,-4.128a0.553,0.544 90,0 0,-0.788 0,0.598 0.588,90 0,0 0.001,0.826 3.583,3.527 90,0 1,0.002 4.952,0.598 0.588,90 0,0 0,0.826 0.553,0.544 90,0 0,0.788 0c1.737,-1.825 1.736,-4.781 -0.004,-6.604zM14.262,6.803c0.562,0 1.019,0.478 1.019,1.067 0,0.589 -0.457,1.067 -1.019,1.067 -0.561,0 -1.016,-0.478 -1.016,-1.067 0,-0.589 0.455,-1.067 1.016,-1.067m-0.762,-4.802c0.701,0 1.271,0.598 1.271,1.334l0,2.401l-1.017,0L13.754,3.601L9.175,3.601l0,8.004l4.579,0l0,-1.601l1.016,0l0,2.401c0,0.736 -0.569,1.334 -1.271,1.334l-4.07,0c-0.704,0 -1.273,-0.598 -1.273,-1.334L8.156,3.334c0.001,-0.736 0.57,-1.334 1.271,-1.334z" /> <path android:fillColor="#FFF" android:pathData="M1.4,21.914l0,-6.16l1.244,0l0,2.424L5.081,18.179l0,-2.424l1.244,0l0,6.16L5.081,21.914l0,-2.693L2.644,19.221l0,2.693zM8.997,21.914l0,-5.118L7.169,16.796l0,-1.042l4.895,0l0,1.042l-1.823,0l0,5.118zM14.253,21.914l0,-5.118l-1.828,0l0,-1.042l4.895,0l0,1.042l-1.823,0l0,5.118zM18.123,21.914l0,-6.16l1.996,0q1.134,0 1.479,0.092 0.529,0.139 0.887,0.605 0.357,0.462 0.357,1.197 0,0.567 -0.206,0.954 -0.206,0.387 -0.525,0.609 -0.315,0.218 -0.643,0.29 -0.445,0.088 -1.29,0.088l-0.811,0l0,2.323zM19.366,16.796l0,1.748l0.681,0q0.735,0 0.983,-0.097 0.248,-0.097 0.387,-0.302 0.143,-0.206 0.143,-0.479 0,-0.336 -0.197,-0.555 -0.198,-0.219 -0.5,-0.273 -0.223,-0.042 -0.895,-0.042z" /> </vector> ```
/content/code_sandbox/app/src/main/res/drawable/ic_tile_24dp.xml
xml
2016-07-18T08:07:33
2024-08-14T13:46:53
ScreenStream
dkrivoruchko/ScreenStream
1,630
1,063
```xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="path_to_url" xmlns:xsi="path_to_url" xsi:schemaLocation="path_to_url path_to_url"> <modelVersion>4.0.0</modelVersion> <name>Flowable - CMMN Cdi</name> <artifactId>flowable-cmmn-cdi</artifactId> <packaging>jar</packaging> <parent> <groupId>org.flowable</groupId> <artifactId>flowable-root</artifactId> <relativePath>../..</relativePath> <version>7.1.0-SNAPSHOT</version> </parent> <dependencies> <dependency> <groupId>org.flowable</groupId> <artifactId>flowable-cmmn-engine</artifactId> </dependency> <dependency> <groupId>jakarta.enterprise</groupId> <artifactId>jakarta.enterprise.cdi-api</artifactId> <scope>provided</scope> </dependency> </dependencies> </project> ```
/content/code_sandbox/modules/flowable-cmmn-cdi/pom.xml
xml
2016-10-13T07:21:43
2024-08-16T15:23:14
flowable-engine
flowable/flowable-engine
7,715
253
```xml /** * @license * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at path_to_url */ import {ChangeDetectionStrategy, Component, Input, ViewEncapsulation} from '@angular/core'; /** Quality of the placeholder image. */ export type PlaceholderImageQuality = 'high' | 'standard' | 'low'; @Component({ selector: 'youtube-player-placeholder', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: ` <button type="button" class="youtube-player-placeholder-button" [attr.aria-label]="buttonLabel"> <svg height="100%" version="1.1" viewBox="0 0 68 48" focusable="false" aria-hidden="true"> <path d="M66.52,7.74c-0.78-2.93-2.49-5.41-5.42-6.19C55.79,.13,34,0,34,0S12.21,.13,6.9,1.55 C3.97,2.33,2.27,4.81,1.48,7.74C0.06,13.05,0,24,0,24s0.06,10.95,1.48,16.26c0.78,2.93,2.49,5.41,5.42,6.19 C12.21,47.87,34,48,34,48s21.79-0.13,27.1-1.55c2.93-0.78,4.64-3.26,5.42-6.19C67.94,34.95,68,24,68,24S67.94,13.05,66.52,7.74z" fill="#f00"></path> <path d="M 45,24 27,14 27,34" fill="#fff"></path> </svg> </button> `, standalone: true, styleUrl: 'youtube-player-placeholder.css', host: { 'class': 'youtube-player-placeholder', '[class.youtube-player-placeholder-loading]': 'isLoading', '[style.background-image]': '_getBackgroundImage()', '[style.width.px]': 'width', '[style.height.px]': 'height', }, }) export class YouTubePlayerPlaceholder { /** ID of the video for which to show the placeholder. */ @Input() videoId: string; /** Width of the video for which to show the placeholder. */ @Input() width: number; /** Height of the video for which to show the placeholder. */ @Input() height: number; /** Whether the video is currently being loaded. */ @Input() isLoading: boolean; /** Accessible label for the play button. */ @Input() buttonLabel: string; /** Quality of the placeholder image. */ @Input() quality: PlaceholderImageQuality; /** Gets the background image showing the placeholder. */ protected _getBackgroundImage(): string | undefined { let url: string; if (this.quality === 'low') { url = `path_to_url{this.videoId}/hqdefault.jpg`; } else if (this.quality === 'high') { url = `path_to_url{this.videoId}/maxresdefault.jpg`; } else { url = `path_to_url{this.videoId}/sddefault.webp`; } return `url(${url})`; } } ```
/content/code_sandbox/src/youtube-player/youtube-player-placeholder.ts
xml
2016-01-04T18:50:02
2024-08-16T11:21:13
components
angular/components
24,263
779
```xml /* * Planck.js * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import type { MassData } from '../dynamics/Body'; import { RayCastOutput, RayCastInput, AABBValue } from './AABB'; import { DistanceProxy } from './Distance'; import type { Transform, TransformValue } from '../common/Transform'; import type { Vec2Value } from '../common/Vec2'; import { Style } from '../util/Testbed'; // todo make shape an interface /** * A shape is used for collision detection. You can create a shape however you * like. Shapes used for simulation in World are created automatically when a * Fixture is created. Shapes may encapsulate one or more child shapes. */ export abstract class Shape { /** @hidden */ m_type: ShapeType; /** * @hidden * Radius of a shape. For polygonal shapes this must be b2_polygonRadius. * There is no support for making rounded polygons. */ m_radius: number; /** Styling for dev-tools. */ style: Style = {}; /** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */ appData: Record<string, any> = {}; /** @hidden */ abstract _reset(): void; static isValid(obj: any): boolean { if (obj === null || typeof obj === 'undefined') { return false; } return typeof obj.m_type === 'string' && typeof obj.m_radius === 'number'; } abstract getRadius(): number; /** * Get the type of this shape. You can use this to down cast to the concrete * shape. * * @return the shape type. */ abstract getType(): ShapeType; /** * @internal @deprecated Shapes should be treated as immutable. * * clone the concrete shape. */ abstract _clone(): Shape; /** * Get the number of child primitives. */ abstract getChildCount(): number; /** * Test a point for containment in this shape. This only works for convex * shapes. * * @param xf The shape world transform. * @param p A point in world coordinates. */ abstract testPoint(xf: TransformValue, p: Vec2Value): boolean; /** * Cast a ray against a child shape. * * @param output The ray-cast results. * @param input The ray-cast input parameters. * @param xf The transform to be applied to the shape. * @param childIndex The child shape index */ abstract rayCast(output: RayCastOutput, input: RayCastInput, xf: Transform, childIndex: number): boolean; /** * Given a transform, compute the associated axis aligned bounding box for a * child shape. * * @param aabb Returns the axis aligned box. * @param xf The world transform of the shape. * @param childIndex The child shape */ abstract computeAABB(aabb: AABBValue, xf: TransformValue, childIndex: number): void; /** * Compute the mass properties of this shape using its dimensions and density. * The inertia tensor is computed about the local origin. * * @param massData Returns the mass data for this shape. * @param density The density in kilograms per meter squared. */ abstract computeMass(massData: MassData, density?: number): void; abstract computeDistanceProxy(proxy: DistanceProxy, childIndex: number): void; } export type ShapeType = "circle" | "edge" | "polygon" | "chain"; ```
/content/code_sandbox/src/collision/Shape.ts
xml
2016-03-22T04:46:05
2024-08-16T07:41:00
planck.js
piqnt/planck.js
4,864
994
```xml import CheckoutMain from "@/modules/checkout/main" import ProductsContainer from "@/modules/products/productsContainer" import BarcodeListener from "@/components/barcodeListener" import Header from "@/components/header/header.main" const MainIndexPage = () => { return ( <BarcodeListener> <Header /> <section className="flex flex-auto items-stretch overflow-hidden"> <div className="flex h-full w-2/3 flex-col p-4 pr-0"> <ProductsContainer /> </div> <div className="flex w-1/3 flex-col border-l"> <CheckoutMain /> </div> </section> </BarcodeListener> ) } export default MainIndexPage ```
/content/code_sandbox/pos/app/(main)/main.tsx
xml
2016-11-11T06:54:50
2024-08-16T10:26:06
erxes
erxes/erxes
3,479
148
```xml <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="path_to_url"> <item> <rotate android:drawable="@drawable/sample_footer_loading" android:duration="500" android:fromDegrees="0.0" android:pivotX="50.0%" android:pivotY="50.0%" android:toDegrees="360.0" /> </item> </layer-list> ```
/content/code_sandbox/RxUI/src/main/res/drawable/sample_footer_loading_progress.xml
xml
2016-09-24T09:30:45
2024-08-16T09:54:41
RxTool
Tamsiree/RxTool
12,242
100
```xml import { noop } from "lodash"; import React, { Component, ReactElement, ReactNode } from "react"; import { css, DefaultButton, PrimaryButton, IconButton, MessageBar, MessageBarType, Spinner, SpinnerSize, Stack, StackItem } from "@fluentui/react"; import { CircleRingIcon, CompletedSolidIcon, RadioBtnOnIcon } from "@fluentui/react-icons-mdl2"; import { IWizardStrings } from "../Localization"; import * as cstrings from "CommonStrings"; import styles from "./styles/Wizard.module.scss"; export type WizardData = {}; export interface IButtonRenderProps<D extends WizardData> { defaultBackButton: ReactNode; defaultNextButton: ReactNode; disabled: boolean; isFowardOnly: boolean; isFirstStep: boolean; isLastStep: boolean; wizardStrings: IWizardStrings; data: D; onBack: () => void; onNext: () => void; } export interface IWizardPageMetadata<D extends WizardData> { title?: string; forwardOnly?: boolean; onRenderButtons?: (props: IButtonRenderProps<D>) => ReactNode; } export interface IWizardPageProps<D extends WizardData> { data: D; onClickEdit?: (pageIndex: number) => void; children?: React.ReactNode; } export interface IWizardStepProps<D extends WizardData> extends IWizardPageProps<D> { stepNumber?: number; totalStepCount?: number; validateFn: (fn: () => boolean) => void; deactivateFn: (fn: () => Promise<any>) => void; } export type PageRenderer<D extends WizardData, P extends IWizardPageProps<D> = IWizardPageProps<D>> = React.FC<P>; export type StepRenderer<D extends WizardData, P extends IWizardStepProps<D> = IWizardStepProps<D>> = PageRenderer<D, P> & IWizardPageMetadata<D>; export interface IWizardProps<D extends WizardData> { data: D; headingLabel?: string; heading?: ReactElement; className?: string; panel?: boolean; strings?: Partial<IWizardStrings>; startPage?: PageRenderer<D>; stepPages: StepRenderer<D>[]; successPage?: PageRenderer<D>; successPageTimeout?: number; execute?: (config: D) => Promise<void>; initialize?: () => Promise<void>; onWizardComplete?: () => void; onDiscard?: () => void; } export interface IWizardState { currentPageIndex: number; error: any; } abstract class WizardPage<D extends WizardData, P extends IWizardPageProps<D> = IWizardPageProps<D>> { constructor( private readonly _renderer: PageRenderer<D, P>, protected readonly wizardStrings: IWizardStrings ) { } public async activate(): Promise<void> { } public valid(): boolean { return true; } public async deactivate(): Promise<void> { } public get autoContinue(): boolean { return false; } public renderPage(props: P): React.ReactNode { const Page = this._renderer; return <Page {...props} />; } public renderFooterButtons(props: IWizardPageProps<D>, disabled: boolean): ReactNode { return <></>; } } class WizardStartPage<D extends WizardData> extends WizardPage<D> { constructor( renderer: PageRenderer<D>, wizardStrings: IWizardStrings, private readonly _onClickStart: () => void ) { super(renderer, wizardStrings); } public renderFooterButtons(props: IWizardPageProps<D>, disabled: boolean): ReactNode { return <> <PrimaryButton text={this.wizardStrings.StartButton.Text} disabled={disabled} onClick={this._onClickStart} /> </>; } } class WizardStepPage<D extends WizardData> extends WizardPage<D, IWizardStepProps<D>> { private _validateFn: () => boolean; private _deactivateFn: () => Promise<any>; constructor( public readonly renderer: StepRenderer<D>, wizardStrings: IWizardStrings, private readonly _stepNumber: number, private readonly _totalStepCount: number, private readonly _onClickBack: () => void, private readonly _onClickNext: () => void ) { super(renderer, wizardStrings); } public valid(): boolean { return this._validateFn ? this._validateFn() : true; } public async deactivate(): Promise<void> { if (this._deactivateFn) await this._deactivateFn(); } protected get isStep(): boolean { return !!this._stepNumber; } protected get isFirstStep(): boolean { return this._stepNumber === 1; } protected get isLastStep(): boolean { return this._stepNumber === this._totalStepCount; } public renderPage(props: IWizardStepProps<D>): React.ReactNode { if (this.isStep) { props.stepNumber = this._stepNumber; props.totalStepCount = this._totalStepCount; } return super.renderPage({ ...props, validateFn: fn => this._validateFn = fn, deactivateFn: fn => this._deactivateFn = fn }); } public renderFooterButtons(props: IWizardPageProps<D>, disabled: boolean): ReactNode { const { BackButton, NextButton, FinishButton } = this.wizardStrings; const backButtonText = BackButton.Text; const nextButtonText = this.isLastStep ? FinishButton.Text : NextButton.Text; const isFowardOnly = !!this.renderer.forwardOnly; let defaultBackButton: ReactNode; let defaultNextButton: ReactNode; if (this.isFirstStep || isFowardOnly) { defaultBackButton = <></>; defaultNextButton = <PrimaryButton text={nextButtonText} disabled={disabled} onClick={this._onClickNext} />; } else { defaultBackButton = <DefaultButton text={backButtonText} disabled={this.isFirstStep || disabled} onClick={this._onClickBack} />; defaultNextButton = <PrimaryButton text={nextButtonText} disabled={disabled} onClick={this._onClickNext} />; } const renderProps: IButtonRenderProps<D> = { data: props.data, defaultBackButton, defaultNextButton, disabled, isFowardOnly, isFirstStep: this.isFirstStep, isLastStep: this.isLastStep, wizardStrings: this.wizardStrings, onBack: this._onClickBack, onNext: this._onClickNext }; const { onRenderButtons } = this.renderer; return onRenderButtons ? onRenderButtons(renderProps) : this._defaultRenderFooterButtons(renderProps); } private _defaultRenderFooterButtons(props: IButtonRenderProps<D>): ReactNode { const { defaultBackButton, defaultNextButton } = props; return <> {defaultBackButton} {defaultNextButton} </>; } } class WizardInitializePage<D extends WizardData> extends WizardPage<D> { constructor( wizardStrings: IWizardStrings, private readonly _initialize: () => Promise<void> ) { super(null, wizardStrings); } public async activate() { await this._initialize(); } public get autoContinue(): boolean { return true; } public renderPage(props: IWizardPageProps<D>): React.ReactNode { return <Spinner size={SpinnerSize.large} label={cstrings.OneMoment} />; } } class WizardExecutePage<D extends WizardData> extends WizardPage<D> { constructor( wizardStrings: IWizardStrings, private readonly _execute: () => Promise<void> ) { super(null, wizardStrings); } public async activate() { await this._execute(); } public get autoContinue(): boolean { return true; } public renderPage(props: IWizardPageProps<D>): React.ReactNode { return <Spinner style={{ marginTop: 20 }} size={SpinnerSize.large} label={cstrings.OneMoment} />; } } class WizardSuccessPage<D extends WizardData> extends WizardPage<D> { constructor( step: PageRenderer<D>, wizardStrings: IWizardStrings, private readonly _timeout: number, private readonly _onWizardComplete: () => void ) { super(step, wizardStrings); } public async activate() { setTimeout(this._onWizardComplete, this._timeout); } } export class Wizard<D extends WizardData> extends Component<IWizardProps<D>, IWizardState> { private static readonly defaultProps: Partial<IWizardProps<any>> = { successPageTimeout: 2500, onWizardComplete: noop }; private readonly _pages: WizardPage<D>[]; constructor(props: IWizardProps<D>) { super(props); const wizardStrings = { ...cstrings.Wizard, ...props.strings }; this._pages = this._buildPages(props, wizardStrings); this.state = { currentPageIndex: -1, error: null }; } public componentDidMount() { this._nextPage(); } private readonly _goToPage = async (pageIndex: number) => { const currentPageIndex = this.state.currentPageIndex; const currentPage = this._pages[currentPageIndex]; const isValid = currentPage ? currentPage.valid() : true; if (isValid && pageIndex < this._pages.length) { if (currentPage) { await currentPage.deactivate(); } const newPage = this._pages[pageIndex]; this.setState({ currentPageIndex: pageIndex }); try { await newPage.activate(); } catch (e) { console.error(e); this.setState({ error: e }); } } } private readonly _buildPages = (props: IWizardProps<D>, wizardStrings: IWizardStrings): WizardPage<D>[] => { const pages: WizardPage<D>[] = []; if (props.startPage) { const page = new WizardStartPage(props.startPage, wizardStrings, this._nextPage); pages.push(page); } if (props.initialize) { const page = new WizardInitializePage<D>(wizardStrings, props.initialize); pages.push(page); } props.stepPages.forEach((step, index, steps) => { const page = new WizardStepPage(step, wizardStrings, index + 1, steps.length, this._previousPage, this._nextPage); pages.push(page); }); if (props.execute) { const page = new WizardExecutePage<D>(wizardStrings, () => props.execute(props.data)); pages.push(page); } if (props.successPage) { const page = new WizardSuccessPage(props.successPage, wizardStrings, props.successPageTimeout, props.onWizardComplete); pages.push(page); } return pages; } private readonly _previousPage = () => { const currentPageIndex = this.state.currentPageIndex; const newPageIndex = currentPageIndex - 1; const currentPage = this._pages[currentPageIndex]; const isValid = currentPage ? currentPage.valid() : true; if (isValid) { if (newPageIndex >= 0) { this._pages[currentPageIndex].deactivate(); this._pages[newPageIndex].activate(); this.setState({ currentPageIndex: newPageIndex }); } } } private readonly _nextPage = async () => { const currentPageIndex = this.state.currentPageIndex; const newPageIndex = currentPageIndex + 1; const isLastPage = currentPageIndex === this._pages.length - 1; const currentPage = this._pages[currentPageIndex]; const isValid = currentPage ? currentPage.valid() : true; if (isValid) { if (currentPage) { await currentPage.deactivate(); } if (isLastPage) { this.props.onWizardComplete(); } else { const newPage = this._pages[newPageIndex]; this.setState({ currentPageIndex: newPageIndex }); try { await newPage.activate(); } catch (e) { console.error(e); this.setState({ error: e }); } if (newPage.autoContinue) { this._nextPage(); } } } } private readonly _renderProgressBar = () => { const { onDiscard } = this.props; const { currentPageIndex } = this.state; const stepPages = this._pages.filter(page => page instanceof WizardStepPage).map(page => page as WizardStepPage<D>); if (this._pages[currentPageIndex] instanceof WizardStartPage || stepPages.length === 0) return; return ( <Stack className={styles.progressBar} horizontal horizontalAlign='space-evenly'> {stepPages.map((page, idx) => { const PageIcon = idx < currentPageIndex ? CompletedSolidIcon : (idx === currentPageIndex ? RadioBtnOnIcon : CircleRingIcon); const className = css(styles.statusIndicator, { [styles.futurePage]: idx > currentPageIndex }); return ( <StackItem key={idx} grow> <PageIcon className={className} /> <div>{page.renderer.title}</div> </StackItem> ); })} {onDiscard && <StackItem> <IconButton ariaLabel={cstrings.Wizard.CloseButtonAriaLabel} iconProps={{ iconName: 'Cancel' }} onClick={onDiscard} /> </StackItem>} </Stack> ); } public render(): React.ReactElement<IWizardProps<D>> { const { data, className, headingLabel, heading } = this.props; const { currentPageIndex, error } = this.state; const currentPage = this._pages[currentPageIndex]; const pageProps: IWizardPageProps<D> = { data, onClickEdit: this._goToPage }; return ( <div className={css(styles.wizard, className)}> <div className={styles.header}> {heading || (headingLabel && <h1>{headingLabel}</h1>)} </div> {this._renderProgressBar()} {!error ? currentPage?.renderPage(pageProps) : <MessageBar messageBarType={MessageBarType.error}>{cstrings.GenericError}</MessageBar> } <Stack horizontal horizontalAlign="center" wrap className={styles.footer} tokens={{ childrenGap: 10 }}> {currentPage?.renderFooterButtons(pageProps, !!error)} </Stack> </div> ); } } ```
/content/code_sandbox/samples/react-rhythm-of-business-calendar/src/common/components/Wizard.tsx
xml
2016-08-30T17:21:43
2024-08-16T18:41:32
sp-dev-fx-webparts
pnp/sp-dev-fx-webparts
2,027
3,119
```xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url"> <plist version="1.0"> <dict> <key>CFBundleDevelopmentRegion</key> <string>English</string> <key>CFBundleExecutable</key> <string>AppleACPIPS2Nub</string> <key>CFBundleIdentifier</key> <string>com.yourcompany.driver.AppleACPIPS2Nub</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> <string>AppleACPIPS2Nub</string> <key>CFBundlePackageType</key> <string>KEXT</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> <string>1.0.0d1</string> <key>IOKitPersonalities</key> <dict> <key>ACPI PS/2 Nub</key> <dict> <key>CFBundleIdentifier</key> <string>com.yourcompany.driver.AppleACPIPS2Nub</string> <key>IOClass</key> <string>AppleACPIPS2Nub</string> <key>IONameMatch</key> <array> <string>PNP0303</string> <string>PNP030B</string> </array> <key>IOProviderClass</key> <string>IOACPIPlatformDevice</string> <key>MouseNameMatch</key> <array> <string>PNP0F03</string> <string>PNP0F0B</string> <string>PNP0F0E</string> <string>PNP0F13</string> </array> </dict> </dict> <key>OSBundleLibraries</key> <dict> <key>com.apple.iokit.IOACPIFamily</key> <string>1.0.0d1</string> <key>com.apple.kpi.bsd</key> <string>8.0.0</string> <key>com.apple.kpi.iokit</key> <string>8.0.0</string> <key>com.apple.kpi.libkern</key> <string>8.0.0</string> <key>com.apple.kpi.mach</key> <string>8.0.0</string> <key>com.apple.kpi.unsupported</key> <string>8.0.0</string> </dict> <key>OSBundleRequired</key> <string>Root</string> </dict> </plist> ```
/content/code_sandbox/Clover-Configs/Acer/E5-572G/CLOVER/kexts/10.10/AppleACPIPS2Nub.kext/Contents/Info.plist
xml
2016-11-05T04:22:54
2024-08-12T19:25:53
Hackintosh-Installer-University
huangyz0918/Hackintosh-Installer-University
3,937
659
```xml import { expect, galata, test } from '@jupyterlab/galata'; import * as path from 'path'; const fileName = 'simple_notebook.ipynb'; test.describe('Cells', () => { test.beforeEach(async ({ page, request, tmpPath }) => { const contents = galata.newContentsHelper(request); await contents.uploadFile( path.resolve(__dirname, `./notebooks/${fileName}`), `${tmpPath}/${fileName}` ); await contents.uploadFile( path.resolve(__dirname, './notebooks/WidgetArch.png'), `${tmpPath}/WidgetArch.png` ); await page.notebook.openByPath(`${tmpPath}/${fileName}`); await page.notebook.activate(fileName); }); test('should collapse a cell', async ({ page }) => { await page.notebook.run(); await page.locator('.jp-Cell-inputCollapser').nth(2).click(); expect(await page.locator('.jp-Cell').nth(2).screenshot()).toMatchSnapshot( 'collapsed-cell.png' ); }); }); test.describe('Run Cells With Keyboard', () => { test.beforeEach(async ({ page }) => { await page.notebook.createNew(); }); test('Run code cell with Ctrl + Enter', async ({ page }) => { await page.notebook.setCell(0, 'code', '2**32'); await page.notebook.enterCellEditingMode(0); const initialOutput = await page.notebook.getCellTextOutput(0); expect(initialOutput).toBe(null); await page.keyboard.press('Control+Enter'); // Confirm that the cell has be executed by checking output const output = await page.notebook.getCellTextOutput(0); expect(output).toEqual(['4294967296']); // Expect the input to NOT include an extra line; const text = await page.notebook.getCellTextInput(0); expect(text).toBe('2**32'); }); }); ```
/content/code_sandbox/galata/test/jupyterlab/cells.test.ts
xml
2016-06-03T20:09:17
2024-08-16T19:12:44
jupyterlab
jupyterlab/jupyterlab
14,019
415
```xml <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net8.0</TargetFramework> <AssemblyName>PowerShellTests</AssemblyName> <PackageId>PowerShellTests</PackageId> </PropertyGroup> <ItemGroup> <ProjectReference Include="..\..\src\Amazon.Lambda.PowerShellHost\Amazon.Lambda.PowerShellHost.csproj" /> <ProjectReference Include="..\TestPowerShellFunctions\PowerShellScriptsAsFunctions\PowerShellScriptsAsFunctions.csproj" /> </ItemGroup> <ItemGroup> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference> <PackageReference Include="xunit" Version="2.4.5" /> </ItemGroup> </Project> ```
/content/code_sandbox/Libraries/test/PowerShellTests/PowerShellTests.csproj
xml
2016-11-11T20:43:34
2024-08-15T16:57:53
aws-lambda-dotnet
aws/aws-lambda-dotnet
1,558
230
```xml <?xml version="1.0" encoding="utf-8"?> <xsd:schema xmlns:xsd="path_to_url" xmlns="urn:schemas-microsoft-com:office:excel" xmlns:s="path_to_url" targetNamespace="urn:schemas-microsoft-com:office:excel" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xsd:import namespace="path_to_url" schemaLocation="shared-commonSimpleTypes.xsd"/> <xsd:element name="ClientData" type="CT_ClientData"/> <xsd:complexType name="CT_ClientData"> <xsd:choice minOccurs="0" maxOccurs="unbounded"> <xsd:element name="MoveWithCells" type="s:ST_TrueFalseBlank"/> <xsd:element name="SizeWithCells" type="s:ST_TrueFalseBlank"/> <xsd:element name="Anchor" type="xsd:string"/> <xsd:element name="Locked" type="s:ST_TrueFalseBlank"/> <xsd:element name="DefaultSize" type="s:ST_TrueFalseBlank"/> <xsd:element name="PrintObject" type="s:ST_TrueFalseBlank"/> <xsd:element name="Disabled" type="s:ST_TrueFalseBlank"/> <xsd:element name="AutoFill" type="s:ST_TrueFalseBlank"/> <xsd:element name="AutoLine" type="s:ST_TrueFalseBlank"/> <xsd:element name="AutoPict" type="s:ST_TrueFalseBlank"/> <xsd:element name="FmlaMacro" type="xsd:string"/> <xsd:element name="TextHAlign" type="xsd:string"/> <xsd:element name="TextVAlign" type="xsd:string"/> <xsd:element name="LockText" type="s:ST_TrueFalseBlank"/> <xsd:element name="JustLastX" type="s:ST_TrueFalseBlank"/> <xsd:element name="SecretEdit" type="s:ST_TrueFalseBlank"/> <xsd:element name="Default" type="s:ST_TrueFalseBlank"/> <xsd:element name="Help" type="s:ST_TrueFalseBlank"/> <xsd:element name="Cancel" type="s:ST_TrueFalseBlank"/> <xsd:element name="Dismiss" type="s:ST_TrueFalseBlank"/> <xsd:element name="Accel" type="xsd:integer"/> <xsd:element name="Accel2" type="xsd:integer"/> <xsd:element name="Row" type="xsd:integer"/> <xsd:element name="Column" type="xsd:integer"/> <xsd:element name="Visible" type="s:ST_TrueFalseBlank"/> <xsd:element name="RowHidden" type="s:ST_TrueFalseBlank"/> <xsd:element name="ColHidden" type="s:ST_TrueFalseBlank"/> <xsd:element name="VTEdit" type="xsd:integer"/> <xsd:element name="MultiLine" type="s:ST_TrueFalseBlank"/> <xsd:element name="VScroll" type="s:ST_TrueFalseBlank"/> <xsd:element name="ValidIds" type="s:ST_TrueFalseBlank"/> <xsd:element name="FmlaRange" type="xsd:string"/> <xsd:element name="WidthMin" type="xsd:integer"/> <xsd:element name="Sel" type="xsd:integer"/> <xsd:element name="NoThreeD2" type="s:ST_TrueFalseBlank"/> <xsd:element name="SelType" type="xsd:string"/> <xsd:element name="MultiSel" type="xsd:string"/> <xsd:element name="LCT" type="xsd:string"/> <xsd:element name="ListItem" type="xsd:string"/> <xsd:element name="DropStyle" type="xsd:string"/> <xsd:element name="Colored" type="s:ST_TrueFalseBlank"/> <xsd:element name="DropLines" type="xsd:integer"/> <xsd:element name="Checked" type="xsd:integer"/> <xsd:element name="FmlaLink" type="xsd:string"/> <xsd:element name="FmlaPict" type="xsd:string"/> <xsd:element name="NoThreeD" type="s:ST_TrueFalseBlank"/> <xsd:element name="FirstButton" type="s:ST_TrueFalseBlank"/> <xsd:element name="FmlaGroup" type="xsd:string"/> <xsd:element name="Val" type="xsd:integer"/> <xsd:element name="Min" type="xsd:integer"/> <xsd:element name="Max" type="xsd:integer"/> <xsd:element name="Inc" type="xsd:integer"/> <xsd:element name="Page" type="xsd:integer"/> <xsd:element name="Horiz" type="s:ST_TrueFalseBlank"/> <xsd:element name="Dx" type="xsd:integer"/> <xsd:element name="MapOCX" type="s:ST_TrueFalseBlank"/> <xsd:element name="CF" type="ST_CF"/> <xsd:element name="Camera" type="s:ST_TrueFalseBlank"/> <xsd:element name="RecalcAlways" type="s:ST_TrueFalseBlank"/> <xsd:element name="AutoScale" type="s:ST_TrueFalseBlank"/> <xsd:element name="DDE" type="s:ST_TrueFalseBlank"/> <xsd:element name="UIObj" type="s:ST_TrueFalseBlank"/> <xsd:element name="ScriptText" type="xsd:string"/> <xsd:element name="ScriptExtended" type="xsd:string"/> <xsd:element name="ScriptLanguage" type="xsd:nonNegativeInteger"/> <xsd:element name="ScriptLocation" type="xsd:nonNegativeInteger"/> <xsd:element name="FmlaTxbx" type="xsd:string"/> </xsd:choice> <xsd:attribute name="ObjectType" type="ST_ObjectType" use="required"/> </xsd:complexType> <xsd:simpleType name="ST_CF"> <xsd:restriction base="xsd:string"/> </xsd:simpleType> <xsd:simpleType name="ST_ObjectType"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Button"/> <xsd:enumeration value="Checkbox"/> <xsd:enumeration value="Dialog"/> <xsd:enumeration value="Drop"/> <xsd:enumeration value="Edit"/> <xsd:enumeration value="GBox"/> <xsd:enumeration value="Label"/> <xsd:enumeration value="LineA"/> <xsd:enumeration value="List"/> <xsd:enumeration value="Movie"/> <xsd:enumeration value="Note"/> <xsd:enumeration value="Pict"/> <xsd:enumeration value="Radio"/> <xsd:enumeration value="RectA"/> <xsd:enumeration value="Scroll"/> <xsd:enumeration value="Spin"/> <xsd:enumeration value="Shape"/> <xsd:enumeration value="Group"/> <xsd:enumeration value="Rect"/> </xsd:restriction> </xsd:simpleType> </xsd:schema> ```
/content/code_sandbox/ooxml-schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd
xml
2016-03-26T23:43:56
2024-08-16T13:02:47
docx
dolanmiu/docx
4,139
1,601
```xml <?xml version="1.0" encoding="UTF-8"?> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22154" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> <dependencies> <deployment identifier="macosx"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22154"/> </dependencies> <objects> <customObject id="-2" userLabel="File's Owner" customClass="NSApplication"> <connections> <outlet property="delegate" destination="Voe-Tx-rLC" id="GzC-gU-4Uq"/> </connections> </customObject> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-3" userLabel="Application" customClass="NSObject"/> <customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="Karabiner_GamePadViewer"/> <menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6"> <items> <menuItem title="Karabiner-GamePadViewer" id="1Xt-HY-uBw" userLabel="Karabiner-GamePadViewer"> <modifierMask key="keyEquivalentModifierMask"/> <menu key="submenu" title="Karabiner-GamePadViewer" systemMenu="apple" id="uQy-DD-JDr"> <items> <menuItem title="Hide Karabiner-GamePadViewer" keyEquivalent="h" id="Olw-nP-bQN" userLabel="Hide Karabiner-GamePadViewer"> <connections> <action selector="hide:" target="-1" id="PnN-Uc-m68"/> </connections> </menuItem> <menuItem title="Hide Others" keyEquivalent="h" id="Vdr-fp-XzO"> <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/> <connections> <action selector="hideOtherApplications:" target="-1" id="VT4-aY-XCT"/> </connections> </menuItem> <menuItem title="Show All" id="Kd2-mp-pUS"> <modifierMask key="keyEquivalentModifierMask"/> <connections> <action selector="unhideAllApplications:" target="-1" id="Dhg-Le-xox"/> </connections> </menuItem> <menuItem isSeparatorItem="YES" id="TZI-3b-uc9"/> <menuItem title="Quit Karabiner-GamePadViewer" keyEquivalent="q" id="pc0-ds-IqP" userLabel="Quit Karabiner-GamePadViewer"> <connections> <action selector="terminate:" target="-1" id="J9R-Lm-n58"/> </connections> </menuItem> </items> </menu> </menuItem> <menuItem title="Edit" id="5QF-Oa-p0T"> <modifierMask key="keyEquivalentModifierMask"/> <menu key="submenu" title="Edit" id="W48-6f-4Dl"> <items> <menuItem title="Undo" keyEquivalent="z" id="dRJ-4n-Yzg"> <connections> <action selector="undo:" target="-1" id="M6e-cu-g7V"/> </connections> </menuItem> <menuItem title="Redo" keyEquivalent="Z" id="6dh-zS-Vam"/> <menuItem isSeparatorItem="YES" id="WRV-NI-Exz"/> <menuItem title="Cut" keyEquivalent="x" id="uRl-iY-unG"> <connections> <action selector="cut:" target="-1" id="YJe-68-I9s"/> </connections> </menuItem> <menuItem title="Copy" keyEquivalent="c" id="x3v-GG-iWU"> <connections> <action selector="copy:" target="-1" id="G1f-GL-Joy"/> </connections> </menuItem> <menuItem title="Paste" keyEquivalent="v" id="gVA-U4-sdL"> <connections> <action selector="paste:" target="-1" id="UvS-8e-Qdg"/> </connections> </menuItem> <menuItem title="Paste and Match Style" keyEquivalent="V" id="WeT-3V-zwk"> <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/> <connections> <action selector="pasteAsPlainText:" target="-1" id="cEh-KX-wJQ"/> </connections> </menuItem> <menuItem title="Delete" id="pa3-QI-u2k"> <modifierMask key="keyEquivalentModifierMask"/> <connections> <action selector="delete:" target="-1" id="0Mk-Ml-PaM"/> </connections> </menuItem> <menuItem title="Select All" keyEquivalent="a" id="Ruw-6m-B2m"> <connections> <action selector="selectAll:" target="-1" id="VNm-Mi-diN"/> </connections> </menuItem> <menuItem isSeparatorItem="YES" id="uyl-h8-XO2"/> <menuItem title="Find" id="4EN-yA-p0u"> <modifierMask key="keyEquivalentModifierMask"/> <menu key="submenu" title="Find" id="1b7-l0-nxx"> <items> <menuItem title="Find" tag="1" keyEquivalent="f" id="Xz5-n4-O0W"> <connections> <action selector="performFindPanelAction:" target="-1" id="cD7-Qs-BN4"/> </connections> </menuItem> <menuItem title="Find and Replace" tag="12" keyEquivalent="f" id="YEy-JH-Tfz"> <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/> <connections> <action selector="performFindPanelAction:" target="-1" id="WD3-Gg-5AJ"/> </connections> </menuItem> <menuItem title="Find Next" tag="2" keyEquivalent="g" id="q09-fT-Sye"> <connections> <action selector="performFindPanelAction:" target="-1" id="NDo-RZ-v9R"/> </connections> </menuItem> <menuItem title="Find Previous" tag="3" keyEquivalent="G" id="OwM-mh-QMV"> <connections> <action selector="performFindPanelAction:" target="-1" id="HOh-sY-3ay"/> </connections> </menuItem> <menuItem title="Use Selection for Find" tag="7" keyEquivalent="e" id="buJ-ug-pKt"> <connections> <action selector="performFindPanelAction:" target="-1" id="U76-nv-p5D"/> </connections> </menuItem> <menuItem title="Jump to Selection" keyEquivalent="j" id="S0p-oC-mLd"/> </items> </menu> </menuItem> <menuItem title="Spelling and Grammar" id="Dv1-io-Yv7"> <modifierMask key="keyEquivalentModifierMask"/> <menu key="submenu" title="Spelling" id="3IN-sU-3Bg"> <items> <menuItem title="Show Spelling and Grammar" keyEquivalent=":" id="HFo-cy-zxI"> <connections> <action selector="showGuessPanel:" target="-1" id="vFj-Ks-hy3"/> </connections> </menuItem> <menuItem title="Check Document Now" keyEquivalent=";" id="hz2-CU-CR7"> <connections> <action selector="checkSpelling:" target="-1" id="fz7-VC-reM"/> </connections> </menuItem> <menuItem isSeparatorItem="YES" id="bNw-od-mp5"/> <menuItem title="Check Spelling While Typing" id="rbD-Rh-wIN"> <modifierMask key="keyEquivalentModifierMask"/> <connections> <action selector="toggleContinuousSpellChecking:" target="-1" id="7w6-Qz-0kB"/> </connections> </menuItem> <menuItem title="Check Grammar With Spelling" id="mK6-2p-4JG"> <modifierMask key="keyEquivalentModifierMask"/> <connections> <action selector="toggleGrammarChecking:" target="-1" id="muD-Qn-j4w"/> </connections> </menuItem> <menuItem title="Correct Spelling Automatically" id="78Y-hA-62v"> <modifierMask key="keyEquivalentModifierMask"/> <connections> <action selector="toggleAutomaticSpellingCorrection:" target="-1" id="2lM-Qi-WAP"/> </connections> </menuItem> </items> </menu> </menuItem> <menuItem title="Substitutions" id="9ic-FL-obx"> <modifierMask key="keyEquivalentModifierMask"/> <menu key="submenu" title="Substitutions" id="FeM-D8-WVr"> <items> <menuItem title="Show Substitutions" id="z6F-FW-3nz"> <modifierMask key="keyEquivalentModifierMask"/> <connections> <action selector="orderFrontSubstitutionsPanel:" target="-1" id="oku-mr-iSq"/> </connections> </menuItem> <menuItem isSeparatorItem="YES" id="gPx-C9-uUO"/> <menuItem title="Smart Copy/Paste" id="9yt-4B-nSM"> <modifierMask key="keyEquivalentModifierMask"/> <connections> <action selector="toggleSmartInsertDelete:" target="-1" id="3IJ-Se-DZD"/> </connections> </menuItem> <menuItem title="Smart Quotes" id="hQb-2v-fYv"> <modifierMask key="keyEquivalentModifierMask"/> <connections> <action selector="toggleAutomaticQuoteSubstitution:" target="-1" id="ptq-xd-QOA"/> </connections> </menuItem> <menuItem title="Smart Dashes" id="rgM-f4-ycn"> <modifierMask key="keyEquivalentModifierMask"/> <connections> <action selector="toggleAutomaticDashSubstitution:" target="-1" id="oCt-pO-9gS"/> </connections> </menuItem> <menuItem title="Smart Links" id="cwL-P1-jid"> <modifierMask key="keyEquivalentModifierMask"/> <connections> <action selector="toggleAutomaticLinkDetection:" target="-1" id="Gip-E3-Fov"/> </connections> </menuItem> <menuItem title="Data Detectors" id="tRr-pd-1PS"> <modifierMask key="keyEquivalentModifierMask"/> <connections> <action selector="toggleAutomaticDataDetection:" target="-1" id="R1I-Nq-Kbl"/> </connections> </menuItem> <menuItem title="Text Replacement" id="HFQ-gK-NFA"> <modifierMask key="keyEquivalentModifierMask"/> <connections> <action selector="toggleAutomaticTextReplacement:" target="-1" id="DvP-Fe-Py6"/> </connections> </menuItem> </items> </menu> </menuItem> <menuItem title="Transformations" id="2oI-Rn-ZJC"> <modifierMask key="keyEquivalentModifierMask"/> <menu key="submenu" title="Transformations" id="c8a-y6-VQd"> <items> <menuItem title="Make Upper Case" id="vmV-6d-7jI"> <modifierMask key="keyEquivalentModifierMask"/> </menuItem> <menuItem title="Make Lower Case" id="d9M-CD-aMd"> <modifierMask key="keyEquivalentModifierMask"/> </menuItem> <menuItem title="Capitalize" id="UEZ-Bs-lqG"> <modifierMask key="keyEquivalentModifierMask"/> </menuItem> </items> </menu> </menuItem> <menuItem title="Speech" id="xrE-MZ-jX0"> <modifierMask key="keyEquivalentModifierMask"/> <menu key="submenu" title="Speech" id="3rS-ZA-NoH"> <items> <menuItem title="Start Speaking" id="Ynk-f8-cLZ"> <modifierMask key="keyEquivalentModifierMask"/> <connections> <action selector="startSpeaking:" target="-1" id="654-Ng-kyl"/> </connections> </menuItem> <menuItem title="Stop Speaking" id="Oyz-dy-DGm"> <modifierMask key="keyEquivalentModifierMask"/> <connections> <action selector="stopSpeaking:" target="-1" id="dX8-6p-jy9"/> </connections> </menuItem> </items> </menu> </menuItem> </items> </menu> </menuItem> <menuItem title="Window" id="aUF-d1-5bR"> <modifierMask key="keyEquivalentModifierMask"/> <menu key="submenu" title="Window" systemMenu="window" id="Td7-aD-5lo"> <items> <menuItem title="Close" keyEquivalent="w" id="DVo-aG-piG"> <connections> <action selector="performClose:" target="-1" id="HmO-Ls-i7Q"/> </connections> </menuItem> <menuItem title="Minimize" keyEquivalent="m" id="OY7-WF-poV"> <connections> <action selector="performMiniaturize:" target="-1" id="VwT-WD-YPe"/> </connections> </menuItem> <menuItem title="Zoom" id="R4o-n2-Eq4"> <modifierMask key="keyEquivalentModifierMask"/> <connections> <action selector="performZoom:" target="-1" id="DIl-cC-cCs"/> </connections> </menuItem> <menuItem isSeparatorItem="YES" id="eu3-7i-yIM"/> <menuItem title="Bring All to Front" id="LE2-aR-0XJ"> <modifierMask key="keyEquivalentModifierMask"/> <connections> <action selector="arrangeInFront:" target="-1" id="DRN-fu-gQh"/> </connections> </menuItem> </items> </menu> </menuItem> </items> <point key="canvasLocation" x="88" y="476"/> </menu> </objects> </document> ```
/content/code_sandbox/appendix/GamePadViewer/Resources/MainMenu.xib
xml
2016-07-11T04:57:55
2024-08-16T18:49:52
Karabiner-Elements
pqrs-org/Karabiner-Elements
18,433
3,336
```xml import { ICommonParams, IScoreParams } from '../../../models/definitions/common'; import { IContext } from '../../../connectionResolver'; import { paginate } from '@erxes/api-utils/src'; const scoreLogQueries = { async scoreLogs(_root, params: ICommonParams, { models }: IContext) { const { ownerType, ownerId, searchValue } = params; const filter: any = {}; if (ownerType) { filter.ownerType = ownerType; } if (ownerId) { filter.ownerId = ownerId; } if (searchValue) { filter.description = searchValue; } return paginate( models.ScoreLogs.find(filter).sort({ createdAt: -1 }), params ); }, async scoreLogList(_root, params: IScoreParams, { models }: IContext) { const result = models.ScoreLogs.getScoreLogs(params); return result; } }; export default scoreLogQueries; ```
/content/code_sandbox/packages/plugin-loyalties-api/src/graphql/resolvers/queries/scoreLogs.ts
xml
2016-11-11T06:54:50
2024-08-16T10:26:06
erxes
erxes/erxes
3,479
210
```xml import { DeprecatedError } from './DeprecatedError' import { HttpStatusCode } from './HttpStatusCode' export type DeprecatedMinimalHttpResponse = { status: HttpStatusCode error?: DeprecatedError headers?: Map<string, string | null> } ```
/content/code_sandbox/packages/responses/src/Domain/Http/DeprecatedMinimalHttpResponses.ts
xml
2016-12-05T23:31:33
2024-08-16T06:51:19
app
standardnotes/app
5,180
49
```xml import { Pipe, PipeTransform } from '@angular/core'; import { CalendarEvent } from 'calendar-utils'; import { CalendarEventTitleFormatter } from '../calendar-event-title-formatter/calendar-event-title-formatter.provider'; @Pipe({ name: 'calendarEventTitle', }) export class CalendarEventTitlePipe implements PipeTransform { constructor(private calendarEventTitle: CalendarEventTitleFormatter) {} transform(title: string, titleType: string, event: CalendarEvent): string { return this.calendarEventTitle[titleType](event, title); } } ```
/content/code_sandbox/projects/angular-calendar/src/modules/common/calendar-event-title/calendar-event-title.pipe.ts
xml
2016-04-26T15:19:33
2024-08-08T14:23:40
angular-calendar
mattlewis92/angular-calendar
2,717
114
```xml <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Library</OutputType> <IsPackable>false</IsPackable> <TargetFramework>netcoreapp3.1</TargetFramework> </PropertyGroup> <ItemGroup> <PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" /> <PackageReference Include="Amazon.Lambda.TestUtilities" Version="2.0.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" /> <PackageReference Include="xunit" Version="2.3.1" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\..\src\BlueprintBaseName.1\BlueprintBaseName.1.fsproj" /> </ItemGroup> <ItemGroup> <Compile Include="FunctionTest.fs" /> </ItemGroup> </Project> ```
/content/code_sandbox/Blueprints/BlueprintDefinitions/vs2019/StepFunctionsHelloWorld-FSharp/template/test/BlueprintBaseName.1.Tests/BlueprintBaseName.1.Tests.fsproj
xml
2016-11-11T20:43:34
2024-08-15T16:57:53
aws-lambda-dotnet
aws/aws-lambda-dotnet
1,558
221
```xml const reportTemplates = [ { serviceType: "ticket", title: "Tickets chart", serviceName: "cards", description: "Tickets conversation charts", charts: [ "TicketsTotalCount", "TicketCustomProperties", "TicketClosedTotalsByTags", "TicketClosedTotalsByLabel", "TicketClosedTotalsByRep", "TicketTotalsByFrequency", "TicketAverageTimeToCloseByRep", "TicketTotalsBySource" ], img: "path_to_url" } ]; export default reportTemplates; ```
/content/code_sandbox/packages/plugin-tickets-api/src/reports/template/report.ts
xml
2016-11-11T06:54:50
2024-08-16T10:26:06
erxes
erxes/erxes
3,479
123
```xml <manifest xmlns:android="path_to_url" package="com.fetchdemo"> <uses-permission android:name="android.permission.INTERNET" /> <!-- [background-fetch] OPTIONAL: allows forceAlarmManager: true to use exact alarms --> <uses-permission android:name="android.permission.USE_EXACT_ALARM" android:minSdkVersion="34" /> <application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" android:theme="@style/AppTheme"> <activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> ```
/content/code_sandbox/example/android/app/src/main/AndroidManifest.xml
xml
2016-08-01T18:44:54
2024-08-14T15:07:53
react-native-background-fetch
transistorsoft/react-native-background-fetch
1,459
257
```xml import * as React from "react"; import { useTranslation } from "react-i18next"; import { $Diff } from "utility-types"; import { CollectionPermission } from "@shared/types"; import { EmptySelectValue } from "~/types"; import InputSelect, { Props, Option, InputSelectRef } from "./InputSelect"; function InputSelectPermission( props: $Diff< Props, { options: Array<Option>; ariaLabel: string; } >, ref: React.RefObject<InputSelectRef> ) { const { value, onChange, ...rest } = props; const { t } = useTranslation(); return ( <InputSelect ref={ref} label={t("Permission")} options={[ { label: t("View only"), value: CollectionPermission.Read, }, { label: t("Can edit"), value: CollectionPermission.ReadWrite, }, { divider: true, label: t("No access"), value: EmptySelectValue, }, ]} ariaLabel={t("Default access")} value={value || EmptySelectValue} onChange={onChange} {...rest} /> ); } export default React.forwardRef(InputSelectPermission); ```
/content/code_sandbox/app/components/InputSelectPermission.tsx
xml
2016-05-22T21:31:47
2024-08-16T19:57:22
outline
outline/outline
26,751
265
```xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "path_to_url"> <library id="fiber" name="Fiber" dirname="fiber" last-revision="$Date: 2017/11/07 18:07:00 $" xmlns:xi="path_to_url"> <libraryinfo> <authorgroup> <author> <firstname>Oliver</firstname> <surname>Kowalke</surname> </author> </authorgroup> <copyright> <year>2013</year> <holder>Oliver Kowalke</holder> </copyright> <legalnotice id="fiber.legal"> <para> file LICENSE_1_0.txt or copy at <ulink url="path_to_url">path_to_url </para> </legalnotice> <librarypurpose> C++ Library to cooperatively schedule and synchronize micro-threads </librarypurpose> <librarycategory name="category:text"></librarycategory> </libraryinfo> <title>Fiber</title> <section id="fiber.overview"> <title><link linkend="fiber.overview">Overview</link></title> <para> <emphasis role="bold">Boost.Fiber</emphasis> provides a framework for micro-/userland-threads (fibers) scheduled cooperatively. The API contains classes and functions to manage and synchronize fibers similiarly to <ulink url="path_to_url">standard thread support library</ulink>. </para> <para> Each fiber has its own stack. </para> <para> A fiber can save the current execution state, including all registers and CPU flags, the instruction pointer, and the stack pointer and later restore this state. The idea is to have multiple execution paths running on a single thread using cooperative scheduling (versus threads, which are preemptively scheduled). The running fiber decides explicitly when it should yield to allow another fiber to run (context switching). <emphasis role="bold">Boost.Fiber</emphasis> internally uses <ulink url="path_to_url"><emphasis>call/cc</emphasis></ulink> from <ulink url="path_to_url">Boost.Context</ulink>; the classes in this library manage, schedule and, when needed, synchronize those execution contexts. A context switch between threads usually costs thousands of CPU cycles on x86, compared to a fiber switch with less than a hundred cycles. A fiber runs on a single thread at any point in time. </para> <para> In order to use the classes and functions described here, you can either include the specific headers specified by the descriptions of each class or function, or include the master library header: </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">all</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> </programlisting> <para> which includes all the other headers in turn. </para> <para> The namespaces used are: </para> <programlisting><phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_fiber</phrase> </programlisting> <bridgehead renderas="sect3" id="fiber.overview.h0"> <phrase id="fiber.overview.fibers_and_threads"/><link linkend="fiber.overview.fibers_and_threads">Fibers and Threads</link> </bridgehead> <para> Control is cooperatively passed between fibers launched on a given thread. At a given moment, on a given thread, at most one fiber is running. </para> <para> Spawning additional fibers on a given thread does not distribute your program across more hardware cores, though it can make more effective use of the core on which it's running. </para> <para> On the other hand, a fiber may safely access any resource exclusively owned by its parent thread without explicitly needing to defend that resource against concurrent access by other fibers on the same thread. You are already guaranteed that no other fiber on that thread is concurrently touching that resource. This can be particularly important when introducing concurrency in legacy code. You can safely spawn fibers running old code, using asynchronous I/O to interleave execution. </para> <para> In effect, fibers provide a natural way to organize concurrent code based on asynchronous I/O. Instead of chaining together completion handlers, code running on a fiber can make what looks like a normal blocking function call. That call can cheaply suspend the calling fiber, allowing other fibers on the same thread to run. When the operation has completed, the suspended fiber resumes, without having to explicitly save or restore its state. Its local stack variables persist across the call. </para> <para> A fiber can be migrated from one thread to another, though the library does not do this by default. It is possible for you to supply a custom scheduler that migrates fibers between threads. You may specify custom fiber properties to help your scheduler decide which fibers are permitted to migrate. Please see <link linkend="migration">Migrating fibers between threads</link> and <link linkend="custom">Customization</link> for more details. </para> <para> A fiber launched on a particular thread continues running on that thread unless migrated. It might be unblocked (see <link linkend="blocking">Blocking</link> below) by some other thread, but that only transitions the fiber from <quote>blocked</quote> to <quote>ready</quote> on its current thread &mdash; it does not cause the fiber to resume on the thread that unblocked it. </para> <anchor id="thread_local_storage"/> <bridgehead renderas="sect3" id="fiber.overview.h1"> <phrase id="fiber.overview.thread_local_storage"/><link linkend="fiber.overview.thread_local_storage">thread-local storage</link> </bridgehead> <para> Unless migrated, a fiber may access thread-local storage; however that storage will be shared among all fibers running on the same thread. For fiber-local storage, please see <link linkend="class_fiber_specific_ptr"><code>fiber_specific_ptr</code></link>. </para> <anchor id="cross_thread_sync"/> <bridgehead renderas="sect3" id="fiber.overview.h2"> <phrase id="fiber.overview.boost_fibers_no_atomics"/><link linkend="fiber.overview.boost_fibers_no_atomics">BOOST_FIBERS_NO_ATOMICS</link> </bridgehead> <para> The fiber synchronization objects provided by this library will, by default, safely synchronize fibers running on different threads. However, this level of synchronization can be removed (for performance) by building the library with <emphasis role="bold"><code><phrase role="identifier">BOOST_FIBERS_NO_ATOMICS</phrase></code></emphasis> defined. When the library is built with that macro, you must ensure that all the fibers referencing a particular synchronization object are running in the same thread. Please see <link linkend="synchronization">Synchronization</link>. </para> <anchor id="blocking"/> <bridgehead renderas="sect3" id="fiber.overview.h3"> <phrase id="fiber.overview.blocking"/><link linkend="fiber.overview.blocking">Blocking</link> </bridgehead> <para> Normally, when this documentation states that a particular fiber <emphasis>blocks</emphasis> (or equivalently, <emphasis>suspends),</emphasis> it means that it yields control, allowing other fibers on the same thread to run. The synchronization mechanisms provided by <emphasis role="bold">Boost.Fiber</emphasis> have this behavior. </para> <para> A fiber may, of course, use normal thread synchronization mechanisms; however a fiber that invokes any of these mechanisms will block its entire thread, preventing any other fiber from running on that thread in the meantime. For instance, when a fiber wants to wait for a value from another fiber in the same thread, using <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">future</phrase></code> would be unfortunate: <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">future</phrase><phrase role="special">::</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code> would block the whole thread, preventing the other fiber from delivering its value. Use <link linkend="class_future"><code>future&lt;&gt;</code></link> instead. </para> <para> Similarly, a fiber that invokes a normal blocking I/O operation will block its entire thread. Fiber authors are encouraged to consistently use asynchronous I/O. <ulink url="path_to_url">Boost.Asio</ulink> and other asynchronous I/O operations can straightforwardly be adapted for <emphasis role="bold">Boost.Fiber</emphasis>: see <link linkend="callbacks">Integrating Fibers with Asynchronous Callbacks</link>. </para> <para> <emphasis role="bold">Boost.Fiber</emphasis> depends upon <ulink url="path_to_url">Boost.Context</ulink>. Boost version 1.61.0 or greater is required. </para> <note> <para> This library requires C++11! </para> </note> <section id="fiber.overview.implementations__fcontext_t__ucontext_t_and_winfiber"> <title><anchor id="implementation"/><link linkend="fiber.overview.implementations__fcontext_t__ucontext_t_and_winfiber">Implementations: fcontext_t, ucontext_t and WinFiber</link></title> <para> <emphasis role="bold">Boost.Fiber</emphasis> uses <ulink url="path_to_url"><emphasis>call/cc</emphasis></ulink> from <ulink url="path_to_url">Boost.Context</ulink> as building-block. </para> <bridgehead renderas="sect4" id="fiber.overview.implementations__fcontext_t__ucontext_t_and_winfiber.h0"> <phrase id="fiber.overview.implementations__fcontext_t__ucontext_t_and_winfiber.fcontext_t"/><link linkend="fiber.overview.implementations__fcontext_t__ucontext_t_and_winfiber.fcontext_t">fcontext_t</link> </bridgehead> <para> The implementation uses <code><phrase role="identifier">fcontext_t</phrase></code> per default. fcontext_t is based on assembler and not available for all platforms. It provides a much better performance than <code><phrase role="identifier">ucontext_t</phrase></code> (the context switch takes two magnitudes of order less CPU cycles; see section <ulink url="path_to_url"><emphasis>performance</emphasis></ulink>) and <code><phrase role="identifier">WinFiber</phrase></code>. </para> <bridgehead renderas="sect4" id="fiber.overview.implementations__fcontext_t__ucontext_t_and_winfiber.h1"> <phrase id="fiber.overview.implementations__fcontext_t__ucontext_t_and_winfiber.ucontext_t"/><link linkend="fiber.overview.implementations__fcontext_t__ucontext_t_and_winfiber.ucontext_t">ucontext_t</link> </bridgehead> <para> As an alternative, <ulink url="path_to_url"><code><phrase role="identifier">ucontext_t</phrase></code></ulink> can be used by compiling with <code><phrase role="identifier">BOOST_USE_UCONTEXT</phrase></code> and b2 property <code><phrase role="identifier">context</phrase><phrase role="special">-</phrase><phrase role="identifier">impl</phrase><phrase role="special">=</phrase><phrase role="identifier">ucontext</phrase></code>. <code><phrase role="identifier">ucontext_t</phrase></code> might be available on a broader range of POSIX-platforms but has some <ulink url="path_to_url#ucontext"><emphasis>disadvantages</emphasis></ulink> (for instance deprecated since POSIX.1-2003, not C99 conform). </para> <note> <para> <ulink url="path_to_url"><emphasis>call/cc</emphasis></ulink> supports <link linkend="segmented"><emphasis>Segmented stacks</emphasis></link> only with <code><phrase role="identifier">ucontext_t</phrase></code> as its implementation. </para> </note> <bridgehead renderas="sect4" id="fiber.overview.implementations__fcontext_t__ucontext_t_and_winfiber.h2"> <phrase id="fiber.overview.implementations__fcontext_t__ucontext_t_and_winfiber.winfiber"/><link linkend="fiber.overview.implementations__fcontext_t__ucontext_t_and_winfiber.winfiber">WinFiber</link> </bridgehead> <para> With <code><phrase role="identifier">BOOST_USE_WINFIB</phrase></code> and b2 property <code><phrase role="identifier">context</phrase><phrase role="special">-</phrase><phrase role="identifier">impl</phrase><phrase role="special">=</phrase><phrase role="identifier">winfib</phrase></code> Win32-Fibers are used as implementation for <ulink url="path_to_url"><emphasis>call/cc</emphasis></ulink>. </para> <para> Because the TIB (thread information block) is not fully described in the MSDN, it might be possible that not all required TIB-parts are swapped. </para> <note> <para> The first call of <ulink url="path_to_url"><emphasis>call/cc</emphasis></ulink> converts the thread into a Windows fiber by invoking <code><phrase role="identifier">ConvertThreadToFiber</phrase><phrase role="special">()</phrase></code>. If desired, <code><phrase role="identifier">ConvertFiberToThread</phrase><phrase role="special">()</phrase></code> has to be called by the user explicitly in order to release resources allocated by <code><phrase role="identifier">ConvertThreadToFiber</phrase><phrase role="special">()</phrase></code> (e.g. after using boost.context). </para> </note> </section> </section> <section id="fiber.fiber_mgmt"> <title><link linkend="fiber.fiber_mgmt">Fiber management</link></title> <bridgehead renderas="sect3" id="fiber.fiber_mgmt.h0"> <phrase id="fiber.fiber_mgmt.synopsis"/><link linkend="fiber.fiber_mgmt.synopsis">Synopsis</link> </bridgehead> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">all</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">fiber</phrase><phrase role="special">;</phrase> <phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">&lt;(</phrase> <phrase role="identifier">fiber</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">l</phrase><phrase role="special">,</phrase> <phrase role="identifier">fiber</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">r</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase> <phrase role="identifier">fiber</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">l</phrase><phrase role="special">,</phrase> <phrase role="identifier">fiber</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">r</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">SchedAlgo</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">(</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">args</phrase><phrase role="special">);</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">has_ready_fibers</phrase><phrase role="special">();</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">algo</phrase> <phrase role="special">{</phrase> <phrase role="keyword">struct</phrase> <phrase role="identifier">algorithm</phrase><phrase role="special">;</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">PROPS</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">struct</phrase> <phrase role="identifier">algorithm_with_properties</phrase><phrase role="special">;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">round_robin</phrase><phrase role="special">;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">shared_round_robin</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">this_fiber</phrase> <phrase role="special">{</phrase> <phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase> <phrase role="identifier">get_id</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">yield</phrase><phrase role="special">();</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">sleep_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">abs_time</phrase><phrase role="special">)</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">sleep_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">rel_time</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">PROPS</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">PROPS</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">properties</phrase><phrase role="special">();</phrase> <phrase role="special">}}</phrase> </programlisting> <bridgehead renderas="sect3" id="fiber.fiber_mgmt.h1"> <phrase id="fiber.fiber_mgmt.tutorial"/><link linkend="fiber.fiber_mgmt.tutorial">Tutorial</link> </bridgehead> <para> Each <link linkend="class_fiber"><code>fiber</code></link> represents a micro-thread which will be launched and managed cooperatively by a scheduler. Objects of type <link linkend="class_fiber"><code>fiber</code></link> are move-only. </para> <programlisting><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase> <phrase role="identifier">f1</phrase><phrase role="special">;</phrase> <phrase role="comment">// not-a-fiber</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase> <phrase role="identifier">f2</phrase><phrase role="special">(</phrase> <phrase role="identifier">some_fn</phrase><phrase role="special">);</phrase> <phrase role="identifier">f1</phrase> <phrase role="special">=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">move</phrase><phrase role="special">(</phrase> <phrase role="identifier">f2</phrase><phrase role="special">);</phrase> <phrase role="comment">// f2 moved to f1</phrase> <phrase role="special">}</phrase> </programlisting> <bridgehead renderas="sect3" id="fiber.fiber_mgmt.h2"> <phrase id="fiber.fiber_mgmt.launching"/><link linkend="fiber.fiber_mgmt.launching">Launching</link> </bridgehead> <para> A new fiber is launched by passing an object of a callable type that can be invoked with no parameters. If the object must not be copied or moved, then <emphasis>std::ref</emphasis> can be used to pass in a reference to the function object. In this case, the user must ensure that the referenced object outlives the newly-created fiber. </para> <programlisting><phrase role="keyword">struct</phrase> <phrase role="identifier">callable</phrase> <phrase role="special">{</phrase> <phrase role="keyword">void</phrase> <phrase role="keyword">operator</phrase><phrase role="special">()();</phrase> <phrase role="special">};</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase> <phrase role="identifier">copies_are_safe</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="identifier">callable</phrase> <phrase role="identifier">x</phrase><phrase role="special">;</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <phrase role="identifier">x</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="comment">// x is destroyed, but the newly-created fiber has a copy, so this is OK</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase> <phrase role="identifier">oops</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="identifier">callable</phrase> <phrase role="identifier">x</phrase><phrase role="special">;</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="identifier">x</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="comment">// x is destroyed, but the newly-created fiber still has a reference</phrase> <phrase role="comment">// this leads to undefined behaviour</phrase> </programlisting> <para> The spawned <link linkend="class_fiber"><code>fiber</code></link> does not immediately start running. It is enqueued in the list of ready-to-run fibers, and will run when the scheduler gets around to it. </para> <anchor id="exceptions"/> <bridgehead renderas="sect3" id="fiber.fiber_mgmt.h3"> <phrase id="fiber.fiber_mgmt.exceptions"/><link linkend="fiber.fiber_mgmt.exceptions">Exceptions</link> </bridgehead> <para> An exception escaping from the function or callable object passed to the <link linkend="class_fiber"><code>fiber</code></link> constructor calls <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">terminate</phrase><phrase role="special">()</phrase></code>. If you need to know which exception was thrown, use <link linkend="class_future"><code>future&lt;&gt;</code></link> or <link linkend="class_packaged_task"><code>packaged_task&lt;&gt;</code></link>. </para> <bridgehead renderas="sect3" id="fiber.fiber_mgmt.h4"> <phrase id="fiber.fiber_mgmt.detaching"/><link linkend="fiber.fiber_mgmt.detaching">Detaching</link> </bridgehead> <para> A <link linkend="class_fiber"><code>fiber</code></link> can be detached by explicitly invoking the <link linkend="fiber_detach"><code>fiber::detach()</code></link> member function. After <link linkend="fiber_detach"><code>fiber::detach()</code></link> is called on a fiber object, that object represents <emphasis>not-a-fiber</emphasis>. The fiber object may then safely be destroyed. </para> <programlisting><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <phrase role="identifier">some_fn</phrase><phrase role="special">).</phrase><phrase role="identifier">detach</phrase><phrase role="special">();</phrase> </programlisting> <para> <emphasis role="bold">Boost.Fiber</emphasis> provides a number of ways to wait for a running fiber to complete. You can coordinate even with a detached fiber using a <link linkend="class_mutex"><code>mutex</code></link>, or <link linkend="class_condition_variable"><code>condition_variable</code></link>, or any of the other <link linkend="synchronization">synchronization objects</link> provided by the library. </para> <para> If a detached fiber is still running when the thread&#8217;s main fiber terminates, the thread will not shut down. </para> <bridgehead renderas="sect3" id="fiber.fiber_mgmt.h5"> <phrase id="fiber.fiber_mgmt.joining"/><link linkend="fiber.fiber_mgmt.joining">Joining</link> </bridgehead> <para> In order to wait for a fiber to finish, the <link linkend="fiber_join"><code>fiber::join()</code></link> member function of the <link linkend="class_fiber"><code>fiber</code></link> object can be used. <link linkend="fiber_join"><code>fiber::join()</code></link> will block until the <link linkend="class_fiber"><code>fiber</code></link> object has completed. </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">some_fn</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="special">...</phrase> <phrase role="special">}</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase> <phrase role="identifier">some_fn</phrase><phrase role="special">);</phrase> <phrase role="special">...</phrase> <phrase role="identifier">f</phrase><phrase role="special">.</phrase><phrase role="identifier">join</phrase><phrase role="special">();</phrase> </programlisting> <para> If the fiber has already completed, then <link linkend="fiber_join"><code>fiber::join()</code></link> returns immediately and the joined <link linkend="class_fiber"><code>fiber</code></link> object becomes <emphasis>not-a-fiber</emphasis>. </para> <bridgehead renderas="sect3" id="fiber.fiber_mgmt.h6"> <phrase id="fiber.fiber_mgmt.destruction"/><link linkend="fiber.fiber_mgmt.destruction">Destruction</link> </bridgehead> <para> When a <link linkend="class_fiber"><code>fiber</code></link> object representing a valid execution context (the fiber is <link linkend="fiber_joinable"><code>fiber::joinable()</code></link>) is destroyed, the program terminates. If you intend the fiber to outlive the <link linkend="class_fiber"><code>fiber</code></link> object that launched it, use the <link linkend="fiber_detach"><code>fiber::detach()</code></link> method. </para> <programlisting><phrase role="special">{</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase> <phrase role="identifier">some_fn</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="comment">// std::terminate() will be called</phrase> <phrase role="special">{</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="identifier">some_fn</phrase><phrase role="special">);</phrase> <phrase role="identifier">f</phrase><phrase role="special">.</phrase><phrase role="identifier">detach</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="comment">// okay, program continues</phrase> </programlisting> <anchor id="class_fiber_id"/> <bridgehead renderas="sect3" id="fiber.fiber_mgmt.h7"> <phrase id="fiber.fiber_mgmt.fiber_ids"/><link linkend="fiber.fiber_mgmt.fiber_ids">Fiber IDs</link> </bridgehead> <para> Objects of class <link linkend="class_fiber_id"><code><phrase role="identifier">fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase></code></link> can be used to identify fibers. Each running <link linkend="class_fiber"><code>fiber</code></link> has a unique <link linkend="class_fiber_id"><code><phrase role="identifier">fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase></code></link> obtainable from the corresponding <link linkend="class_fiber"><code>fiber</code></link> by calling the <link linkend="fiber_get_id"><code>fiber::get_id()</code></link> member function. Objects of class <link linkend="class_fiber_id"><code><phrase role="identifier">fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase></code></link> can be copied, and used as keys in associative containers: the full range of comparison operators is provided. They can also be written to an output stream using the stream insertion operator, though the output format is unspecified. </para> <para> Each instance of <link linkend="class_fiber_id"><code><phrase role="identifier">fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase></code></link> either refers to some fiber, or <emphasis>not-a-fiber</emphasis>. Instances that refer to <emphasis>not-a-fiber</emphasis> compare equal to each other, but not equal to any instances that refer to an actual fiber. The comparison operators on <link linkend="class_fiber_id"><code><phrase role="identifier">fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase></code></link> yield a total order for every non-equal <link linkend="class_fiber_id"><code><phrase role="identifier">fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase></code></link>. </para> <anchor id="class_launch"/> <bridgehead renderas="sect3" id="fiber.fiber_mgmt.h8"> <phrase id="fiber.fiber_mgmt.your_sha256_hashe_"/><link linkend="fiber.fiber_mgmt.your_sha256_hashe_">Enumeration <code><phrase role="identifier">launch</phrase></code></link> </bridgehead> <para> <code><phrase role="identifier">launch</phrase></code> specifies whether control passes immediately into a newly-launched fiber. </para> <programlisting><phrase role="keyword">enum</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">launch</phrase> <phrase role="special">{</phrase> <phrase role="identifier">dispatch</phrase><phrase role="special">,</phrase> <phrase role="identifier">post</phrase> <phrase role="special">};</phrase> </programlisting> <bridgehead renderas="sect3" id="fiber.fiber_mgmt.h9"> <phrase id="fiber.fiber_mgmt._code__phrase_role__identifier__dispatch__phrase___code_"/><link linkend="fiber.fiber_mgmt._code__phrase_role__identifier__dispatch__phrase___code_"><code><phrase role="identifier">dispatch</phrase></code></link> </bridgehead> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> A fiber launched with <code><phrase role="identifier">launch</phrase> <phrase role="special">==</phrase> <phrase role="identifier">dispatch</phrase></code> is entered immediately. In other words, launching a fiber with <code><phrase role="identifier">dispatch</phrase></code> suspends the caller (the previously-running fiber) until the fiber scheduler has a chance to resume it later. </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect3" id="fiber.fiber_mgmt.h10"> <phrase id="fiber.fiber_mgmt._code__phrase_role__identifier__post__phrase___code_"/><link linkend="fiber.fiber_mgmt._code__phrase_role__identifier__post__phrase___code_"><code><phrase role="identifier">post</phrase></code></link> </bridgehead> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> A fiber launched with <code><phrase role="identifier">launch</phrase> <phrase role="special">==</phrase> <phrase role="identifier">post</phrase></code> is passed to the fiber scheduler as ready, but it is not yet entered. The caller (the previously-running fiber) continues executing. The newly-launched fiber will be entered when the fiber scheduler has a chance to resume it later. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> If <code><phrase role="identifier">launch</phrase></code> is not explicitly specified, <code><phrase role="identifier">post</phrase></code> is the default. </para> </listitem> </varlistentry> </variablelist> <section id="fiber.fiber_mgmt.fiber"> <title><anchor id="class_fiber"/><link linkend="fiber.fiber_mgmt.fiber">Class <code><phrase role="identifier">fiber</phrase></code></link></title> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">fiber</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">id</phrase><phrase role="special">;</phrase> <phrase role="keyword">constexpr</phrase> <phrase role="identifier">fiber</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;,</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <link linkend="class_launch"><code><phrase role="identifier">launch</phrase></code></link><phrase role="special">,</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;,</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <link linkend="stack_allocator_concept"><code><phrase role="identifier">StackAllocator</phrase></code></link><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">allocator_arg_t</phrase></code></ulink><phrase role="special">,</phrase> <phrase role="identifier">StackAllocator</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;,</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <link linkend="stack_allocator_concept"><code><phrase role="identifier">StackAllocator</phrase></code></link><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <link linkend="class_launch"><code><phrase role="identifier">launch</phrase></code></link><phrase role="special">,</phrase> <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">allocator_arg_t</phrase></code></ulink><phrase role="special">,</phrase> <phrase role="identifier">StackAllocator</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;,</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...);</phrase> <phrase role="special">~</phrase><phrase role="identifier">fiber</phrase><phrase role="special">();</phrase> <phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <phrase role="identifier">fiber</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">fiber</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">fiber</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <phrase role="identifier">fiber</phrase> <phrase role="special">&amp;&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">fiber</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">fiber</phrase> <phrase role="special">&amp;&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase> <phrase role="identifier">fiber</phrase> <phrase role="special">&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">joinable</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">id</phrase> <phrase role="identifier">get_id</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">detach</phrase><phrase role="special">();</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">join</phrase><phrase role="special">();</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">PROPS</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">PROPS</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">properties</phrase><phrase role="special">();</phrase> <phrase role="special">};</phrase> <phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">&lt;(</phrase> <phrase role="identifier">fiber</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;,</phrase> <phrase role="identifier">fiber</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase> <phrase role="identifier">fiber</phrase> <phrase role="special">&amp;,</phrase> <phrase role="identifier">fiber</phrase> <phrase role="special">&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">SchedAlgo</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">(</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">has_ready_fibers</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="special">}}</phrase> </programlisting> <bridgehead renderas="sect4" id="fiber.fiber_mgmt.fiber.h0"> <phrase id="fiber.fiber_mgmt.fiber.default_constructor"/><link linkend="fiber.fiber_mgmt.fiber.default_constructor">Default constructor</link> </bridgehead> <programlisting><phrase role="keyword">constexpr</phrase> <phrase role="identifier">fiber</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Constructs a <link linkend="class_fiber"><code>fiber</code></link> instance that refers to <emphasis>not-a-fiber</emphasis>. </para> </listitem> </varlistentry> <varlistentry> <term>Postconditions:</term> <listitem> <para> <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase><phrase role="special">()</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> </variablelist> <anchor id="fiber_fiber"/> <bridgehead renderas="sect4" id="fiber.fiber_mgmt.fiber.h1"> <phrase id="fiber.fiber_mgmt.fiber.constructor"/><link linkend="fiber.fiber_mgmt.fiber.constructor">Constructor</link> </bridgehead> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">fn</phrase><phrase role="special">,</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">args</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <link linkend="class_launch"><code><phrase role="identifier">launch</phrase></code></link> <phrase role="identifier">policy</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">fn</phrase><phrase role="special">,</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">args</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <link linkend="stack_allocator_concept"><code><phrase role="identifier">StackAllocator</phrase></code></link><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">allocator_arg_t</phrase></code></ulink><phrase role="special">,</phrase> <phrase role="identifier">StackAllocator</phrase> <phrase role="identifier">salloc</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">fn</phrase><phrase role="special">,</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">args</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <link linkend="stack_allocator_concept"><code><phrase role="identifier">StackAllocator</phrase></code></link><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <link linkend="class_launch"><code><phrase role="identifier">launch</phrase></code></link> <phrase role="identifier">policy</phrase><phrase role="special">,</phrase> <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">allocator_arg_t</phrase></code></ulink><phrase role="special">,</phrase> <phrase role="identifier">StackAllocator</phrase> <phrase role="identifier">salloc</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">fn</phrase><phrase role="special">,</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">args</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Preconditions:</term> <listitem> <para> <code><phrase role="identifier">Fn</phrase></code> must be copyable or movable. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> <code><phrase role="identifier">fn</phrase></code> is copied or moved into internal storage for access by the new fiber. If <link linkend="class_launch"><code>launch</code></link> is specified (or defaulted) to <code><phrase role="identifier">post</phrase></code>, the new fiber is marked <quote>ready</quote> and will be entered at the next opportunity. If <code><phrase role="identifier">launch</phrase></code> is specified as <code><phrase role="identifier">dispatch</phrase></code>, the calling fiber is suspended and the new fiber is entered immediately. </para> </listitem> </varlistentry> <varlistentry> <term>Postconditions:</term> <listitem> <para> <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> refers to the newly created fiber of execution. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">fiber_error</phrase></code> if an error occurs. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> <link linkend="stack_allocator_concept"><code><phrase role="identifier">StackAllocator</phrase></code></link> is required to allocate a stack for the internal __econtext__. If <code><phrase role="identifier">StackAllocator</phrase></code> is not explicitly passed, the default stack allocator depends on <code><phrase role="identifier">BOOST_USE_SEGMENTED_STACKS</phrase></code>: if defined, you will get a <link linkend="class_segmented_stack"><code>segmented_stack</code></link>, else a <link linkend="class_fixedsize_stack"><code>fixedsize_stack</code></link>. </para> </listitem> </varlistentry> <varlistentry> <term>See also:</term> <listitem> <para> <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">allocator_arg_t</phrase></code></ulink>, <link linkend="stack">Stack allocation</link> </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect4" id="fiber.fiber_mgmt.fiber.h2"> <phrase id="fiber.fiber_mgmt.fiber.move_constructor"/><link linkend="fiber.fiber_mgmt.fiber.move_constructor">Move constructor</link> </bridgehead> <programlisting><phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <phrase role="identifier">fiber</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Transfers ownership of the fiber managed by <code><phrase role="identifier">other</phrase></code> to the newly constructed <link linkend="class_fiber"><code>fiber</code></link> instance. </para> </listitem> </varlistentry> <varlistentry> <term>Postconditions:</term> <listitem> <para> <code><phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase><phrase role="special">()</phrase></code> and <code><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code> returns the value of <code><phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code> prior to the construction </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect4" id="fiber.fiber_mgmt.fiber.h3"> <phrase id="fiber.fiber_mgmt.fiber.move_assignment_operator"/><link linkend="fiber.fiber_mgmt.fiber.move_assignment_operator">Move assignment operator</link> </bridgehead> <programlisting><phrase role="identifier">fiber</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">fiber</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Transfers ownership of the fiber managed by <code><phrase role="identifier">other</phrase></code> (if any) to <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Postconditions:</term> <listitem> <para> <code><phrase role="identifier">other</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase><phrase role="special">()</phrase></code> and <code><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code> returns the value of <code><phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code> prior to the assignment. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect4" id="fiber.fiber_mgmt.fiber.h4"> <phrase id="fiber.fiber_mgmt.fiber.destructor"/><link linkend="fiber.fiber_mgmt.fiber.destructor">Destructor</link> </bridgehead> <programlisting><phrase role="special">~</phrase><phrase role="identifier">fiber</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> If the fiber is <link linkend="fiber_joinable"><code>fiber::joinable()</code></link>, calls std::terminate. Destroys <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> The programmer must ensure that the destructor is never executed while the fiber is still <link linkend="fiber_joinable"><code>fiber::joinable()</code></link>. Even if you know that the fiber has completed, you must still call either <link linkend="fiber_join"><code>fiber::join()</code></link> or <link linkend="fiber_detach"><code>fiber::detach()</code></link> before destroying the <code><phrase role="identifier">fiber</phrase></code> object. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="fiber_joinable_bridgehead"> <phrase id="fiber_joinable"/> <link linkend="fiber_joinable">Member function <code>joinable</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="identifier">joinable</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> refers to a fiber of execution, which may or may not have completed; otherwise <code><phrase role="keyword">false</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="fiber_join_bridgehead"> <phrase id="fiber_join"/> <link linkend="fiber_join">Member function <code>join</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">join</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Preconditions:</term> <listitem> <para> the fiber is <link linkend="fiber_joinable"><code>fiber::joinable()</code></link>. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Waits for the referenced fiber of execution to complete. </para> </listitem> </varlistentry> <varlistentry> <term>Postconditions:</term> <listitem> <para> The fiber of execution referenced on entry has completed. <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> no longer refers to any fiber of execution. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">fiber_error</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Error Conditions:</term> <listitem> <para> <emphasis role="bold">resource_deadlock_would_occur</emphasis>: if <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code>. <emphasis role="bold">invalid_argument</emphasis>: if the fiber is not <link linkend="fiber_joinable"><code>fiber::joinable()</code></link>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="fiber_detach_bridgehead"> <phrase id="fiber_detach"/> <link linkend="fiber_detach">Member function <code>detach</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">detach</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Preconditions:</term> <listitem> <para> the fiber is <link linkend="fiber_joinable"><code>fiber::joinable()</code></link>. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> The fiber of execution becomes detached, and no longer has an associated <link linkend="class_fiber"><code>fiber</code></link> object. </para> </listitem> </varlistentry> <varlistentry> <term>Postconditions:</term> <listitem> <para> <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> no longer refers to any fiber of execution. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">fiber_error</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Error Conditions:</term> <listitem> <para> <emphasis role="bold">invalid_argument</emphasis>: if the fiber is not <link linkend="fiber_joinable"><code>fiber::joinable()</code></link>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="fiber_get_id_bridgehead"> <phrase id="fiber_get_id"/> <link linkend="fiber_get_id">Member function <code>get_id</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase> <phrase role="identifier">get_id</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> If <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> refers to a fiber of execution, an instance of <link linkend="class_fiber_id"><code><phrase role="identifier">fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase></code></link> that represents that fiber. Otherwise returns a default-constructed <link linkend="class_fiber_id"><code><phrase role="identifier">fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase></code></link>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> <varlistentry> <term>See also:</term> <listitem> <para> <link linkend="this_fiber_get_id"><code>this_fiber::get_id()</code></link> </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="fiber_properties_bridgehead"> <phrase id="fiber_properties"/> <link linkend="fiber_properties">Templated member function <code>properties</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">PROPS</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">PROPS</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">properties</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Preconditions:</term> <listitem> <para> <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> refers to a fiber of execution. <link linkend="use_scheduling_algorithm"><code>use_scheduling_algorithm()</code></link> has been called from this thread with a subclass of <link linkend="class_algorithm_with_properties"><code>algorithm_with_properties&lt;&gt;</code></link> with the same template argument <code><phrase role="identifier">PROPS</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> a reference to the scheduler properties instance for <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">bad_cast</phrase></code> if <code><phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">()</phrase></code> was called with a <code><phrase role="identifier">algorithm_with_properties</phrase></code> subclass with some other template parameter than <code><phrase role="identifier">PROPS</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> <link linkend="class_algorithm_with_properties"><code>algorithm_with_properties&lt;&gt;</code></link> provides a way for a user-coded scheduler to associate extended properties, such as priority, with a fiber instance. This method allows access to those user-provided properties. </para> </listitem> </varlistentry> <varlistentry> <term>See also:</term> <listitem> <para> <link linkend="custom">Customization</link> </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="fiber_swap_bridgehead"> <phrase id="fiber_swap"/> <link linkend="fiber_swap">Member function <code>swap</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase> <phrase role="identifier">fiber</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Exchanges the fiber of execution associated with <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> and <code><phrase role="identifier">other</phrase></code>, so <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> becomes associated with the fiber formerly associated with <code><phrase role="identifier">other</phrase></code>, and vice-versa. </para> </listitem> </varlistentry> <varlistentry> <term>Postconditions:</term> <listitem> <para> <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code> returns the same value as <code><phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code> prior to the call. <code><phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code> returns the same value as <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code> prior to the call. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="swap_for_fiber_bridgehead"> <phrase id="swap_for_fiber"/> <link linkend="swap_for_fiber">Non-member function <code>swap()</code></link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase> <phrase role="identifier">fiber</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">l</phrase><phrase role="special">,</phrase> <phrase role="identifier">fiber</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">r</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Same as <code><phrase role="identifier">l</phrase><phrase role="special">.</phrase><phrase role="identifier">swap</phrase><phrase role="special">(</phrase> <phrase role="identifier">r</phrase><phrase role="special">)</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="operator&lt;_bridgehead"> <phrase id="operator&lt;"/> <link linkend="operator&lt;">Non-member function <code>operator&lt;()</code></link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">&lt;(</phrase> <phrase role="identifier">fiber</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">l</phrase><phrase role="special">,</phrase> <phrase role="identifier">fiber</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">r</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if <code><phrase role="identifier">l</phrase><phrase role="special">.</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">r</phrase><phrase role="special">.</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code> is <code><phrase role="keyword">true</phrase></code>, false otherwise. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="use_scheduling_algorithm_bridgehead"> <phrase id="use_scheduling_algorithm"/> <link linkend="use_scheduling_algorithm">Non-member function <code>use_scheduling_algorithm()</code></link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">SchedAlgo</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">(</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">args</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Directs <emphasis role="bold">Boost.Fiber</emphasis> to use <code><phrase role="identifier">SchedAlgo</phrase></code>, which must be a concrete subclass of <link linkend="class_algorithm"><code>algorithm</code></link>, as the scheduling algorithm for all fibers in the current thread. Pass any required <code><phrase role="identifier">SchedAlgo</phrase></code> constructor arguments as <code><phrase role="identifier">args</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> If you want a given thread to use a non-default scheduling algorithm, make that thread call <code><phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">()</phrase></code> before any other <emphasis role="bold">Boost.Fiber</emphasis> entry point. If no scheduler has been set for the current thread by the time <emphasis role="bold">Boost.Fiber</emphasis> needs to use it, the library will create a default <link linkend="class_round_robin"><code>round_robin</code></link> instance for this thread. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> <varlistentry> <term>See also:</term> <listitem> <para> <link linkend="scheduling">Scheduling</link>, <link linkend="custom">Customization</link> </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="has_ready_fibers_bridgehead"> <phrase id="has_ready_fibers"/> <link linkend="has_ready_fibers">Non-member function <code>has_ready_fibers()</code></link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="identifier">has_ready_fibers</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if scheduler has fibers ready to run. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> Can be used for work-stealing to find an idle scheduler. </para> </listitem> </varlistentry> </variablelist> </section> <section id="fiber.fiber_mgmt.id"> <title><anchor id="class_id"/><link linkend="fiber.fiber_mgmt.id">Class fiber::id</link></title> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">id</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="keyword">constexpr</phrase> <phrase role="identifier">id</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">==(</phrase> <phrase role="identifier">id</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">!=(</phrase> <phrase role="identifier">id</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">&lt;(</phrase> <phrase role="identifier">id</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">&gt;(</phrase> <phrase role="identifier">id</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">&lt;=(</phrase> <phrase role="identifier">id</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">&gt;=(</phrase> <phrase role="identifier">id</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">charT</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">traitsT</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">friend</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">basic_ostream</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">charT</phrase><phrase role="special">,</phrase> <phrase role="identifier">traitsT</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">&lt;&lt;(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">basic_ostream</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">charT</phrase><phrase role="special">,</phrase> <phrase role="identifier">traitsT</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;,</phrase> <phrase role="identifier">id</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;);</phrase> <phrase role="special">};</phrase> <phrase role="special">}}</phrase> </programlisting> <bridgehead renderas="sect4" id="fiber.fiber_mgmt.id.h0"> <phrase id="fiber.fiber_mgmt.id.constructor"/><link linkend="fiber.fiber_mgmt.id.constructor">Constructor</link> </bridgehead> <programlisting><phrase role="keyword">constexpr</phrase> <phrase role="identifier">id</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Represents an instance of <emphasis>not-a-fiber</emphasis>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="id_operator_equal_bridgehead"> <phrase id="id_operator_equal"/> <link linkend="id_operator_equal">Member function <code>operator==</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">==(</phrase> <phrase role="identifier">id</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> and <code><phrase role="identifier">other</phrase></code> represent the same fiber, or both represent <emphasis>not-a-fiber</emphasis>, <code><phrase role="keyword">false</phrase></code> otherwise. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="id_operator_not_equal_bridgehead"> <phrase id="id_operator_not_equal"/> <link linkend="id_operator_not_equal">Member function <code>operator!=</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">!=(</phrase> <phrase role="identifier">id</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code>! (other == * this)</code> </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="id_operator_less_bridgehead"> <phrase id="id_operator_less"/> <link linkend="id_operator_less">Member function <code>operator&lt;</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">&lt;(</phrase> <phrase role="identifier">id</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">other</phrase></code> is true and the implementation-defined total order of <code><phrase role="identifier">fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase></code> values places <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> before <code><phrase role="identifier">other</phrase></code>, false otherwise. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="id_operator_greater_bridgehead"> <phrase id="id_operator_greater"/> <link linkend="id_operator_greater">Member function <code>operator&gt;</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">&gt;(</phrase> <phrase role="identifier">id</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="identifier">other</phrase> <phrase role="special">&lt;</phrase> <phrase role="special">*</phrase> <phrase role="keyword">this</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="id_operator_less_equal_bridgehead"> <phrase id="id_operator_less_equal"/> <link linkend="id_operator_less_equal">Member function <code>operator&lt;=</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">&lt;=(</phrase> <phrase role="identifier">id</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="special">!</phrase> <phrase role="special">(</phrase><phrase role="identifier">other</phrase> <phrase role="special">&lt;</phrase> <phrase role="special">*</phrase> <phrase role="keyword">this</phrase><phrase role="special">)</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="id_operator_greater_equal_bridgehead"> <phrase id="id_operator_greater_equal"/> <link linkend="id_operator_greater_equal">Member function <code>operator&gt;=</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">&gt;=(</phrase> <phrase role="identifier">id</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="special">!</phrase> <phrase role="special">(*</phrase> <phrase role="keyword">this</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect4" id="fiber.fiber_mgmt.id.h1"> <phrase id="fiber.fiber_mgmt.id.operator_lt__lt_"/><link linkend="fiber.fiber_mgmt.id.operator_lt__lt_">operator&lt;&lt;</link> </bridgehead> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">charT</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">traitsT</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">basic_ostream</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">charT</phrase><phrase role="special">,</phrase> <phrase role="identifier">traitsT</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">&lt;&lt;(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">basic_ostream</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">charT</phrase><phrase role="special">,</phrase> <phrase role="identifier">traitsT</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">os</phrase><phrase role="special">,</phrase> <phrase role="identifier">id</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Efects:</term> <listitem> <para> Writes the representation of <code><phrase role="identifier">other</phrase></code> to stream <code><phrase role="identifier">os</phrase></code>. The representation is unspecified. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="identifier">os</phrase></code> </para> </listitem> </varlistentry> </variablelist> </section> <section id="fiber.fiber_mgmt.this_fiber"> <title><link linkend="fiber.fiber_mgmt.this_fiber">Namespace this_fiber</link></title> <para> In general, <code><phrase role="identifier">this_fiber</phrase></code> operations may be called from the <quote>main</quote> fiber &mdash; the fiber on which function <code><phrase role="identifier">main</phrase><phrase role="special">()</phrase></code> is entered &mdash; as well as from an explicitly-launched thread&#8217;s thread-function. That is, in many respects the main fiber on each thread can be treated like an explicitly-launched fiber. </para> <programlisting><phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">this_fiber</phrase> <phrase role="special">{</phrase> <phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase> <phrase role="identifier">get_id</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">yield</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">sleep_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">sleep_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">PROPS</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">PROPS</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">properties</phrase><phrase role="special">();</phrase> <phrase role="special">}}</phrase> </programlisting> <para> <bridgehead renderas="sect4" id="this_fiber_get_id_bridgehead"> <phrase id="this_fiber_get_id"/> <link linkend="this_fiber_get_id">Non-member function <code>this_fiber::get_id()</code></link> </bridgehead> </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">operations</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="identifier">fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase> <phrase role="identifier">get_id</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="special">}}</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> An instance of <link linkend="class_fiber_id"><code><phrase role="identifier">fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase></code></link> that represents the currently executing fiber. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="this_fiber_sleep_until_bridgehead"> <phrase id="this_fiber_sleep_until"/> <link linkend="this_fiber_sleep_until">Non-member function <code>this_fiber::sleep_until()</code></link> </bridgehead> </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">operations</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">sleep_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">abs_time</phrase><phrase role="special">);</phrase> <phrase role="special">}}</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Suspends the current fiber until the time point specified by <code><phrase role="identifier">abs_time</phrase></code> has been reached. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> timeout-related exceptions. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> The current fiber will not resume before <code><phrase role="identifier">abs_time</phrase></code>, but there are no guarantees about how soon after <code><phrase role="identifier">abs_time</phrase></code> it might resume. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> <quote>timeout-related exceptions</quote> are as defined in the C++ Standard, section <emphasis role="bold">30.2.4 Timing specifications [thread.req.timing]</emphasis>: <quote>A function that takes an argument which specifies a timeout will throw if, during its execution, a clock, time point, or time duration throws an exception. Such exceptions are referred to as <emphasis>timeout-related exceptions.</emphasis></quote> </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="this_fiber_sleep_for_bridgehead"> <phrase id="this_fiber_sleep_for"/> <link linkend="this_fiber_sleep_for">Non-member function <code>this_fiber::sleep_for()</code></link> </bridgehead> </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">operations</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">sleep_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">rel_time</phrase><phrase role="special">);</phrase> <phrase role="special">}}</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Suspends the current fiber until the time duration specified by <code><phrase role="identifier">rel_time</phrase></code> has elapsed. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> timeout-related exceptions. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> The current fiber will not resume before <code><phrase role="identifier">rel_time</phrase></code> has elapsed, but there are no guarantees about how soon after that it might resume. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="this_fiber_yield_bridgehead"> <phrase id="this_fiber_yield"/> <link linkend="this_fiber_yield">Non-member function <code>this_fiber::yield()</code></link> </bridgehead> </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">operations</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">yield</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="special">}}</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Relinquishes execution control, allowing other fibers to run. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> A fiber that calls <code><phrase role="identifier">yield</phrase><phrase role="special">()</phrase></code> is not suspended: it is immediately passed to the scheduler as ready to run. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="this_fiber_properties_bridgehead"> <phrase id="this_fiber_properties"/> <link linkend="this_fiber_properties">Non-member function <code>this_fiber::properties()</code></link> </bridgehead> </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">operations</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">PROPS</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">PROPS</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">properties</phrase><phrase role="special">();</phrase> <phrase role="special">}}</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Preconditions:</term> <listitem> <para> <link linkend="use_scheduling_algorithm"><code>use_scheduling_algorithm()</code></link> has been called from this thread with a subclass of <link linkend="class_algorithm_with_properties"><code>algorithm_with_properties&lt;&gt;</code></link> with the same template argument <code><phrase role="identifier">PROPS</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> a reference to the scheduler properties instance for the currently running fiber. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">bad_cast</phrase></code> if <code><phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">()</phrase></code> was called with an <code><phrase role="identifier">algorithm_with_properties</phrase></code> subclass with some other template parameter than <code><phrase role="identifier">PROPS</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> <link linkend="class_algorithm_with_properties"><code>algorithm_with_properties&lt;&gt;</code></link> provides a way for a user-coded scheduler to associate extended properties, such as priority, with a fiber instance. This function allows access to those user-provided properties. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> The first time this function is called from the main fiber of a thread, it may internally yield, permitting other fibers to run. </para> </listitem> </varlistentry> <varlistentry> <term>See also:</term> <listitem> <para> <link linkend="custom">Customization</link> </para> </listitem> </varlistentry> </variablelist> </section> </section> <section id="fiber.scheduling"> <title><anchor id="scheduling"/><link linkend="fiber.scheduling">Scheduling</link></title> <para> The fibers in a thread are coordinated by a fiber manager. Fibers trade control cooperatively, rather than preemptively: the currently-running fiber retains control until it invokes some operation that passes control to the manager. Each time a fiber suspends (or yields), the fiber manager consults a scheduler to determine which fiber will run next. </para> <para> <emphasis role="bold">Boost.Fiber</emphasis> provides the fiber manager, but the scheduler is a customization point. (See <link linkend="custom">Customization</link>.) </para> <para> Each thread has its own scheduler. Different threads in a process may use different schedulers. By default, <emphasis role="bold">Boost.Fiber</emphasis> implicitly instantiates <link linkend="class_round_robin"><code>round_robin</code></link> as the scheduler for each thread. </para> <para> You are explicitly permitted to code your own <link linkend="class_algorithm"><code>algorithm</code></link> subclass. For the most part, your <code><phrase role="identifier">algorithm</phrase></code> subclass need not defend against cross-thread calls: the fiber manager intercepts and defers such calls. Most <code><phrase role="identifier">algorithm</phrase></code> methods are only ever directly called from the thread whose fibers it is managing &mdash; with exceptions as documented below. </para> <para> Your <code><phrase role="identifier">algorithm</phrase></code> subclass is engaged on a particular thread by calling <link linkend="use_scheduling_algorithm"><code>use_scheduling_algorithm()</code></link>: </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">thread_fn</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">my_fiber_scheduler</phrase> <phrase role="special">&gt;();</phrase> <phrase role="special">...</phrase> <phrase role="special">}</phrase> </programlisting> <para> A scheduler class must implement interface <link linkend="class_algorithm"><code>algorithm</code></link>. <emphasis role="bold">Boost.Fiber</emphasis> provides schedulers: <link linkend="class_round_robin"><code>round_robin</code></link>, <link linkend="class_work_stealing"><code>work_stealing</code></link>, <link linkend="class_numa_work_stealing"><code>numa::work_stealing</code></link> and <link linkend="class_shared_work"><code>shared_work</code></link>. </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">thread</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase> <phrase role="identifier">thread_count</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// thread registers itself at work-stealing scheduler</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">algo</phrase><phrase role="special">::</phrase><phrase role="identifier">work_stealing</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">thread_count</phrase><phrase role="special">);</phrase> <phrase role="special">...</phrase> <phrase role="special">}</phrase> <phrase role="comment">// count of logical cpus</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase> <phrase role="identifier">thread_count</phrase> <phrase role="special">=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">thread</phrase><phrase role="special">::</phrase><phrase role="identifier">hardware_concurrency</phrase><phrase role="special">();</phrase> <phrase role="comment">// start-thread registers itself at work-stealing scheduler</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">algo</phrase><phrase role="special">::</phrase><phrase role="identifier">work_stealing</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">thread_count</phrase><phrase role="special">);</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">thread</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">threads</phrase><phrase role="special">;</phrase> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">1</phrase> <phrase role="comment">/* count start-thread */</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">thread_count</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// spawn thread</phrase> <phrase role="identifier">threads</phrase><phrase role="special">.</phrase><phrase role="identifier">emplace_back</phrase><phrase role="special">(</phrase> <phrase role="identifier">thread</phrase><phrase role="special">,</phrase> <phrase role="identifier">thread_count</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="special">...</phrase> </programlisting> <para> The example spawns as many threads as <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">thread</phrase><phrase role="special">::</phrase><phrase role="identifier">hardware_concurrency</phrase><phrase role="special">()</phrase></code> returns. Each thread runs a <link linkend="class_work_stealing"><code>work_stealing</code></link> scheduler. Each instance of this scheduler needs to know how many threads run the work-stealing scheduler in the program. If the local queue of one thread runs out of ready fibers, the thread tries to steal a ready fiber from another thread running this scheduler. </para> <para> <bridgehead renderas="sect4" id="class_algorithm_bridgehead"> <phrase id="class_algorithm"/> <link linkend="class_algorithm">Class <code>algorithm</code></link> </bridgehead> </para> <para> <code><phrase role="identifier">algorithm</phrase></code> is the abstract base class defining the interface that a fiber scheduler must implement. </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">algo</phrase><phrase role="special">/</phrase><phrase role="identifier">algorithm</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">algo</phrase> <phrase role="special">{</phrase> <phrase role="keyword">struct</phrase> <phrase role="identifier">algorithm</phrase> <phrase role="special">{</phrase> <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">algorithm</phrase><phrase role="special">();</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">awakened</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*)</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">pick_next</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">has_ready_fibers</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">suspend_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">steady_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">notify</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> <phrase role="special">}}}</phrase> </programlisting> <para> <bridgehead renderas="sect4" id="algorithm_awakened_bridgehead"> <phrase id="algorithm_awakened"/> <link linkend="algorithm_awakened">Member function <code>awakened</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">awakened</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">f</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Informs the scheduler that fiber <code><phrase role="identifier">f</phrase></code> is ready to run. Fiber <code><phrase role="identifier">f</phrase></code> might be newly launched, or it might have been blocked but has just been awakened, or it might have called <link linkend="this_fiber_yield"><code>this_fiber::yield()</code></link>. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> This method advises the scheduler to add fiber <code><phrase role="identifier">f</phrase></code> to its collection of fibers ready to run. A typical scheduler implementation places <code><phrase role="identifier">f</phrase></code> into a queue. </para> </listitem> </varlistentry> <varlistentry> <term>See also:</term> <listitem> <para> <link linkend="class_round_robin"><code>round_robin</code></link> </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="algorithm_pick_next_bridgehead"> <phrase id="algorithm_pick_next"/> <link linkend="algorithm_pick_next">Member function <code>pick_next</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">pick_next</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> the fiber which is to be resumed next, or <code><phrase role="keyword">nullptr</phrase></code> if there is no ready fiber. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> This is where the scheduler actually specifies the fiber which is to run next. A typical scheduler implementation chooses the head of the ready queue. </para> </listitem> </varlistentry> <varlistentry> <term>See also:</term> <listitem> <para> <link linkend="class_round_robin"><code>round_robin</code></link> </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="algorithm_has_ready_fibers_bridgehead"> <phrase id="algorithm_has_ready_fibers"/> <link linkend="algorithm_has_ready_fibers">Member function <code>has_ready_fibers</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">has_ready_fibers</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if scheduler has fibers ready to run. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="algorithm_suspend_until_bridgehead"> <phrase id="algorithm_suspend_until"/> <link linkend="algorithm_suspend_until">Member function <code>suspend_until</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">suspend_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">steady_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">abs_time</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Informs the scheduler that no fiber will be ready until time-point <code><phrase role="identifier">abs_time</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> This method allows a custom scheduler to yield control to the containing environment in whatever way makes sense. The fiber manager is stating that <code><phrase role="identifier">suspend_until</phrase><phrase role="special">()</phrase></code> need not return until <code><phrase role="identifier">abs_time</phrase></code> &mdash; or <link linkend="algorithm_notify"><code>algorithm::notify()</code></link> is called &mdash; whichever comes first. The interaction with <code><phrase role="identifier">notify</phrase><phrase role="special">()</phrase></code> means that, for instance, calling <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase role="identifier">sleep_until</phrase><phrase role="special">(</phrase><phrase role="identifier">abs_time</phrase><phrase role="special">)</phrase></code></ulink> would be too simplistic. <link linkend="round_robin_suspend_until"><code>round_robin::suspend_until()</code></link> uses a <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_variable</phrase></code></ulink> to coordinate with <link linkend="round_robin_notify"><code>round_robin::notify()</code></link>. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> Given that <code><phrase role="identifier">notify</phrase><phrase role="special">()</phrase></code> might be called from another thread, your <code><phrase role="identifier">suspend_until</phrase><phrase role="special">()</phrase></code> implementation &mdash; like the rest of your <code><phrase role="identifier">algorithm</phrase></code> implementation &mdash; must guard any data it shares with your <code><phrase role="identifier">notify</phrase><phrase role="special">()</phrase></code> implementation. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="algorithm_notify_bridgehead"> <phrase id="algorithm_notify"/> <link linkend="algorithm_notify">Member function <code>notify</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">notify</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Requests the scheduler to return from a pending call to <link linkend="algorithm_suspend_until"><code>algorithm::suspend_until()</code></link>. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> Alone among the <code><phrase role="identifier">algorithm</phrase></code> methods, <code><phrase role="identifier">notify</phrase><phrase role="special">()</phrase></code> may be called from another thread. Your <code><phrase role="identifier">notify</phrase><phrase role="special">()</phrase></code> implementation must guard any data it shares with the rest of your <code><phrase role="identifier">algorithm</phrase></code> implementation. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="class_round_robin_bridgehead"> <phrase id="class_round_robin"/> <link linkend="class_round_robin">Class <code>round_robin</code></link> </bridgehead> </para> <para> This class implements <link linkend="class_algorithm"><code>algorithm</code></link>, scheduling fibers in round-robin fashion. </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">algo</phrase><phrase role="special">/</phrase><phrase role="identifier">round_robin</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">algo</phrase> <phrase role="special">{</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">round_robin</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">algorithm</phrase> <phrase role="special">{</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">awakened</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">pick_next</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">has_ready_fibers</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">suspend_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">steady_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">notify</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> <phrase role="special">}}}</phrase> </programlisting> <para> <bridgehead renderas="sect4" id="round_robin_awakened_bridgehead"> <phrase id="round_robin_awakened"/> <link linkend="round_robin_awakened">Member function <code>awakened</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">awakened</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">f</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Enqueues fiber <code><phrase role="identifier">f</phrase></code> onto a ready queue. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="round_robin_pick_next_bridgehead"> <phrase id="round_robin_pick_next"/> <link linkend="round_robin_pick_next">Member function <code>pick_next</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">pick_next</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> the fiber at the head of the ready queue, or <code><phrase role="keyword">nullptr</phrase></code> if the queue is empty. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> Placing ready fibers onto the tail of a queue, and returning them from the head of that queue, shares the thread between ready fibers in round-robin fashion. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="round_robin_has_ready_fibers_bridgehead"> <phrase id="round_robin_has_ready_fibers"/> <link linkend="round_robin_has_ready_fibers">Member function <code>has_ready_fibers</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">has_ready_fibers</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if scheduler has fibers ready to run. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="round_robin_suspend_until_bridgehead"> <phrase id="round_robin_suspend_until"/> <link linkend="round_robin_suspend_until">Member function <code>suspend_until</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">suspend_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">steady_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">abs_time</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Informs <code><phrase role="identifier">round_robin</phrase></code> that no ready fiber will be available until time-point <code><phrase role="identifier">abs_time</phrase></code>. This implementation blocks in <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_variable</phrase><phrase role="special">::</phrase><phrase role="identifier">wait_until</phrase><phrase role="special">()</phrase></code></ulink>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="round_robin_notify_bridgehead"> <phrase id="round_robin_notify"/> <link linkend="round_robin_notify">Member function <code>notify</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">notify</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Wake up a pending call to <link linkend="round_robin_suspend_until"><code>round_robin::suspend_until()</code></link>, some fibers might be ready. This implementation wakes <code><phrase role="identifier">suspend_until</phrase><phrase role="special">()</phrase></code> via <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_variable</phrase><phrase role="special">::</phrase><phrase role="identifier">notify_all</phrase><phrase role="special">()</phrase></code></ulink>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="class_work_stealing_bridgehead"> <phrase id="class_work_stealing"/> <link linkend="class_work_stealing">Class <code>work_stealing</code></link> </bridgehead> </para> <para> This class implements <link linkend="class_algorithm"><code>algorithm</code></link>; if the local ready-queue runs out of ready fibers, ready fibers are stolen from other schedulers.<sbr/> The victim scheduler (from which a ready fiber is stolen) is selected at random. </para> <note> <para> Worker-threads are stored in a static variable, dynamically adding/removing worker threads is not supported. </para> </note> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">algo</phrase><phrase role="special">/</phrase><phrase role="identifier">work_stealing</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">algo</phrase> <phrase role="special">{</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">work_stealing</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">algorithm</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="identifier">work_stealing</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase> <phrase role="identifier">thread_count</phrase><phrase role="special">,</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">suspend</phrase> <phrase role="special">=</phrase> <phrase role="keyword">false</phrase><phrase role="special">);</phrase> <phrase role="identifier">work_stealing</phrase><phrase role="special">(</phrase> <phrase role="identifier">work_stealing</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">work_stealing</phrase><phrase role="special">(</phrase> <phrase role="identifier">work_stealing</phrase> <phrase role="special">&amp;&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">work_stealing</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">work_stealing</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">work_stealing</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">work_stealing</phrase> <phrase role="special">&amp;&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">awakened</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">pick_next</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">has_ready_fibers</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">suspend_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">steady_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">notify</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> <phrase role="special">}}}</phrase> </programlisting> <bridgehead renderas="sect3" id="fiber.scheduling.h0"> <phrase id="fiber.scheduling.constructor"/><link linkend="fiber.scheduling.constructor">Constructor</link> </bridgehead> <programlisting><phrase role="identifier">work_stealing</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase> <phrase role="identifier">thread_count</phrase><phrase role="special">,</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">suspend</phrase> <phrase role="special">=</phrase> <phrase role="keyword">false</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Constructs work-stealing scheduling algorithm. <code><phrase role="identifier">thread_count</phrase></code> represents the number of threads running this algorithm. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">system_error</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> If <code><phrase role="identifier">suspend</phrase></code> is set to <code><phrase role="keyword">true</phrase></code>, then the scheduler suspends if no ready fiber could be stolen. The scheduler will by woken up if a sleeping fiber times out or it was notified from remote (other thread or fiber scheduler). </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="work_stealing_awakened_bridgehead"> <phrase id="work_stealing_awakened"/> <link linkend="work_stealing_awakened">Member function <code>awakened</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">awakened</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">f</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Enqueues fiber <code><phrase role="identifier">f</phrase></code> onto the shared ready queue. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="work_stealing_pick_next_bridgehead"> <phrase id="work_stealing_pick_next"/> <link linkend="work_stealing_pick_next">Member function <code>pick_next</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">pick_next</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> the fiber at the head of the ready queue, or <code><phrase role="keyword">nullptr</phrase></code> if the queue is empty. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> Placing ready fibers onto the tail of the sahred queue, and returning them from the head of that queue, shares the thread between ready fibers in round-robin fashion. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="work_stealing_has_ready_fibers_bridgehead"> <phrase id="work_stealing_has_ready_fibers"/> <link linkend="work_stealing_has_ready_fibers">Member function <code>has_ready_fibers</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">has_ready_fibers</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if scheduler has fibers ready to run. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="work_stealing_suspend_until_bridgehead"> <phrase id="work_stealing_suspend_until"/> <link linkend="work_stealing_suspend_until">Member function <code>suspend_until</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">suspend_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">steady_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">abs_time</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Informs <code><phrase role="identifier">work_stealing</phrase></code> that no ready fiber will be available until time-point <code><phrase role="identifier">abs_time</phrase></code>. This implementation blocks in <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_variable</phrase><phrase role="special">::</phrase><phrase role="identifier">wait_until</phrase><phrase role="special">()</phrase></code></ulink>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="work_stealing_notify_bridgehead"> <phrase id="work_stealing_notify"/> <link linkend="work_stealing_notify">Member function <code>notify</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">notify</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Wake up a pending call to <link linkend="work_stealing_suspend_until"><code>work_stealing::suspend_until()</code></link>, some fibers might be ready. This implementation wakes <code><phrase role="identifier">suspend_until</phrase><phrase role="special">()</phrase></code> via <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_variable</phrase><phrase role="special">::</phrase><phrase role="identifier">notify_all</phrase><phrase role="special">()</phrase></code></ulink>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="class_shared_work_bridgehead"> <phrase id="class_shared_work"/> <link linkend="class_shared_work">Class <code>shared_work</code></link> </bridgehead> </para> <note> <para> Because of the non-locality of data, <emphasis>shared_work</emphasis> is less performant than <link linkend="class_work_stealing"><code>work_stealing</code></link>. </para> </note> <para> This class implements <link linkend="class_algorithm"><code>algorithm</code></link>, scheduling fibers in round-robin fashion. Ready fibers are shared between all instances (running on different threads) of shared_work, thus the work is distributed equally over all threads. </para> <note> <para> Worker-threads are stored in a static variable, dynamically adding/removing worker threads is not supported. </para> </note> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">algo</phrase><phrase role="special">/</phrase><phrase role="identifier">shared_work</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">algo</phrase> <phrase role="special">{</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">shared_work</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">algorithm</phrase> <phrase role="special">{</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">awakened</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">pick_next</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">has_ready_fibers</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">suspend_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">steady_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">notify</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> <phrase role="special">}}}</phrase> </programlisting> <para> <bridgehead renderas="sect4" id="shared_work_awakened_bridgehead"> <phrase id="shared_work_awakened"/> <link linkend="shared_work_awakened">Member function <code>awakened</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">awakened</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">f</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Enqueues fiber <code><phrase role="identifier">f</phrase></code> onto the shared ready queue. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="shared_work_pick_next_bridgehead"> <phrase id="shared_work_pick_next"/> <link linkend="shared_work_pick_next">Member function <code>pick_next</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">pick_next</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> the fiber at the head of the ready queue, or <code><phrase role="keyword">nullptr</phrase></code> if the queue is empty. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> Placing ready fibers onto the tail of the shared queue, and returning them from the head of that queue, shares the thread between ready fibers in round-robin fashion. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="shared_work_has_ready_fibers_bridgehead"> <phrase id="shared_work_has_ready_fibers"/> <link linkend="shared_work_has_ready_fibers">Member function <code>has_ready_fibers</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">has_ready_fibers</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if scheduler has fibers ready to run. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="shared_work_suspend_until_bridgehead"> <phrase id="shared_work_suspend_until"/> <link linkend="shared_work_suspend_until">Member function <code>suspend_until</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">suspend_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">steady_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">abs_time</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Informs <code><phrase role="identifier">shared_work</phrase></code> that no ready fiber will be available until time-point <code><phrase role="identifier">abs_time</phrase></code>. This implementation blocks in <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_variable</phrase><phrase role="special">::</phrase><phrase role="identifier">wait_until</phrase><phrase role="special">()</phrase></code></ulink>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="shared_work_notify_bridgehead"> <phrase id="shared_work_notify"/> <link linkend="shared_work_notify">Member function <code>notify</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">notify</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Wake up a pending call to <link linkend="shared_work_suspend_until"><code>shared_work::suspend_until()</code></link>, some fibers might be ready. This implementation wakes <code><phrase role="identifier">suspend_until</phrase><phrase role="special">()</phrase></code> via <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_variable</phrase><phrase role="special">::</phrase><phrase role="identifier">notify_all</phrase><phrase role="special">()</phrase></code></ulink>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect3" id="fiber.scheduling.h1"> <phrase id="fiber.scheduling.custom_scheduler_fiber_properties"/><link linkend="fiber.scheduling.custom_scheduler_fiber_properties">Custom Scheduler Fiber Properties</link> </bridgehead> <para> A scheduler class directly derived from <link linkend="class_algorithm"><code>algorithm</code></link> can use any information available from <link linkend="class_context"><code>context</code></link> to implement the <code><phrase role="identifier">algorithm</phrase></code> interface. But a custom scheduler might need to track additional properties for a fiber. For instance, a priority-based scheduler would need to track a fiber&#8217;s priority. </para> <para> <emphasis role="bold">Boost.Fiber</emphasis> provides a mechanism by which your custom scheduler can associate custom properties with each fiber. </para> <para> <bridgehead renderas="sect4" id="class_fiber_properties_bridgehead"> <phrase id="class_fiber_properties"/> <link linkend="class_fiber_properties">Class <code>fiber_properties</code></link> </bridgehead> </para> <para> A custom fiber properties class must be derived from <code><phrase role="identifier">fiber_properties</phrase></code>. </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">properties</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">fiber_properties</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="identifier">fiber_properties</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">fiber_properties</phrase><phrase role="special">();</phrase> <phrase role="keyword">protected</phrase><phrase role="special">:</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">notify</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> <phrase role="special">}}</phrase> </programlisting> <bridgehead renderas="sect3" id="fiber.scheduling.h2"> <phrase id="fiber.scheduling.constructor0"/><link linkend="fiber.scheduling.constructor0">Constructor</link> </bridgehead> <programlisting><phrase role="identifier">fiber_properties</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">f</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Constructs base-class component of custom subclass. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> Your subclass constructor must accept a <code><phrase role="identifier">context</phrase><phrase role="special">*</phrase></code> and pass it to the base-class <code><phrase role="identifier">fiber_properties</phrase></code> constructor. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="fiber_properties_notify_bridgehead"> <phrase id="fiber_properties_notify"/> <link linkend="fiber_properties_notify">Member function <code>notify</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">notify</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Pass control to the custom <link linkend="class_algorithm_with_properties"><code>algorithm_with_properties&lt;&gt;</code></link> subclass&#8217;s <link linkend="algorithm_with_properties_property_change"><code>algorithm_with_properties::property_change()</code></link> method. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> A custom scheduler&#8217;s <link linkend="algorithm_with_properties_pick_next"><code>algorithm_with_properties::pick_next()</code></link> method might dynamically select from the ready fibers, or <link linkend="algorithm_with_properties_awakened"><code>algorithm_with_properties::awakened()</code></link> might instead insert each ready fiber into some form of ready queue for <code><phrase role="identifier">pick_next</phrase><phrase role="special">()</phrase></code>. In the latter case, if application code modifies a fiber property (e.g. priority) that should affect that fiber&#8217;s relationship to other ready fibers, the custom scheduler must be given the opportunity to reorder its ready queue. The custom property subclass should implement an access method to modify such a property; that access method should call <code><phrase role="identifier">notify</phrase><phrase role="special">()</phrase></code> once the new property value has been stored. This passes control to the custom scheduler&#8217;s <code><phrase role="identifier">property_change</phrase><phrase role="special">()</phrase></code> method, allowing the custom scheduler to reorder its ready queue appropriately. Use at your discretion. Of course, if you define a property which does not affect the behavior of the <code><phrase role="identifier">pick_next</phrase><phrase role="special">()</phrase></code> method, you need not call <code><phrase role="identifier">notify</phrase><phrase role="special">()</phrase></code> when that property is modified. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="class_algorithm_with_properties_bridgehead"> <phrase id="class_algorithm_with_properties"/> <link linkend="class_algorithm_with_properties">Template <code>algorithm_with_properties&lt;&gt;</code></link> </bridgehead> </para> <para> A custom scheduler that depends on a custom properties class <code><phrase role="identifier">PROPS</phrase></code> should be derived from <code><phrase role="identifier">algorithm_with_properties</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">PROPS</phrase><phrase role="special">&gt;</phrase></code>. <code><phrase role="identifier">PROPS</phrase></code> should be derived from <link linkend="class_fiber_properties"><code>fiber_properties</code></link>. </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">algorithm</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">algo</phrase> <phrase role="special">{</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">PROPS</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">struct</phrase> <phrase role="identifier">algorithm_with_properties</phrase> <phrase role="special">{</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">awakened</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*,</phrase> <phrase role="identifier">PROPS</phrase> <phrase role="special">&amp;)</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">pick_next</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">has_ready_fibers</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">suspend_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">steady_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">notify</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">PROPS</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">properties</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">property_change</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*,</phrase> <phrase role="identifier">PROPS</phrase> <phrase role="special">&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="identifier">fiber_properties</phrase> <phrase role="special">*</phrase> <phrase role="identifier">new_properties</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*);</phrase> <phrase role="special">};</phrase> <phrase role="special">}}}</phrase> </programlisting> <para> <bridgehead renderas="sect4" id="algorithm_with_properties_awakened_bridgehead"> <phrase id="algorithm_with_properties_awakened"/> <link linkend="algorithm_with_properties_awakened">Member function <code>awakened</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">awakened</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">f</phrase><phrase role="special">,</phrase> <phrase role="identifier">PROPS</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">properties</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Informs the scheduler that fiber <code><phrase role="identifier">f</phrase></code> is ready to run, like <link linkend="algorithm_awakened"><code>algorithm::awakened()</code></link>. Passes the fiber&#8217;s associated <code><phrase role="identifier">PROPS</phrase></code> instance. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> An <code><phrase role="identifier">algorithm_with_properties</phrase><phrase role="special">&lt;&gt;</phrase></code> subclass must override this method instead of <code><phrase role="identifier">algorithm</phrase><phrase role="special">::</phrase><phrase role="identifier">awakened</phrase><phrase role="special">()</phrase></code>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="algorithm_with_properties_pick_next_bridgehead"> <phrase id="algorithm_with_properties_pick_next"/> <link linkend="algorithm_with_properties_pick_next">Member function <code>pick_next</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">pick_next</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> the fiber which is to be resumed next, or <code><phrase role="keyword">nullptr</phrase></code> if there is no ready fiber. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> same as <link linkend="algorithm_pick_next"><code>algorithm::pick_next()</code></link> </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="algorithm_with_properties_has_ready_fibers_bridgehead"> <phrase id="algorithm_with_properties_has_ready_fibers"/> <link linkend="algorithm_with_properties_has_ready_fibers">Member function <code>has_ready_fibers</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">has_ready_fibers</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if scheduler has fibers ready to run. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> same as <link linkend="algorithm_has_ready_fibers"><code>algorithm::has_ready_fibers()</code></link> </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="algorithm_with_properties_suspend_until_bridgehead"> <phrase id="algorithm_with_properties_suspend_until"/> <link linkend="algorithm_with_properties_suspend_until">Member function <code>suspend_until</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">suspend_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">steady_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">abs_time</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Informs the scheduler that no fiber will be ready until time-point <code><phrase role="identifier">abs_time</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> same as <link linkend="algorithm_suspend_until"><code>algorithm::suspend_until()</code></link> </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="algorithm_with_properties_notify_bridgehead"> <phrase id="algorithm_with_properties_notify"/> <link linkend="algorithm_with_properties_notify">Member function <code>notify</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">notify</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Requests the scheduler to return from a pending call to <link linkend="algorithm_with_properties_suspend_until"><code>algorithm_with_properties::suspend_until()</code></link>. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> same as <link linkend="algorithm_notify"><code>algorithm::notify()</code></link> </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="algorithm_with_properties_properties_bridgehead"> <phrase id="algorithm_with_properties_properties"/> <link linkend="algorithm_with_properties_properties">Member function <code>properties</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">PROPS</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">properties</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">f</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> the <code><phrase role="identifier">PROPS</phrase></code> instance associated with fiber <code><phrase role="identifier">f</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> The fiber&#8217;s associated <code><phrase role="identifier">PROPS</phrase></code> instance is already passed to <link linkend="algorithm_with_properties_awakened"><code>algorithm_with_properties::awakened()</code></link> and <link linkend="algorithm_with_properties_property_change"><code>algorithm_with_properties::property_change()</code></link>. However, every <link linkend="class_algorithm"><code>algorithm</code></link> subclass is expected to track a collection of ready <link linkend="class_context"><code>context</code></link> instances. This method allows your custom scheduler to retrieve the <link linkend="class_fiber_properties"><code>fiber_properties</code></link> subclass instance for any <code><phrase role="identifier">context</phrase></code> in its collection. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="algorithm_with_properties_property_change_bridgehead"> <phrase id="algorithm_with_properties_property_change"/> <link linkend="algorithm_with_properties_property_change">Member function <code>property_change</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">property_change</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">f</phrase><phrase role="special">,</phrase> <phrase role="identifier">PROPS</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">properties</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Notify the custom scheduler of a possibly-relevant change to a property belonging to fiber <code><phrase role="identifier">f</phrase></code>. <code><phrase role="identifier">properties</phrase></code> contains the new values of all relevant properties. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> This method is only called when a custom <link linkend="class_fiber_properties"><code>fiber_properties</code></link> subclass explicitly calls <link linkend="fiber_properties_notify"><code>fiber_properties::notify()</code></link>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="algorithm_with_properties_new_properties_bridgehead"> <phrase id="algorithm_with_properties_new_properties"/> <link linkend="algorithm_with_properties_new_properties">Member function <code>new_properties</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="identifier">fiber_properties</phrase> <phrase role="special">*</phrase> <phrase role="identifier">new_properties</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">f</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> A new instance of <link linkend="class_fiber_properties"><code>fiber_properties</code></link> subclass <code><phrase role="identifier">PROPS</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> By default, <code><phrase role="identifier">algorithm_with_properties</phrase><phrase role="special">&lt;&gt;::</phrase><phrase role="identifier">new_properties</phrase><phrase role="special">()</phrase></code> simply returns <code><phrase role="keyword">new</phrase> <phrase role="identifier">PROPS</phrase><phrase role="special">(</phrase><phrase role="identifier">f</phrase><phrase role="special">)</phrase></code>, placing the <code><phrase role="identifier">PROPS</phrase></code> instance on the heap. Override this method to allocate <code><phrase role="identifier">PROPS</phrase></code> some other way. The returned <code><phrase role="identifier">fiber_properties</phrase></code> pointer must point to the <code><phrase role="identifier">PROPS</phrase></code> instance to be associated with fiber <code><phrase role="identifier">f</phrase></code>. </para> </listitem> </varlistentry> </variablelist> <para> <anchor id="context"/><bridgehead renderas="sect4" id="class_context_bridgehead"> <phrase id="class_context"/> <link linkend="class_context">Class <code>context</code></link> </bridgehead> </para> <para> While you are free to treat <code><phrase role="identifier">context</phrase><phrase role="special">*</phrase></code> as an opaque token, certain <code><phrase role="identifier">context</phrase></code> members may be useful to a custom scheduler implementation. </para> <para> <anchor id="ready_queue_t"/>Of particular note is the fact that <code><phrase role="identifier">context</phrase></code> contains a hook to participate in a <ulink url="path_to_url"><code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">intrusive</phrase><phrase role="special">::</phrase><phrase role="identifier">list</phrase></code></ulink> <literal>typedef</literal>&#8217;ed as <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">scheduler</phrase><phrase role="special">::</phrase><phrase role="identifier">ready_queue_t</phrase></code>. This hook is reserved for use by <link linkend="class_algorithm"><code>algorithm</code></link> implementations. (For instance, <link linkend="class_round_robin"><code>round_robin</code></link> contains a <code><phrase role="identifier">ready_queue_t</phrase></code> instance to manage its ready fibers.) See <link linkend="context_ready_is_linked"><code>context::ready_is_linked()</code></link>, <link linkend="context_ready_link"><code>context::ready_link()</code></link>, <link linkend="context_ready_unlink"><code>context::ready_unlink()</code></link>. </para> <para> Your <code><phrase role="identifier">algorithm</phrase></code> implementation may use any container you desire to manage passed <code><phrase role="identifier">context</phrase></code> instances. <code><phrase role="identifier">ready_queue_t</phrase></code> avoids some of the overhead of typical STL containers. </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">context</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">enum</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">type</phrase> <phrase role="special">{</phrase> <phrase role="identifier">none</phrase> <phrase role="special">=</phrase> <emphasis>unspecified</emphasis><phrase role="special">,</phrase> <phrase role="identifier">main_context</phrase> <phrase role="special">=</phrase> <emphasis>unspecified</emphasis><phrase role="special">,</phrase> <phrase role="comment">// fiber associated with thread's stack</phrase> <phrase role="identifier">dispatcher_context</phrase> <phrase role="special">=</phrase> <emphasis>unspecified</emphasis><phrase role="special">,</phrase> <phrase role="comment">// special fiber for maintenance operations</phrase> <phrase role="identifier">worker_context</phrase> <phrase role="special">=</phrase> <emphasis>unspecified</emphasis><phrase role="special">,</phrase> <phrase role="comment">// fiber not special to the library</phrase> <phrase role="identifier">pinned_context</phrase> <phrase role="special">=</phrase> <emphasis>unspecified</emphasis> <phrase role="comment">// fiber must not be migrated to another thread</phrase> <phrase role="special">};</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">context</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">id</phrase><phrase role="special">;</phrase> <phrase role="keyword">static</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">active</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">context</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">context</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">context</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">id</phrase> <phrase role="identifier">get_id</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">detach</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">attach</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">is_context</phrase><phrase role="special">(</phrase> <phrase role="identifier">type</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">is_terminated</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">ready_is_linked</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">remote_ready_is_linked</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">wait_is_linked</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">List</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">ready_link</phrase><phrase role="special">(</phrase> <phrase role="identifier">List</phrase> <phrase role="special">&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">List</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">remote_ready_link</phrase><phrase role="special">(</phrase> <phrase role="identifier">List</phrase> <phrase role="special">&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">List</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">wait_link</phrase><phrase role="special">(</phrase> <phrase role="identifier">List</phrase> <phrase role="special">&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">ready_unlink</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">remote_ready_unlink</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">wait_unlink</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">suspend</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">set_ready</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> <phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">&lt;(</phrase> <phrase role="identifier">context</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">l</phrase><phrase role="special">,</phrase> <phrase role="identifier">context</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">r</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="special">}}</phrase> </programlisting> <para> <bridgehead renderas="sect4" id="context_active_bridgehead"> <phrase id="context_active"/> <link linkend="context_active">Static member function <code>active</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">static</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">active</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> Pointer to instance of current fiber. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="context_get_id_bridgehead"> <phrase id="context_get_id"/> <link linkend="context_get_id">Member function <code>get_id</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">context</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase> <phrase role="identifier">get_id</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> If <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> refers to a fiber of execution, an instance of <link linkend="class_fiber_id"><code><phrase role="identifier">fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase></code></link> that represents that fiber. Otherwise returns a default-constructed <link linkend="class_fiber_id"><code><phrase role="identifier">fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase></code></link>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> <varlistentry> <term>See also:</term> <listitem> <para> <link linkend="fiber_get_id"><code>fiber::get_id()</code></link> </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="context_attach_bridgehead"> <phrase id="context_attach"/> <link linkend="context_attach">Member function <code>attach</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">attach</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">f</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get_scheduler</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="keyword">nullptr</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Attach fiber <code><phrase role="identifier">f</phrase></code> to scheduler running <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Postcondition:</term> <listitem> <para> <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get_scheduler</phrase><phrase role="special">()</phrase> <phrase role="special">!=</phrase> <phrase role="keyword">nullptr</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> A typical call: <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">context</phrase><phrase role="special">::</phrase><phrase role="identifier">active</phrase><phrase role="special">()-&gt;</phrase><phrase role="identifier">attach</phrase><phrase role="special">(</phrase><phrase role="identifier">f</phrase><phrase role="special">);</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> <code><phrase role="identifier">f</phrase></code> must not be the running fiber&#8217;s context. It must not be <link linkend="blocking"><emphasis>blocked</emphasis></link> or terminated. It must not be a <code><phrase role="identifier">pinned_context</phrase></code>. It must be currently detached. It must not currently be linked into an <link linkend="class_algorithm"><code>algorithm</code></link> implementation&#8217;s ready queue. Most of these conditions are implied by <code><phrase role="identifier">f</phrase></code> being owned by an <code><phrase role="identifier">algorithm</phrase></code> implementation: that is, it has been passed to <link linkend="algorithm_awakened"><code>algorithm::awakened()</code></link> but has not yet been returned by <link linkend="algorithm_pick_next"><code>algorithm::pick_next()</code></link>. Typically a <code><phrase role="identifier">pick_next</phrase><phrase role="special">()</phrase></code> implementation would call <code><phrase role="identifier">attach</phrase><phrase role="special">()</phrase></code> with the <code><phrase role="identifier">context</phrase><phrase role="special">*</phrase></code> it is about to return. It must first remove <code><phrase role="identifier">f</phrase></code> from its ready queue. You should never pass a <code><phrase role="identifier">pinned_context</phrase></code> to <code><phrase role="identifier">attach</phrase><phrase role="special">()</phrase></code> because you should never have called its <code><phrase role="identifier">detach</phrase><phrase role="special">()</phrase></code> method in the first place. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="context_detach_bridgehead"> <phrase id="context_detach"/> <link linkend="context_detach">Member function <code>detach</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">detach</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> <code><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get_scheduler</phrase><phrase role="special">()</phrase> <phrase role="special">!=</phrase> <phrase role="keyword">nullptr</phrase><phrase role="special">)</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">!</phrase> <phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">is_context</phrase><phrase role="special">(</phrase><phrase role="identifier">pinned_context</phrase><phrase role="special">)</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Detach fiber <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> from its scheduler running <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> <varlistentry> <term>Postcondition:</term> <listitem> <para> <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get_scheduler</phrase><phrase role="special">()</phrase> <phrase role="special">==</phrase> <phrase role="keyword">nullptr</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> This method must be called on the thread with which the fiber is currently associated. <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> must not be the running fiber&#8217;s context. It must not be <link linkend="blocking"><emphasis>blocked</emphasis></link> or terminated. It must not be a <code><phrase role="identifier">pinned_context</phrase></code>. It must not be detached already. It must not already be linked into an <link linkend="class_algorithm"><code>algorithm</code></link> implementation&#8217;s ready queue. Most of these conditions are implied by <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> being passed to <link linkend="algorithm_awakened"><code>algorithm::awakened()</code></link>; an <code><phrase role="identifier">awakened</phrase><phrase role="special">()</phrase></code> implementation must, however, test for <code><phrase role="identifier">pinned_context</phrase></code>. It must call <code><phrase role="identifier">detach</phrase><phrase role="special">()</phrase></code> <emphasis>before</emphasis> linking <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> into its ready queue. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> In particular, it is erroneous to attempt to migrate a fiber from one thread to another by calling both <code><phrase role="identifier">detach</phrase><phrase role="special">()</phrase></code> and <code><phrase role="identifier">attach</phrase><phrase role="special">()</phrase></code> in the <link linkend="algorithm_pick_next"><code>algorithm::pick_next()</code></link> method. <code><phrase role="identifier">pick_next</phrase><phrase role="special">()</phrase></code> is called on the intended destination thread. <code><phrase role="identifier">detach</phrase><phrase role="special">()</phrase></code> must be called on the fiber&#8217;s original thread. You must call <code><phrase role="identifier">detach</phrase><phrase role="special">()</phrase></code> in the corresponding <code><phrase role="identifier">awakened</phrase><phrase role="special">()</phrase></code> method. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> Unless you intend make a fiber available for potential migration to a different thread, you should call neither <code><phrase role="identifier">detach</phrase><phrase role="special">()</phrase></code> nor <code><phrase role="identifier">attach</phrase><phrase role="special">()</phrase></code> with its <code><phrase role="identifier">context</phrase></code>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="context_is_context_bridgehead"> <phrase id="context_is_context"/> <link linkend="context_is_context">Member function <code>is_context</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="identifier">is_context</phrase><phrase role="special">(</phrase> <phrase role="identifier">type</phrase> <phrase role="identifier">t</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> is of the specified type. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> <code><phrase role="identifier">type</phrase><phrase role="special">::</phrase><phrase role="identifier">worker_context</phrase></code> here means any fiber not special to the library. For <code><phrase role="identifier">type</phrase><phrase role="special">::</phrase><phrase role="identifier">main_context</phrase></code> the <code><phrase role="identifier">context</phrase></code> is associated with the <quote>main</quote> fiber of the thread: the one implicitly created by the thread itself, rather than one explicitly created by <emphasis role="bold">Boost.Fiber</emphasis>. For <code><phrase role="identifier">type</phrase><phrase role="special">::</phrase><phrase role="identifier">dispatcher_context</phrase></code> the <code><phrase role="identifier">context</phrase></code> is associated with a <quote>dispatching</quote> fiber, responsible for dispatching awakened fibers to a scheduler&#8217;s ready-queue. The <quote>dispatching</quote> fiber is an implementation detail of the fiber manager. The context of the <quote>main</quote> or <quote>dispatching</quote> fiber &mdash; any fiber for which <code><phrase role="identifier">is_context</phrase><phrase role="special">(</phrase><phrase role="identifier">pinned_context</phrase><phrase role="special">)</phrase></code> is <code><phrase role="keyword">true</phrase></code> &mdash; must never be passed to <link linkend="context_detach"><code>context::detach()</code></link>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="context_is_terminated_bridgehead"> <phrase id="context_is_terminated"/> <link linkend="context_is_terminated">Member function <code>is_terminated</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="identifier">is_terminated</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> is no longer a valid context. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> The <code><phrase role="identifier">context</phrase></code> has returned from its fiber-function and is no longer considered a valid context. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="context_ready_is_linked_bridgehead"> <phrase id="context_ready_is_linked"/> <link linkend="context_ready_is_linked">Member function <code>ready_is_linked</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="identifier">ready_is_linked</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> is stored in an <link linkend="class_algorithm"><code>algorithm</code></link> implementation&#8217;s ready-queue. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> Specifically, this method indicates whether <link linkend="context_ready_link"><code>context::ready_link()</code></link> has been called on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>. <code><phrase role="identifier">ready_is_linked</phrase><phrase role="special">()</phrase></code> has no information about participation in any other containers. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="context_remote_ready_is_linked_bridgehead"> <phrase id="context_remote_ready_is_linked"/> <link linkend="context_remote_ready_is_linked">Member function <code>remote_ready_is_linked</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="identifier">remote_ready_is_linked</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> is stored in the fiber manager&#8217;s remote-ready-queue. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> A <code><phrase role="identifier">context</phrase></code> signaled as ready by another thread is first stored in the fiber manager&#8217;s remote-ready-queue. This is the mechanism by which the fiber manager protects an <link linkend="class_algorithm"><code>algorithm</code></link> implementation from cross-thread <link linkend="algorithm_awakened"><code>algorithm::awakened()</code></link> calls. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="context_wait_is_linked_bridgehead"> <phrase id="context_wait_is_linked"/> <link linkend="context_wait_is_linked">Member function <code>wait_is_linked</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="identifier">wait_is_linked</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> is stored in the wait-queue of some synchronization object. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> The <code><phrase role="identifier">context</phrase></code> of a fiber waiting on a synchronization object (e.g. <code><phrase role="identifier">mutex</phrase></code>, <code><phrase role="identifier">condition_variable</phrase></code> etc.) is stored in the wait-queue of that synchronization object. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="context_ready_link_bridgehead"> <phrase id="context_ready_link"/> <link linkend="context_ready_link">Member function <code>ready_link</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">List</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">ready_link</phrase><phrase role="special">(</phrase> <phrase role="identifier">List</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">lst</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Stores <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> in ready-queue <code><phrase role="identifier">lst</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> Argument <code><phrase role="identifier">lst</phrase></code> must be a doubly-linked list from <ulink url="path_to_url">Boost.Intrusive</ulink>, e.g. an instance of <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">scheduler</phrase><phrase role="special">::</phrase><phrase role="identifier">ready_queue_t</phrase></code>. Specifically, it must be a <ulink url="path_to_url"><code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">intrusive</phrase><phrase role="special">::</phrase><phrase role="identifier">list</phrase></code></ulink> compatible with the <code><phrase role="identifier">list_member_hook</phrase></code> stored in the <code><phrase role="identifier">context</phrase></code> object. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="context_remote_ready_link_bridgehead"> <phrase id="context_remote_ready_link"/> <link linkend="context_remote_ready_link">Member function <code>remote_ready_link</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">List</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">remote_ready_link</phrase><phrase role="special">(</phrase> <phrase role="identifier">List</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">lst</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Stores <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> in remote-ready-queue <code><phrase role="identifier">lst</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> Argument <code><phrase role="identifier">lst</phrase></code> must be a doubly-linked list from <ulink url="path_to_url">Boost.Intrusive</ulink>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="context_wait_link_bridgehead"> <phrase id="context_wait_link"/> <link linkend="context_wait_link">Member function <code>wait_link</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">List</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">wait_link</phrase><phrase role="special">(</phrase> <phrase role="identifier">List</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">lst</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Stores <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> in wait-queue <code><phrase role="identifier">lst</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> Argument <code><phrase role="identifier">lst</phrase></code> must be a doubly-linked list from <ulink url="path_to_url">Boost.Intrusive</ulink>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="context_ready_unlink_bridgehead"> <phrase id="context_ready_unlink"/> <link linkend="context_ready_unlink">Member function <code>ready_unlink</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">ready_unlink</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Removes <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> from ready-queue: undoes the effect of <link linkend="context_ready_link"><code>context::ready_link()</code></link>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="context_remote_ready_unlink_bridgehead"> <phrase id="context_remote_ready_unlink"/> <link linkend="context_remote_ready_unlink">Member function <code>remote_ready_unlink</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">remote_ready_unlink</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Removes <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> from remote-ready-queue. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="context_wait_unlink_bridgehead"> <phrase id="context_wait_unlink"/> <link linkend="context_wait_unlink">Member function <code>wait_unlink</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">wait_unlink</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Removes <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> from wait-queue. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="context_suspend_bridgehead"> <phrase id="context_suspend"/> <link linkend="context_suspend">Member function <code>suspend</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">suspend</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Suspends the running fiber (the fiber associated with <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>) until some other fiber passes <code><phrase role="keyword">this</phrase></code> to <link linkend="context_set_ready"><code>context::set_ready()</code></link>. <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> is marked as not-ready, and control passes to the scheduler to select another fiber to run. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> This is a low-level API potentially useful for integration with other frameworks. It is not intended to be directly invoked by a typical application program. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> The burden is on the caller to arrange for a call to <code><phrase role="identifier">set_ready</phrase><phrase role="special">()</phrase></code> with a pointer to <code><phrase role="keyword">this</phrase></code> at some future time. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="context_set_ready_bridgehead"> <phrase id="context_set_ready"/> <link linkend="context_set_ready">Member function <code>set_ready</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">set_ready</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">ctx</phrase> <phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Mark the fiber associated with context <code><phrase role="special">*</phrase><phrase role="identifier">ctx</phrase></code> as being ready to run. This does not immediately resume that fiber; rather it passes the fiber to the scheduler for subsequent resumption. If the scheduler is idle (has not returned from a call to <link linkend="algorithm_suspend_until"><code>algorithm::suspend_until()</code></link>), <link linkend="algorithm_notify"><code>algorithm::notify()</code></link> is called to wake it up. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> This is a low-level API potentially useful for integration with other frameworks. It is not intended to be directly invoked by a typical application program. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> It is explicitly supported to call <code><phrase role="identifier">set_ready</phrase><phrase role="special">(</phrase><phrase role="identifier">ctx</phrase><phrase role="special">)</phrase></code> from a thread other than the one on which <code><phrase role="special">*</phrase><phrase role="identifier">ctx</phrase></code> is currently suspended. The corresponding fiber will be resumed on its original thread in due course. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="context_less_bridgehead"> <phrase id="context_less"/> <link linkend="context_less">Non-member function <code>operator&lt;()</code></link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">&lt;(</phrase> <phrase role="identifier">context</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">l</phrase><phrase role="special">,</phrase> <phrase role="identifier">context</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">r</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if <code><phrase role="identifier">l</phrase><phrase role="special">.</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">r</phrase><phrase role="special">.</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code> is <code><phrase role="keyword">true</phrase></code>, <code><phrase role="keyword">false</phrase></code> otherwise. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> </section> <section id="fiber.stack"> <title><anchor id="stack"/><link linkend="fiber.stack">Stack allocation</link></title> <para> A <link linkend="class_fiber"><code>fiber</code></link> uses internally an __econtext__ which manages a set of registers and a stack. The memory used by the stack is allocated/deallocated via a <emphasis>stack_allocator</emphasis> which is required to model a <link linkend="stack_allocator_concept"><emphasis>stack-allocator concept</emphasis></link>. </para> <para> A <emphasis>stack_allocator</emphasis> can be passed to <link linkend="fiber_fiber"><code><phrase role="identifier">fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase><phrase role="special">()</phrase></code></link> or to <link linkend="fibers_async"><code>fibers::async()</code></link>. </para> <anchor id="stack_allocator_concept"/> <bridgehead renderas="sect3" id="fiber.stack.h0"> <phrase id="fiber.stack.stack_allocator_concept"/><link linkend="fiber.stack.stack_allocator_concept">stack-allocator concept</link> </bridgehead> <para> A <emphasis>stack_allocator</emphasis> must satisfy the <emphasis>stack-allocator concept</emphasis> requirements shown in the following table, in which <code><phrase role="identifier">a</phrase></code> is an object of a <emphasis>stack_allocator</emphasis> type, <code><phrase role="identifier">sctx</phrase></code> is a <ulink url="path_to_url"><code><phrase role="identifier">stack_context</phrase></code></ulink>, and <code><phrase role="identifier">size</phrase></code> is a <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase></code>: </para> <informaltable frame="all"> <tgroup cols="3"> <thead> <row> <entry> <para> expression </para> </entry> <entry> <para> return type </para> </entry> <entry> <para> notes </para> </entry> </row> </thead> <tbody> <row> <entry> <para> <code><phrase role="identifier">a</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase><phrase role="special">)</phrase></code> </para> </entry> <entry> </entry> <entry> <para> creates a stack allocator </para> </entry> </row> <row> <entry> <para> <code><phrase role="identifier">a</phrase><phrase role="special">.</phrase><phrase role="identifier">allocate</phrase><phrase role="special">()</phrase></code> </para> </entry> <entry> <para> <ulink url="path_to_url"><code><phrase role="identifier">stack_context</phrase></code></ulink> </para> </entry> <entry> <para> creates a stack </para> </entry> </row> <row> <entry> <para> <code><phrase role="identifier">a</phrase><phrase role="special">.</phrase><phrase role="identifier">deallocate</phrase><phrase role="special">(</phrase> <phrase role="identifier">sctx</phrase><phrase role="special">)</phrase></code> </para> </entry> <entry> <para> <code><phrase role="keyword">void</phrase></code> </para> </entry> <entry> <para> deallocates the stack created by <code><phrase role="identifier">a</phrase><phrase role="special">.</phrase><phrase role="identifier">allocate</phrase><phrase role="special">()</phrase></code> </para> </entry> </row> </tbody> </tgroup> </informaltable> <important> <para> The implementation of <code><phrase role="identifier">allocate</phrase><phrase role="special">()</phrase></code> might include logic to protect against exceeding the context's available stack size rather than leaving it as undefined behaviour. </para> </important> <important> <para> Calling <code><phrase role="identifier">deallocate</phrase><phrase role="special">()</phrase></code> with a <ulink url="path_to_url"><code><phrase role="identifier">stack_context</phrase></code></ulink> not obtained from <code><phrase role="identifier">allocate</phrase><phrase role="special">()</phrase></code> results in undefined behaviour. </para> </important> <note> <para> The memory for the stack is not required to be aligned; alignment takes place inside __econtext__. </para> </note> <para> See also <ulink url="path_to_url">Boost.Context stack allocation</ulink>. In particular, <code><phrase role="identifier">traits_type</phrase></code> methods are as described for <ulink url="path_to_url"><code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">context</phrase><phrase role="special">::</phrase><phrase role="identifier">stack_traits</phrase></code></ulink>. </para> <para> <bridgehead renderas="sect4" id="class_protected_fixedsize_stack_bridgehead"> <phrase id="class_protected_fixedsize_stack"/> <link linkend="class_protected_fixedsize_stack">Class <code>protected_fixedsize_stack</code></link> </bridgehead> </para> <para> <emphasis role="bold">Boost.Fiber</emphasis> provides the class <link linkend="class_protected_fixedsize_stack"><code>protected_fixedsize_stack</code></link> which models the <link linkend="stack_allocator_concept"><emphasis>stack-allocator concept</emphasis></link>. It appends a guard page at the end of each stack to protect against exceeding the stack. If the guard page is accessed (read or write operation) a segmentation fault/access violation is generated by the operating system. </para> <important> <para> Using <link linkend="class_protected_fixedsize_stack"><code>protected_fixedsize_stack</code></link> is expensive. Launching a new fiber with a stack of this type incurs the overhead of setting the memory protection; once allocated, this stack is just as efficient to use as <link linkend="class_fixedsize_stack"><code>fixedsize_stack</code></link>. </para> </important> <note> <para> The appended <code><phrase role="identifier">guard</phrase> <phrase role="identifier">page</phrase></code> is <emphasis role="bold">not</emphasis> mapped to physical memory, only virtual addresses are used. </para> </note> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">protected_fixedsize</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">struct</phrase> <phrase role="identifier">protected_fixedsize</phrase> <phrase role="special">{</phrase> <phrase role="identifier">protected_fixesize</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">size</phrase> <phrase role="special">=</phrase> <phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">default_size</phrase><phrase role="special">());</phrase> <phrase role="identifier">stack_context</phrase> <phrase role="identifier">allocate</phrase><phrase role="special">();</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">deallocate</phrase><phrase role="special">(</phrase> <phrase role="identifier">stack_context</phrase> <phrase role="special">&amp;);</phrase> <phrase role="special">}</phrase> <phrase role="special">}}</phrase> </programlisting> <para> <bridgehead renderas="sect4" id="protected_fixedsize_allocate_bridgehead"> <phrase id="protected_fixedsize_allocate"/> <link linkend="protected_fixedsize_allocate">Member function <code>allocate</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">stack_context</phrase> <phrase role="identifier">allocate</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Preconditions:</term> <listitem> <para> <code><phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">minimum_size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">size</phrase></code> and <code><phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">is_unbounded</phrase><phrase role="special">()</phrase> <phrase role="special">||</phrase> <phrase role="special">(</phrase> <phrase role="identifier">size</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">maximum_size</phrase><phrase role="special">()</phrase> <phrase role="special">)</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Allocates memory of at least <code><phrase role="identifier">size</phrase></code> bytes and stores a pointer to the stack and its actual size in <code><phrase role="identifier">sctx</phrase></code>. Depending on the architecture (the stack grows downwards/upwards) the stored address is the highest/lowest address of the stack. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="protected_fixesize_deallocate_bridgehead"> <phrase id="protected_fixesize_deallocate"/> <link linkend="protected_fixesize_deallocate">Member function <code>deallocate</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">deallocate</phrase><phrase role="special">(</phrase> <phrase role="identifier">stack_context</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">sctx</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Preconditions:</term> <listitem> <para> <code><phrase role="identifier">sctx</phrase><phrase role="special">.</phrase><phrase role="identifier">sp</phrase></code> is valid, <code><phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">minimum_size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">sctx</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase></code> and <code><phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">is_unbounded</phrase><phrase role="special">()</phrase> <phrase role="special">||</phrase> <phrase role="special">(</phrase> <phrase role="identifier">sctx</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">maximum_size</phrase><phrase role="special">()</phrase> <phrase role="special">)</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Deallocates the stack space. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="class_pooled_fixedsize_stack_bridgehead"> <phrase id="class_pooled_fixedsize_stack"/> <link linkend="class_pooled_fixedsize_stack">Class <code>pooled_fixedsize_stack</code></link> </bridgehead> </para> <para> <emphasis role="bold">Boost.Fiber</emphasis> provides the class <link linkend="class_pooled_fixedsize_stack"><code>pooled_fixedsize_stack</code></link> which models the <link linkend="stack_allocator_concept"><emphasis>stack-allocator concept</emphasis></link>. In contrast to <link linkend="class_protected_fixedsize_stack"><code>protected_fixedsize_stack</code></link> it does not append a guard page at the end of each stack. The memory is managed internally by <ulink url="path_to_url"><code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">pool</phrase><phrase role="special">&lt;&gt;</phrase></code></ulink>. </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">pooled_fixedsize_stack</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">struct</phrase> <phrase role="identifier">pooled_fixedsize_stack</phrase> <phrase role="special">{</phrase> <phrase role="identifier">pooled_fixedsize_stack</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">stack_size</phrase> <phrase role="special">=</phrase> <phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">default_size</phrase><phrase role="special">(),</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">next_size</phrase> <phrase role="special">=</phrase> <phrase role="number">32</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">max_size</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase> <phrase role="identifier">stack_context</phrase> <phrase role="identifier">allocate</phrase><phrase role="special">();</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">deallocate</phrase><phrase role="special">(</phrase> <phrase role="identifier">stack_context</phrase> <phrase role="special">&amp;);</phrase> <phrase role="special">}</phrase> <phrase role="special">}}</phrase> </programlisting> <para> <bridgehead renderas="sect4" id="pooled_fixedsize_bridgehead"> <phrase id="pooled_fixedsize"/> <link linkend="pooled_fixedsize">Constructor</link> </bridgehead> </para> <programlisting><phrase role="identifier">pooled_fixedsize_stack</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">stack_size</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">next_size</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">max_size</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Preconditions:</term> <listitem> <para> <code><phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">is_unbounded</phrase><phrase role="special">()</phrase> <phrase role="special">||</phrase> <phrase role="special">(</phrase> <phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">maximum_size</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">stack_size</phrase><phrase role="special">)</phrase></code> and <code><phrase role="number">0</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">next_size</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Allocates memory of at least <code><phrase role="identifier">stack_size</phrase></code> bytes and stores a pointer to the stack and its actual size in <code><phrase role="identifier">sctx</phrase></code>. Depending on the architecture (the stack grows downwards/upwards) the stored address is the highest/lowest address of the stack. Argument <code><phrase role="identifier">next_size</phrase></code> determines the number of stacks to request from the system the first time that <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> needs to allocate system memory. The third argument <code><phrase role="identifier">max_size</phrase></code> controls how much memory might be allocated for stacks &mdash; a value of zero means no upper limit. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="pooled_fixedsize_allocate_bridgehead"> <phrase id="pooled_fixedsize_allocate"/> <link linkend="pooled_fixedsize_allocate">Member function <code>allocate</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">stack_context</phrase> <phrase role="identifier">allocate</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Preconditions:</term> <listitem> <para> <code><phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">is_unbounded</phrase><phrase role="special">()</phrase> <phrase role="special">||</phrase> <phrase role="special">(</phrase> <phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">maximum_size</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">stack_size</phrase><phrase role="special">)</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Allocates memory of at least <code><phrase role="identifier">stack_size</phrase></code> bytes and stores a pointer to the stack and its actual size in <code><phrase role="identifier">sctx</phrase></code>. Depending on the architecture (the stack grows downwards/upwards) the stored address is the highest/lowest address of the stack. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="pooled_fixesize_deallocate_bridgehead"> <phrase id="pooled_fixesize_deallocate"/> <link linkend="pooled_fixesize_deallocate">Member function <code>deallocate</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">deallocate</phrase><phrase role="special">(</phrase> <phrase role="identifier">stack_context</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">sctx</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Preconditions:</term> <listitem> <para> <code><phrase role="identifier">sctx</phrase><phrase role="special">.</phrase><phrase role="identifier">sp</phrase></code> is valid, <code><phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">is_unbounded</phrase><phrase role="special">()</phrase> <phrase role="special">||</phrase> <phrase role="special">(</phrase> <phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">maximum_size</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">sctx</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">)</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Deallocates the stack space. </para> </listitem> </varlistentry> </variablelist> <note> <para> This stack allocator is not thread safe. </para> </note> <para> <bridgehead renderas="sect4" id="class_fixedsize_stack_bridgehead"> <phrase id="class_fixedsize_stack"/> <link linkend="class_fixedsize_stack">Class <code>fixedsize_stack</code></link> </bridgehead> </para> <para> <emphasis role="bold">Boost.Fiber</emphasis> provides the class <link linkend="class_fixedsize_stack"><code>fixedsize_stack</code></link> which models the <link linkend="stack_allocator_concept"><emphasis>stack-allocator concept</emphasis></link>. In contrast to <link linkend="class_protected_fixedsize_stack"><code>protected_fixedsize_stack</code></link> it does not append a guard page at the end of each stack. The memory is simply managed by <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">malloc</phrase><phrase role="special">()</phrase></code> and <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">free</phrase><phrase role="special">()</phrase></code>. </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">context</phrase><phrase role="special">/</phrase><phrase role="identifier">fixedsize_stack</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">struct</phrase> <phrase role="identifier">fixedsize_stack</phrase> <phrase role="special">{</phrase> <phrase role="identifier">fixedsize_stack</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">size</phrase> <phrase role="special">=</phrase> <phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">default_size</phrase><phrase role="special">());</phrase> <phrase role="identifier">stack_context</phrase> <phrase role="identifier">allocate</phrase><phrase role="special">();</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">deallocate</phrase><phrase role="special">(</phrase> <phrase role="identifier">stack_context</phrase> <phrase role="special">&amp;);</phrase> <phrase role="special">}</phrase> <phrase role="special">}}</phrase> </programlisting> <para> <bridgehead renderas="sect4" id="fixedsize_allocate_bridgehead"> <phrase id="fixedsize_allocate"/> <link linkend="fixedsize_allocate">Member function <code>allocate</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">stack_context</phrase> <phrase role="identifier">allocate</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Preconditions:</term> <listitem> <para> <code><phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">minimum_size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">size</phrase></code> and <code><phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">is_unbounded</phrase><phrase role="special">()</phrase> <phrase role="special">||</phrase> <phrase role="special">(</phrase> <phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">maximum_size</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">size</phrase><phrase role="special">)</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Allocates memory of at least <code><phrase role="identifier">size</phrase></code> bytes and stores a pointer to the stack and its actual size in <code><phrase role="identifier">sctx</phrase></code>. Depending on the architecture (the stack grows downwards/upwards) the stored address is the highest/lowest address of the stack. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="fixesize_deallocate_bridgehead"> <phrase id="fixesize_deallocate"/> <link linkend="fixesize_deallocate">Member function <code>deallocate</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">deallocate</phrase><phrase role="special">(</phrase> <phrase role="identifier">stack_context</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">sctx</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Preconditions:</term> <listitem> <para> <code><phrase role="identifier">sctx</phrase><phrase role="special">.</phrase><phrase role="identifier">sp</phrase></code> is valid, <code><phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">minimum_size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">sctx</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase></code> and <code><phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">is_unbounded</phrase><phrase role="special">()</phrase> <phrase role="special">||</phrase> <phrase role="special">(</phrase> <phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">maximum_size</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">sctx</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">)</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Deallocates the stack space. </para> </listitem> </varlistentry> </variablelist> <para> <anchor id="segmented"/><bridgehead renderas="sect4" id="class_segmented_stack_bridgehead"> <phrase id="class_segmented_stack"/> <link linkend="class_segmented_stack">Class <code>segmented_stack</code></link> </bridgehead> </para> <para> <emphasis role="bold">Boost.Fiber</emphasis> supports usage of a <link linkend="class_segmented_stack"><code>segmented_stack</code></link>, i.e. the stack grows on demand. The fiber is created with a minimal stack size which will be increased as required. Class <link linkend="class_segmented_stack"><code>segmented_stack</code></link> models the <link linkend="stack_allocator_concept"><emphasis>stack-allocator concept</emphasis></link>. In contrast to <link linkend="class_protected_fixedsize_stack"><code>protected_fixedsize_stack</code></link> and <link linkend="class_fixedsize_stack"><code>fixedsize_stack</code></link> it creates a stack which grows on demand. </para> <note> <para> Segmented stacks are currently only supported by <emphasis role="bold">gcc</emphasis> from version <emphasis role="bold">4.7</emphasis> and <emphasis role="bold">clang</emphasis> from version <emphasis role="bold">3.4</emphasis> onwards. In order to use a <link linkend="class_segmented_stack"><code>segmented_stack</code></link> <emphasis role="bold">Boost.Fiber</emphasis> must be built with property <code><phrase role="identifier">segmented</phrase><phrase role="special">-</phrase><phrase role="identifier">stacks</phrase></code>, e.g. <emphasis role="bold">toolset=gcc segmented-stacks=on</emphasis> and applying BOOST_USE_SEGMENTED_STACKS at b2/bjam command line. </para> </note> <note> <para> Segmented stacks can only be used with callcc() using property <code><phrase role="identifier">context</phrase><phrase role="special">-</phrase><phrase role="identifier">impl</phrase><phrase role="special">=</phrase><phrase role="identifier">ucontext</phrase></code>. </para> </note> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">segmented_stack</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">struct</phrase> <phrase role="identifier">segmented_stack</phrase> <phrase role="special">{</phrase> <phrase role="identifier">segmented_stack</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">stack_size</phrase> <phrase role="special">=</phrase> <phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">default_size</phrase><phrase role="special">());</phrase> <phrase role="identifier">stack_context</phrase> <phrase role="identifier">allocate</phrase><phrase role="special">();</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">deallocate</phrase><phrase role="special">(</phrase> <phrase role="identifier">stack_context</phrase> <phrase role="special">&amp;);</phrase> <phrase role="special">}</phrase> <phrase role="special">}}</phrase> </programlisting> <para> <bridgehead renderas="sect4" id="segmented_allocate_bridgehead"> <phrase id="segmented_allocate"/> <link linkend="segmented_allocate">Member function <code>allocate</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">stack_context</phrase> <phrase role="identifier">allocate</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Preconditions:</term> <listitem> <para> <code><phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">minimum_size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">size</phrase></code> and <code><phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">is_unbounded</phrase><phrase role="special">()</phrase> <phrase role="special">||</phrase> <phrase role="special">(</phrase> <phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">maximum_size</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">size</phrase><phrase role="special">)</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Allocates memory of at least <code><phrase role="identifier">size</phrase></code> bytes and stores a pointer to the stack and its actual size in <code><phrase role="identifier">sctx</phrase></code>. Depending on the architecture (the stack grows downwards/upwards) the stored address is the highest/lowest address of the stack. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="segmented_deallocate_bridgehead"> <phrase id="segmented_deallocate"/> <link linkend="segmented_deallocate">Member function <code>deallocate</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">deallocate</phrase><phrase role="special">(</phrase> <phrase role="identifier">stack_context</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">sctx</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Preconditions:</term> <listitem> <para> <code><phrase role="identifier">sctx</phrase><phrase role="special">.</phrase><phrase role="identifier">sp</phrase></code> is valid, <code><phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">minimum_size</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;=</phrase> <phrase role="identifier">sctx</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase></code> and <code><phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">is_unbounded</phrase><phrase role="special">()</phrase> <phrase role="special">||</phrase> <phrase role="special">(</phrase> <phrase role="identifier">traits_type</phrase><phrase role="special">::</phrase><phrase role="identifier">maximum_size</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;=</phrase> <phrase role="identifier">sctx</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">)</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Deallocates the stack space. </para> </listitem> </varlistentry> </variablelist> <note> <para> If the library is compiled for segmented stacks, <link linkend="class_segmented_stack"><code>segmented_stack</code></link> is the only available stack allocator. </para> </note> <section id="fiber.stack.valgrind"> <title><link linkend="fiber.stack.valgrind">Support for valgrind</link></title> <para> Running programs that switch stacks under valgrind causes problems. Property (b2 command-line) <code><phrase role="identifier">valgrind</phrase><phrase role="special">=</phrase><phrase role="identifier">on</phrase></code> let valgrind treat the memory regions as stack space which suppresses the errors. </para> </section> </section> <section id="fiber.synchronization"> <title><anchor id="synchronization"/><link linkend="fiber.synchronization">Synchronization</link></title> <para> In general, <emphasis role="bold">Boost.Fiber</emphasis> synchronization objects can neither be moved nor copied. A synchronization object acts as a mutually-agreed rendezvous point between different fibers. If such an object were copied somewhere else, the new copy would have no consumers. If such an object were <emphasis>moved</emphasis> somewhere else, leaving the original instance in an unspecified state, existing consumers would behave strangely. </para> <para> The fiber synchronization objects provided by this library will, by default, safely synchronize fibers running on different threads. However, this level of synchronization can be removed (for performance) by building the library with <emphasis role="bold"><code><phrase role="identifier">BOOST_FIBERS_NO_ATOMICS</phrase></code></emphasis> defined. When the library is built with that macro, you must ensure that all the fibers referencing a particular synchronization object are running in the same thread. </para> <section id="fiber.synchronization.mutex_types"> <title><link linkend="fiber.synchronization.mutex_types">Mutex Types</link></title> <para> <bridgehead renderas="sect4" id="class_mutex_bridgehead"> <phrase id="class_mutex"/> <link linkend="class_mutex">Class <code>mutex</code></link> </bridgehead> </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">mutex</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">mutex</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="identifier">mutex</phrase><phrase role="special">();</phrase> <phrase role="special">~</phrase><phrase role="identifier">mutex</phrase><phrase role="special">();</phrase> <phrase role="identifier">mutex</phrase><phrase role="special">(</phrase> <phrase role="identifier">mutex</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">mutex</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">mutex</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">lock</phrase><phrase role="special">();</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">try_lock</phrase><phrase role="special">();</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">unlock</phrase><phrase role="special">();</phrase> <phrase role="special">};</phrase> <phrase role="special">}}</phrase> </programlisting> <para> <link linkend="class_mutex"><code>mutex</code></link> provides an exclusive-ownership mutex. At most one fiber can own the lock on a given instance of <link linkend="class_mutex"><code>mutex</code></link> at any time. Multiple concurrent calls to <code><phrase role="identifier">lock</phrase><phrase role="special">()</phrase></code>, <code><phrase role="identifier">try_lock</phrase><phrase role="special">()</phrase></code> and <code><phrase role="identifier">unlock</phrase><phrase role="special">()</phrase></code> shall be permitted. </para> <para> Any fiber blocked in <code><phrase role="identifier">lock</phrase><phrase role="special">()</phrase></code> is suspended until the owning fiber releases the lock by calling <code><phrase role="identifier">unlock</phrase><phrase role="special">()</phrase></code>. </para> <para> <bridgehead renderas="sect4" id="mutex_lock_bridgehead"> <phrase id="mutex_lock"/> <link linkend="mutex_lock">Member function <code>lock</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">lock</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> The calling fiber doesn't own the mutex. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> The current fiber blocks until ownership can be obtained. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">lock_error</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Error Conditions:</term> <listitem> <para> <emphasis role="bold">resource_deadlock_would_occur</emphasis>: if <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code> already owns the mutex. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="mutex_try_lock_bridgehead"> <phrase id="mutex_try_lock"/> <link linkend="mutex_try_lock">Member function <code>try_lock</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="identifier">try_lock</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> The calling fiber doesn't own the mutex. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Attempt to obtain ownership for the current fiber without blocking. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if ownership was obtained for the current fiber, <code><phrase role="keyword">false</phrase></code> otherwise. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">lock_error</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Error Conditions:</term> <listitem> <para> <emphasis role="bold">resource_deadlock_would_occur</emphasis>: if <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code> already owns the mutex. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="mutex_unlock_bridgehead"> <phrase id="mutex_unlock"/> <link linkend="mutex_unlock">Member function <code>unlock</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">unlock</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> The current fiber owns <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Releases a lock on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> by the current fiber. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">lock_error</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Error Conditions:</term> <listitem> <para> <emphasis role="bold">operation_not_permitted</emphasis>: if <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code> does not own the mutex. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="class_timed_mutex_bridgehead"> <phrase id="class_timed_mutex"/> <link linkend="class_timed_mutex">Class <code>timed_mutex</code></link> </bridgehead> </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">timed_mutex</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">timed_mutex</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="identifier">timed_mutex</phrase><phrase role="special">();</phrase> <phrase role="special">~</phrase><phrase role="identifier">timed_mutex</phrase><phrase role="special">();</phrase> <phrase role="identifier">timed_mutex</phrase><phrase role="special">(</phrase> <phrase role="identifier">timed_mutex</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">timed_mutex</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">timed_mutex</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">lock</phrase><phrase role="special">();</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">try_lock</phrase><phrase role="special">();</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">unlock</phrase><phrase role="special">();</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">try_lock_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_time</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">try_lock_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_duration</phrase><phrase role="special">);</phrase> <phrase role="special">};</phrase> <phrase role="special">}}</phrase> </programlisting> <para> <link linkend="class_timed_mutex"><code>timed_mutex</code></link> provides an exclusive-ownership mutex. At most one fiber can own the lock on a given instance of <link linkend="class_timed_mutex"><code>timed_mutex</code></link> at any time. Multiple concurrent calls to <code><phrase role="identifier">lock</phrase><phrase role="special">()</phrase></code>, <code><phrase role="identifier">try_lock</phrase><phrase role="special">()</phrase></code>, <code><phrase role="identifier">try_lock_until</phrase><phrase role="special">()</phrase></code>, <code><phrase role="identifier">try_lock_for</phrase><phrase role="special">()</phrase></code> and <code><phrase role="identifier">unlock</phrase><phrase role="special">()</phrase></code> shall be permitted. </para> <para> <bridgehead renderas="sect4" id="timed_mutex_lock_bridgehead"> <phrase id="timed_mutex_lock"/> <link linkend="timed_mutex_lock">Member function <code>lock</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">lock</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> The calling fiber doesn't own the mutex. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> The current fiber blocks until ownership can be obtained. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">lock_error</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Error Conditions:</term> <listitem> <para> <emphasis role="bold">resource_deadlock_would_occur</emphasis>: if <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code> already owns the mutex. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="timed_mutex_try_lock_bridgehead"> <phrase id="timed_mutex_try_lock"/> <link linkend="timed_mutex_try_lock">Member function <code>try_lock</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="identifier">try_lock</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> The calling fiber doesn't own the mutex. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Attempt to obtain ownership for the current fiber without blocking. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if ownership was obtained for the current fiber, <code><phrase role="keyword">false</phrase></code> otherwise. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">lock_error</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Error Conditions:</term> <listitem> <para> <emphasis role="bold">resource_deadlock_would_occur</emphasis>: if <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code> already owns the mutex. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="timed_mutex_unlock_bridgehead"> <phrase id="timed_mutex_unlock"/> <link linkend="timed_mutex_unlock">Member function <code>unlock</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">unlock</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> The current fiber owns <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Releases a lock on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> by the current fiber. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">lock_error</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Error Conditions:</term> <listitem> <para> <emphasis role="bold">operation_not_permitted</emphasis>: if <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code> does not own the mutex. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="timed_mutex_try_lock_until_bridgehead"> <phrase id="timed_mutex_try_lock_until"/> <link linkend="timed_mutex_try_lock_until">Templated member function <code>try_lock_until</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">try_lock_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_time</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> The calling fiber doesn't own the mutex. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Attempt to obtain ownership for the current fiber. Blocks until ownership can be obtained, or the specified time is reached. If the specified time has already passed, behaves as <link linkend="timed_mutex_try_lock"><code>timed_mutex::try_lock()</code></link>. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if ownership was obtained for the current fiber, <code><phrase role="keyword">false</phrase></code> otherwise. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">lock_error</phrase></code>, timeout-related exceptions. </para> </listitem> </varlistentry> <varlistentry> <term>Error Conditions:</term> <listitem> <para> <emphasis role="bold">resource_deadlock_would_occur</emphasis>: if <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code> already owns the mutex. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="timed_mutex_try_lock_for_bridgehead"> <phrase id="timed_mutex_try_lock_for"/> <link linkend="timed_mutex_try_lock_for">Templated member function <code>try_lock_for</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">try_lock_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_duration</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> The calling fiber doesn't own the mutex. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Attempt to obtain ownership for the current fiber. Blocks until ownership can be obtained, or the specified time is reached. If the specified time has already passed, behaves as <link linkend="timed_mutex_try_lock"><code>timed_mutex::try_lock()</code></link>. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if ownership was obtained for the current fiber, <code><phrase role="keyword">false</phrase></code> otherwise. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">lock_error</phrase></code>, timeout-related exceptions. </para> </listitem> </varlistentry> <varlistentry> <term>Error Conditions:</term> <listitem> <para> <emphasis role="bold">resource_deadlock_would_occur</emphasis>: if <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code> already owns the mutex. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="class_recursive_mutex_bridgehead"> <phrase id="class_recursive_mutex"/> <link linkend="class_recursive_mutex">Class <code>recursive_mutex</code></link> </bridgehead> </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">recursive_mutex</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">recursive_mutex</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="identifier">recursive_mutex</phrase><phrase role="special">();</phrase> <phrase role="special">~</phrase><phrase role="identifier">recursive_mutex</phrase><phrase role="special">();</phrase> <phrase role="identifier">recursive_mutex</phrase><phrase role="special">(</phrase> <phrase role="identifier">recursive_mutex</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">recursive_mutex</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">recursive_mutex</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">lock</phrase><phrase role="special">();</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">try_lock</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">unlock</phrase><phrase role="special">();</phrase> <phrase role="special">};</phrase> <phrase role="special">}}</phrase> </programlisting> <para> <link linkend="class_recursive_mutex"><code>recursive_mutex</code></link> provides an exclusive-ownership recursive mutex. At most one fiber can own the lock on a given instance of <link linkend="class_recursive_mutex"><code>recursive_mutex</code></link> at any time. Multiple concurrent calls to <code><phrase role="identifier">lock</phrase><phrase role="special">()</phrase></code>, <code><phrase role="identifier">try_lock</phrase><phrase role="special">()</phrase></code> and <code><phrase role="identifier">unlock</phrase><phrase role="special">()</phrase></code> shall be permitted. A fiber that already has exclusive ownership of a given <link linkend="class_recursive_mutex"><code>recursive_mutex</code></link> instance can call <code><phrase role="identifier">lock</phrase><phrase role="special">()</phrase></code> or <code><phrase role="identifier">try_lock</phrase><phrase role="special">()</phrase></code> to acquire an additional level of ownership of the mutex. <code><phrase role="identifier">unlock</phrase><phrase role="special">()</phrase></code> must be called once for each level of ownership acquired by a single fiber before ownership can be acquired by another fiber. </para> <para> <bridgehead renderas="sect4" id="recursive_mutex_lock_bridgehead"> <phrase id="recursive_mutex_lock"/> <link linkend="recursive_mutex_lock">Member function <code>lock</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">lock</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> The current fiber blocks until ownership can be obtained. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="recursive_mutex_try_lock_bridgehead"> <phrase id="recursive_mutex_try_lock"/> <link linkend="recursive_mutex_try_lock">Member function <code>try_lock</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="identifier">try_lock</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Attempt to obtain ownership for the current fiber without blocking. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if ownership was obtained for the current fiber, <code><phrase role="keyword">false</phrase></code> otherwise. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="recursive_mutex_unlock_bridgehead"> <phrase id="recursive_mutex_unlock"/> <link linkend="recursive_mutex_unlock">Member function <code>unlock</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">unlock</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Releases a lock on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> by the current fiber. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">lock_error</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Error Conditions:</term> <listitem> <para> <emphasis role="bold">operation_not_permitted</emphasis>: if <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code> does not own the mutex. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="class_recursive_timed_mutex_bridgehead"> <phrase id="class_recursive_timed_mutex"/> <link linkend="class_recursive_timed_mutex">Class <code>recursive_timed_mutex</code></link> </bridgehead> </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">recursive_timed_mutex</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">recursive_timed_mutex</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="identifier">recursive_timed_mutex</phrase><phrase role="special">();</phrase> <phrase role="special">~</phrase><phrase role="identifier">recursive_timed_mutex</phrase><phrase role="special">();</phrase> <phrase role="identifier">recursive_timed_mutex</phrase><phrase role="special">(</phrase> <phrase role="identifier">recursive_timed_mutex</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">recursive_timed_mutex</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">recursive_timed_mutex</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">lock</phrase><phrase role="special">();</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">try_lock</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">unlock</phrase><phrase role="special">();</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">try_lock_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_time</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">try_lock_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_duration</phrase><phrase role="special">);</phrase> <phrase role="special">};</phrase> <phrase role="special">}}</phrase> </programlisting> <para> <link linkend="class_recursive_timed_mutex"><code>recursive_timed_mutex</code></link> provides an exclusive-ownership recursive mutex. At most one fiber can own the lock on a given instance of <link linkend="class_recursive_timed_mutex"><code>recursive_timed_mutex</code></link> at any time. Multiple concurrent calls to <code><phrase role="identifier">lock</phrase><phrase role="special">()</phrase></code>, <code><phrase role="identifier">try_lock</phrase><phrase role="special">()</phrase></code>, <code><phrase role="identifier">try_lock_for</phrase><phrase role="special">()</phrase></code>, <code><phrase role="identifier">try_lock_until</phrase><phrase role="special">()</phrase></code> and <code><phrase role="identifier">unlock</phrase><phrase role="special">()</phrase></code> shall be permitted. A fiber that already has exclusive ownership of a given <link linkend="class_recursive_timed_mutex"><code>recursive_timed_mutex</code></link> instance can call <code><phrase role="identifier">lock</phrase><phrase role="special">()</phrase></code>, <code><phrase role="identifier">try_lock</phrase><phrase role="special">()</phrase></code>, <code><phrase role="identifier">try_lock_for</phrase><phrase role="special">()</phrase></code> or <code><phrase role="identifier">try_lock_until</phrase><phrase role="special">()</phrase></code> to acquire an additional level of ownership of the mutex. <code><phrase role="identifier">unlock</phrase><phrase role="special">()</phrase></code> must be called once for each level of ownership acquired by a single fiber before ownership can be acquired by another fiber. </para> <para> <bridgehead renderas="sect4" id="recursive_timed_mutex_lock_bridgehead"> <phrase id="recursive_timed_mutex_lock"/> <link linkend="recursive_timed_mutex_lock">Member function <code>lock</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">lock</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> The current fiber blocks until ownership can be obtained. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="recursive_timed_mutex_try_lock_bridgehead"> <phrase id="recursive_timed_mutex_try_lock"/> <link linkend="recursive_timed_mutex_try_lock">Member function <code>try_lock</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="identifier">try_lock</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Attempt to obtain ownership for the current fiber without blocking. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if ownership was obtained for the current fiber, <code><phrase role="keyword">false</phrase></code> otherwise. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="recursive_timed_mutex_unlock_bridgehead"> <phrase id="recursive_timed_mutex_unlock"/> <link linkend="recursive_timed_mutex_unlock">Member function <code>unlock</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">unlock</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Releases a lock on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> by the current fiber. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">lock_error</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Error Conditions:</term> <listitem> <para> <emphasis role="bold">operation_not_permitted</emphasis>: if <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase></code> does not own the mutex. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="recursive_timed_mutex_try_lock_until_bridgehead"> <phrase id="recursive_timed_mutex_try_lock_until"/> <link linkend="recursive_timed_mutex_try_lock_until">Templated member function <code>try_lock_until</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">try_lock_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_time</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Attempt to obtain ownership for the current fiber. Blocks until ownership can be obtained, or the specified time is reached. If the specified time has already passed, behaves as <link linkend="recursive_timed_mutex_try_lock"><code>recursive_timed_mutex::try_lock()</code></link>. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if ownership was obtained for the current fiber, <code><phrase role="keyword">false</phrase></code> otherwise. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Timeout-related exceptions. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="recursive_timed_mutex_try_lock_for_bridgehead"> <phrase id="recursive_timed_mutex_try_lock_for"/> <link linkend="recursive_timed_mutex_try_lock_for">Templated member function <code>try_lock_for</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">try_lock_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_duration</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Attempt to obtain ownership for the current fiber. Blocks until ownership can be obtained, or the specified time is reached. If the specified time has already passed, behaves as <link linkend="recursive_timed_mutex_try_lock"><code>recursive_timed_mutex::try_lock()</code></link>. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if ownership was obtained for the current fiber, <code><phrase role="keyword">false</phrase></code> otherwise. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Timeout-related exceptions. </para> </listitem> </varlistentry> </variablelist> </section> <section id="fiber.synchronization.conditions"> <title><link linkend="fiber.synchronization.conditions">Condition Variables</link></title> <bridgehead renderas="sect4" id="fiber.synchronization.conditions.h0"> <phrase id="fiber.synchronization.conditions.synopsis"/><link linkend="fiber.synchronization.conditions.synopsis">Synopsis</link> </bridgehead> <programlisting><phrase role="keyword">enum</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">cv_status</phrase><phrase role="special">;</phrase> <phrase role="special">{</phrase> <phrase role="identifier">no_timeout</phrase><phrase role="special">,</phrase> <phrase role="identifier">timeout</phrase> <phrase role="special">};</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">condition_variable</phrase><phrase role="special">;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">condition_variable_any</phrase><phrase role="special">;</phrase> </programlisting> <para> The class <link linkend="class_condition_variable"><code>condition_variable</code></link> provides a mechanism for a fiber to wait for notification from another fiber. When the fiber awakens from the wait, then it checks to see if the appropriate condition is now true, and continues if so. If the condition is not true, then the fiber calls <code><phrase role="identifier">wait</phrase></code> again to resume waiting. In the simplest case, this condition is just a boolean variable: </para> <programlisting><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_variable</phrase> <phrase role="identifier">cond</phrase><phrase role="special">;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">mutex</phrase> <phrase role="identifier">mtx</phrase><phrase role="special">;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">data_ready</phrase> <phrase role="special">=</phrase> <phrase role="keyword">false</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">process_data</phrase><phrase role="special">();</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">wait_for_data_to_process</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">unique_lock</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">mutex</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">lk</phrase><phrase role="special">(</phrase> <phrase role="identifier">mtx</phrase><phrase role="special">);</phrase> <phrase role="keyword">while</phrase> <phrase role="special">(</phrase> <phrase role="special">!</phrase> <phrase role="identifier">data_ready</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">cond</phrase><phrase role="special">.</phrase><phrase role="identifier">wait</phrase><phrase role="special">(</phrase> <phrase role="identifier">lk</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> <phrase role="comment">// release lk</phrase> <phrase role="identifier">process_data</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> </programlisting> <para> Notice that the <code><phrase role="identifier">lk</phrase></code> is passed to <link linkend="condition_variable_wait"><code>condition_variable::wait()</code></link>: <code><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code> will atomically add the fiber to the set of fibers waiting on the condition variable, and unlock the <link linkend="class_mutex"><code>mutex</code></link>. When the fiber is awakened, the <code><phrase role="identifier">mutex</phrase></code> will be locked again before the call to <code><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code> returns. This allows other fibers to acquire the <code><phrase role="identifier">mutex</phrase></code> in order to update the shared data, and ensures that the data associated with the condition is correctly synchronized. </para> <para> <code><phrase role="identifier">wait_for_data_to_process</phrase><phrase role="special">()</phrase></code> could equivalently be written: </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">wait_for_data_to_process</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">unique_lock</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">mutex</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">lk</phrase><phrase role="special">(</phrase> <phrase role="identifier">mtx</phrase><phrase role="special">);</phrase> <phrase role="comment">// make condition_variable::wait() perform the loop</phrase> <phrase role="identifier">cond</phrase><phrase role="special">.</phrase><phrase role="identifier">wait</phrase><phrase role="special">(</phrase> <phrase role="identifier">lk</phrase><phrase role="special">,</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">data_ready</phrase><phrase role="special">;</phrase> <phrase role="special">});</phrase> <phrase role="special">}</phrase> <phrase role="comment">// release lk</phrase> <phrase role="identifier">process_data</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> </programlisting> <para> In the meantime, another fiber sets <code><phrase role="identifier">data_ready</phrase></code> to <code><phrase role="keyword">true</phrase></code>, and then calls either <link linkend="condition_variable_notify_one"><code>condition_variable::notify_one()</code></link> or <link linkend="condition_variable_notify_all"><code>condition_variable::notify_all()</code></link> on the <link linkend="class_condition_variable"><code>condition_variable</code></link> <code><phrase role="identifier">cond</phrase></code> to wake one waiting fiber or all the waiting fibers respectively. </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">retrieve_data</phrase><phrase role="special">();</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">prepare_data</phrase><phrase role="special">();</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">prepare_data_for_processing</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="identifier">retrieve_data</phrase><phrase role="special">();</phrase> <phrase role="identifier">prepare_data</phrase><phrase role="special">();</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">unique_lock</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">mutex</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">lk</phrase><phrase role="special">(</phrase> <phrase role="identifier">mtx</phrase><phrase role="special">);</phrase> <phrase role="identifier">data_ready</phrase> <phrase role="special">=</phrase> <phrase role="keyword">true</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="identifier">cond</phrase><phrase role="special">.</phrase><phrase role="identifier">notify_one</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> </programlisting> <para> Note that the same <link linkend="class_mutex"><code>mutex</code></link> is locked before the shared data is updated, but that the <code><phrase role="identifier">mutex</phrase></code> does not have to be locked across the call to <link linkend="condition_variable_notify_one"><code>condition_variable::notify_one()</code></link>. </para> <para> Locking is important because the synchronization objects provided by <emphasis role="bold">Boost.Fiber</emphasis> can be used to synchronize fibers running on different threads. </para> <para> <emphasis role="bold">Boost.Fiber</emphasis> provides both <link linkend="class_condition_variable"><code>condition_variable</code></link> and <link linkend="class_condition_variable_any"><code>condition_variable_any</code></link>. <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_variable</phrase></code> can only wait on <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">unique_lock</phrase></code></ulink><code><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase></code><link linkend="class_mutex"><code>mutex</code></link><code> <phrase role="special">&gt;</phrase></code> while <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_variable_any</phrase></code> can wait on user-defined lock types. </para> <anchor id="condition_variable_spurious_wakeups"/> <bridgehead renderas="sect4" id="fiber.synchronization.conditions.h1"> <phrase id="fiber.synchronization.conditions.no_spurious_wakeups"/><link linkend="fiber.synchronization.conditions.no_spurious_wakeups">No Spurious Wakeups</link> </bridgehead> <para> Neither <link linkend="class_condition_variable"><code>condition_variable</code></link> nor <link linkend="class_condition_variable_any"><code>condition_variable_any</code></link> are subject to spurious wakeup: <link linkend="condition_variable_wait"><code>condition_variable::wait()</code></link> can only wake up when <link linkend="condition_variable_notify_one"><code>condition_variable::notify_one()</code></link> or <link linkend="condition_variable_notify_all"><code>condition_variable::notify_all()</code></link> is called. Even so, it is prudent to use one of the <code><phrase role="identifier">wait</phrase><phrase role="special">(</phrase> <phrase role="identifier">lock</phrase><phrase role="special">,</phrase> <phrase role="identifier">predicate</phrase> <phrase role="special">)</phrase></code> overloads. </para> <para> Consider a set of consumer fibers processing items from a <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">queue</phrase></code></ulink>. The queue is continually populated by a set of producer fibers. </para> <para> The consumer fibers might reasonably wait on a <code><phrase role="identifier">condition_variable</phrase></code> as long as the queue remains <ulink url="path_to_url"><code><phrase role="identifier">empty</phrase><phrase role="special">()</phrase></code></ulink>. </para> <para> Because producer fibers might <ulink url="path_to_url"><code><phrase role="identifier">push</phrase><phrase role="special">()</phrase></code></ulink> items to the queue in bursts, they call <link linkend="condition_variable_notify_all"><code>condition_variable::notify_all()</code></link> rather than <link linkend="condition_variable_notify_one"><code>condition_variable::notify_one()</code></link>. </para> <para> But a given consumer fiber might well wake up from <link linkend="condition_variable_wait"><code>condition_variable::wait()</code></link> and find the queue <code><phrase role="identifier">empty</phrase><phrase role="special">()</phrase></code>, because other consumer fibers might already have processed all pending items. </para> <para> (See also <link linkend="spurious_wakeup">spurious wakeup</link>.) </para> <anchor id="class_cv_status"/> <bridgehead renderas="sect4" id="fiber.synchronization.conditions.h2"> <phrase id="fiber.synchronization.conditions.your_sha256_hashcode_"/><link linkend="fiber.synchronization.conditions.your_sha256_hashcode_">Enumeration <code><phrase role="identifier">cv_status</phrase></code></link> </bridgehead> <para> A timed wait operation might return because of timeout or not. </para> <programlisting><phrase role="keyword">enum</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">cv_status</phrase> <phrase role="special">{</phrase> <phrase role="identifier">no_timeout</phrase><phrase role="special">,</phrase> <phrase role="identifier">timeout</phrase> <phrase role="special">};</phrase> </programlisting> <bridgehead renderas="sect4" id="fiber.synchronization.conditions.h3"> <phrase id="fiber.synchronization.conditions._code__phrase_role__identifier__no_timeout__phrase___code_"/><link linkend="fiber.synchronization.conditions._code__phrase_role__identifier__no_timeout__phrase___code_"><code><phrase role="identifier">no_timeout</phrase></code></link> </bridgehead> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> The condition variable was awakened with <code><phrase role="identifier">notify_one</phrase></code> or <code><phrase role="identifier">notify_all</phrase></code>. </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect4" id="fiber.synchronization.conditions.h4"> <phrase id="fiber.synchronization.conditions._code__phrase_role__identifier__timeout__phrase___code_"/><link linkend="fiber.synchronization.conditions._code__phrase_role__identifier__timeout__phrase___code_"><code><phrase role="identifier">timeout</phrase></code></link> </bridgehead> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> The condition variable was awakened by timeout. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="class_condition_variable_any_bridgehead"> <phrase id="class_condition_variable_any"/> <link linkend="class_condition_variable_any">Class <code>condition_variable_any</code></link> </bridgehead> </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">condition_variable</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">class</phrase> condition_variable_any <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> condition_variable_any<phrase role="special">();</phrase> <phrase role="special">~</phrase>condition_variable_any<phrase role="special">();</phrase> condition_variable_any<phrase role="special">(</phrase> condition_variable_any <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> condition_variable_any <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> condition_variable_any <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">notify_one</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">notify_all</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> template&lt; typename LockType &gt; void <phrase role="identifier">wait</phrase><phrase role="special">(</phrase> LockType <phrase role="special">&amp;);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> typename LockType, typename <phrase role="identifier">Pred</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">wait</phrase><phrase role="special">(</phrase> LockType <phrase role="special">&amp;,</phrase> <phrase role="identifier">Pred</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> typename LockType, typename <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">cv_status</phrase> <phrase role="identifier">wait_until</phrase><phrase role="special">(</phrase> LockType <phrase role="special">&amp;,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> typename LockType, typename <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Pred</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">wait_until</phrase><phrase role="special">(</phrase> LockType <phrase role="special">&amp;,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;,</phrase> <phrase role="identifier">Pred</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> typename LockType, typename <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">cv_status</phrase> <phrase role="identifier">wait_for</phrase><phrase role="special">(</phrase> LockType <phrase role="special">&amp;,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> typename LockType, typename <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Period</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Pred</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">wait_for</phrase><phrase role="special">(</phrase> LockType <phrase role="special">&amp;,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;,</phrase> <phrase role="identifier">Pred</phrase><phrase role="special">);</phrase> <phrase role="special">};</phrase> <phrase role="special">}}</phrase> </programlisting> <bridgehead renderas="sect4" id="fiber.synchronization.conditions.h5"> <phrase id="fiber.synchronization.conditions.constructor"/><link linkend="fiber.synchronization.conditions.constructor">Constructor</link> </bridgehead> <programlisting>condition_variable_any<phrase role="special">()</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Creates the object. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect4" id="fiber.synchronization.conditions.h6"> <phrase id="fiber.synchronization.conditions.destructor"/><link linkend="fiber.synchronization.conditions.destructor">Destructor</link> </bridgehead> <programlisting><phrase role="special">~</phrase>condition_variable_any<phrase role="special">()</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> All fibers waiting on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> have been notified by a call to <code><phrase role="identifier">notify_one</phrase></code> or <code><phrase role="identifier">notify_all</phrase></code> (though the respective calls to <code><phrase role="identifier">wait</phrase></code>, <code><phrase role="identifier">wait_for</phrase></code> or <code><phrase role="identifier">wait_until</phrase></code> need not have returned). </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Destroys the object. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="condition_variable_any_notify_one_bridgehead"> <phrase id="condition_variable_any_notify_one"/> <link linkend="condition_variable_any_notify_one">Member function <code>notify_one</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">notify_one</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> If any fibers are currently <link linkend="blocking"><emphasis>blocked</emphasis></link> waiting on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> in a call to <code><phrase role="identifier">wait</phrase></code>, <code><phrase role="identifier">wait_for</phrase></code> or <code><phrase role="identifier">wait_until</phrase></code>, unblocks one of those fibers. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> It is arbitrary which waiting fiber is resumed. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="condition_variable_any_notify_all_bridgehead"> <phrase id="condition_variable_any_notify_all"/> <link linkend="condition_variable_any_notify_all">Member function <code>notify_all</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">notify_all</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> If any fibers are currently <link linkend="blocking"><emphasis>blocked</emphasis></link> waiting on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> in a call to <code><phrase role="identifier">wait</phrase></code>, <code><phrase role="identifier">wait_for</phrase></code> or <code><phrase role="identifier">wait_until</phrase></code>, unblocks all of those fibers. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> This is why a waiting fiber must <emphasis>also</emphasis> check for the desired program state using a mechanism external to the <code>condition_variable_any</code>, and retry the wait until that state is reached. A fiber waiting on a <code>condition_variable_any</code> might well wake up a number of times before the desired state is reached. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="condition_variable_any_wait_bridgehead"> <phrase id="condition_variable_any_wait"/> <link linkend="condition_variable_any_wait">Templated member function <code>wait</code>()</link> </bridgehead> </para> <programlisting>template&lt; typename LockType &gt; void <phrase role="identifier">wait</phrase><phrase role="special">(</phrase> LockType <phrase role="special">&amp;</phrase> <phrase role="identifier">lk</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> typename LockType, typename <phrase role="identifier">Pred</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">wait</phrase><phrase role="special">(</phrase> LockType <phrase role="special">&amp;</phrase> <phrase role="identifier">lk</phrase><phrase role="special">,</phrase> <phrase role="identifier">Pred</phrase> <phrase role="identifier">pred</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> <code><phrase role="identifier">lk</phrase></code> is locked by the current fiber, and either no other fiber is currently waiting on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>, or the execution of the <ulink url="path_to_url"><code><phrase role="identifier">mutex</phrase><phrase role="special">()</phrase></code></ulink> member function on the <code><phrase role="identifier">lk</phrase></code> objects supplied in the calls to <code><phrase role="identifier">wait</phrase></code> in all the fibers currently waiting on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> would return the same value as <code><phrase role="identifier">lk</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">mutex</phrase><phrase role="special">()</phrase></code> for this call to <code><phrase role="identifier">wait</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Atomically call <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">unlock</phrase><phrase role="special">()</phrase></code> and blocks the current fiber. The fiber will unblock when notified by a call to <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">notify_one</phrase><phrase role="special">()</phrase></code> or <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">notify_all</phrase><phrase role="special">()</phrase></code>. When the fiber is unblocked (for whatever reason), the lock is reacquired by invoking <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">lock</phrase><phrase role="special">()</phrase></code> before the call to <code><phrase role="identifier">wait</phrase></code> returns. The lock is also reacquired by invoking <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">lock</phrase><phrase role="special">()</phrase></code> if the function exits with an exception. The member function accepting <code><phrase role="identifier">pred</phrase></code> is shorthand for: <programlisting><phrase role="keyword">while</phrase> <phrase role="special">(</phrase> <phrase role="special">!</phrase> <phrase role="identifier">pred</phrase><phrase role="special">()</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">wait</phrase><phrase role="special">(</phrase> <phrase role="identifier">lk</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> </programlisting> </para> </listitem> </varlistentry> <varlistentry> <term>Postcondition:</term> <listitem> <para> <code><phrase role="identifier">lk</phrase></code> is locked by the current fiber. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">fiber_error</phrase></code> if an error occurs. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> The Precondition is a bit dense. It merely states that all the fibers concurrently calling <code><phrase role="identifier">wait</phrase></code> on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> must wait on <code><phrase role="identifier">lk</phrase></code> objects governing the <emphasis>same</emphasis> <link linkend="class_mutex"><code>mutex</code></link>. Three distinct objects are involved in any <code>condition_variable_any::wait()</code> call: the <code>condition_variable_any</code> itself, the <code><phrase role="identifier">mutex</phrase></code> coordinating access between fibers and a local lock object (e.g. <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">unique_lock</phrase></code></ulink>). In general, you can partition the lifespan of a given <code>condition_variable_any</code> instance into periods with one or more fibers waiting on it, separated by periods when no fibers are waiting on it. When more than one fiber is waiting on that <code>condition_variable_any</code>, all must pass lock objects referencing the <emphasis>same</emphasis> <code><phrase role="identifier">mutex</phrase></code> instance. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="condition_variable_any_wait_until_bridgehead"> <phrase id="condition_variable_any_wait_until"/> <link linkend="condition_variable_any_wait_until">Templated member function <code>wait_until</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> typename LockType, typename <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">cv_status</phrase> <phrase role="identifier">wait_until</phrase><phrase role="special">(</phrase> LockType <phrase role="special">&amp;</phrase> <phrase role="identifier">lk</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">abs_time</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> typename LockType, typename <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Pred</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">wait_until</phrase><phrase role="special">(</phrase> LockType <phrase role="special">&amp;</phrase> <phrase role="identifier">lk</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">abs_time</phrase><phrase role="special">,</phrase> <phrase role="identifier">Pred</phrase> <phrase role="identifier">pred</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> <code><phrase role="identifier">lk</phrase></code> is locked by the current fiber, and either no other fiber is currently waiting on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>, or the execution of the <code><phrase role="identifier">mutex</phrase><phrase role="special">()</phrase></code> member function on the <code><phrase role="identifier">lk</phrase></code> objects supplied in the calls to <code><phrase role="identifier">wait</phrase></code>, <code><phrase role="identifier">wait_for</phrase></code> or <code><phrase role="identifier">wait_until</phrase></code> in all the fibers currently waiting on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> would return the same value as <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">mutex</phrase><phrase role="special">()</phrase></code> for this call to <code><phrase role="identifier">wait_until</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Atomically call <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">unlock</phrase><phrase role="special">()</phrase></code> and blocks the current fiber. The fiber will unblock when notified by a call to <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">notify_one</phrase><phrase role="special">()</phrase></code> or <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">notify_all</phrase><phrase role="special">()</phrase></code>, when the system time would be equal to or later than the specified <code><phrase role="identifier">abs_time</phrase></code>. When the fiber is unblocked (for whatever reason), the lock is reacquired by invoking <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">lock</phrase><phrase role="special">()</phrase></code> before the call to <code><phrase role="identifier">wait_until</phrase></code> returns. The lock is also reacquired by invoking <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">lock</phrase><phrase role="special">()</phrase></code> if the function exits with an exception. The member function accepting <code><phrase role="identifier">pred</phrase></code> is shorthand for: <programlisting><phrase role="keyword">while</phrase> <phrase role="special">(</phrase> <phrase role="special">!</phrase> <phrase role="identifier">pred</phrase><phrase role="special">()</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">cv_status</phrase><phrase role="special">::</phrase><phrase role="identifier">timeout</phrase> <phrase role="special">==</phrase> <phrase role="identifier">wait_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">lk</phrase><phrase role="special">,</phrase> <phrase role="identifier">abs_time</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">pred</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="keyword">return</phrase> <phrase role="keyword">true</phrase><phrase role="special">;</phrase> </programlisting> That is, even if <code><phrase role="identifier">wait_until</phrase><phrase role="special">()</phrase></code> times out, it can still return <code><phrase role="keyword">true</phrase></code> if <code><phrase role="identifier">pred</phrase><phrase role="special">()</phrase></code> returns <code><phrase role="keyword">true</phrase></code> at that time. </para> </listitem> </varlistentry> <varlistentry> <term>Postcondition:</term> <listitem> <para> <code><phrase role="identifier">lk</phrase></code> is locked by the current fiber. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">fiber_error</phrase></code> if an error occurs or timeout-related exceptions. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> The overload without <code><phrase role="identifier">pred</phrase></code> returns <code><phrase role="identifier">cv_status</phrase><phrase role="special">::</phrase><phrase role="identifier">no_timeout</phrase></code> if awakened by <code><phrase role="identifier">notify_one</phrase><phrase role="special">()</phrase></code> or <code><phrase role="identifier">notify_all</phrase><phrase role="special">()</phrase></code>, or <code><phrase role="identifier">cv_status</phrase><phrase role="special">::</phrase><phrase role="identifier">timeout</phrase></code> if awakened because the system time is past <code><phrase role="identifier">abs_time</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> The overload accepting <code><phrase role="identifier">pred</phrase></code> returns <code><phrase role="keyword">false</phrase></code> if the call is returning because the time specified by <code><phrase role="identifier">abs_time</phrase></code> was reached and the predicate returns <code><phrase role="keyword">false</phrase></code>, <code><phrase role="keyword">true</phrase></code> otherwise. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> See <emphasis role="bold">Note</emphasis> for <link linkend="condition_variable_any_wait"><code>condition_variable_any::wait()</code></link>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="condition_variable_any_wait_for_bridgehead"> <phrase id="condition_variable_any_wait_for"/> <link linkend="condition_variable_any_wait_for">Templated member function <code>wait_for</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> typename LockType, typename <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">cv_status</phrase> <phrase role="identifier">wait_for</phrase><phrase role="special">(</phrase> LockType <phrase role="special">&amp;</phrase> <phrase role="identifier">lk</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">rel_time</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> typename LockType, typename <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Period</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Pred</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">wait_for</phrase><phrase role="special">(</phrase> LockType <phrase role="special">&amp;</phrase> <phrase role="identifier">lk</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">rel_time</phrase><phrase role="special">,</phrase> <phrase role="identifier">Pred</phrase> <phrase role="identifier">pred</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> <code><phrase role="identifier">lk</phrase></code> is locked by the current fiber, and either no other fiber is currently waiting on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>, or the execution of the <code><phrase role="identifier">mutex</phrase><phrase role="special">()</phrase></code> member function on the <code><phrase role="identifier">lk</phrase></code> objects supplied in the calls to <code><phrase role="identifier">wait</phrase></code>, <code><phrase role="identifier">wait_for</phrase></code> or <code><phrase role="identifier">wait_until</phrase></code> in all the fibers currently waiting on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> would return the same value as <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">mutex</phrase><phrase role="special">()</phrase></code> for this call to <code><phrase role="identifier">wait_for</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Atomically call <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">unlock</phrase><phrase role="special">()</phrase></code> and blocks the current fiber. The fiber will unblock when notified by a call to <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">notify_one</phrase><phrase role="special">()</phrase></code> or <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">notify_all</phrase><phrase role="special">()</phrase></code>, when a time interval equal to or greater than the specified <code><phrase role="identifier">rel_time</phrase></code> has elapsed. When the fiber is unblocked (for whatever reason), the lock is reacquired by invoking <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">lock</phrase><phrase role="special">()</phrase></code> before the call to <code><phrase role="identifier">wait</phrase></code> returns. The lock is also reacquired by invoking <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">lock</phrase><phrase role="special">()</phrase></code> if the function exits with an exception. The <code><phrase role="identifier">wait_for</phrase><phrase role="special">()</phrase></code> member function accepting <code><phrase role="identifier">pred</phrase></code> is shorthand for: <programlisting><phrase role="keyword">while</phrase> <phrase role="special">(</phrase> <phrase role="special">!</phrase> <phrase role="identifier">pred</phrase><phrase role="special">()</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">cv_status</phrase><phrase role="special">::</phrase><phrase role="identifier">timeout</phrase> <phrase role="special">==</phrase> <phrase role="identifier">wait_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">lk</phrase><phrase role="special">,</phrase> <phrase role="identifier">rel_time</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">pred</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> <phrase role="keyword">return</phrase> <phrase role="keyword">true</phrase><phrase role="special">;</phrase> </programlisting> (except of course that <code><phrase role="identifier">rel_time</phrase></code> is adjusted for each iteration). The point is that, even if <code><phrase role="identifier">wait_for</phrase><phrase role="special">()</phrase></code> times out, it can still return <code><phrase role="keyword">true</phrase></code> if <code><phrase role="identifier">pred</phrase><phrase role="special">()</phrase></code> returns <code><phrase role="keyword">true</phrase></code> at that time. </para> </listitem> </varlistentry> <varlistentry> <term>Postcondition:</term> <listitem> <para> <code><phrase role="identifier">lk</phrase></code> is locked by the current fiber. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">fiber_error</phrase></code> if an error occurs or timeout-related exceptions. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> The overload without <code><phrase role="identifier">pred</phrase></code> returns <code><phrase role="identifier">cv_status</phrase><phrase role="special">::</phrase><phrase role="identifier">no_timeout</phrase></code> if awakened by <code><phrase role="identifier">notify_one</phrase><phrase role="special">()</phrase></code> or <code><phrase role="identifier">notify_all</phrase><phrase role="special">()</phrase></code>, or <code><phrase role="identifier">cv_status</phrase><phrase role="special">::</phrase><phrase role="identifier">timeout</phrase></code> if awakened because at least <code><phrase role="identifier">rel_time</phrase></code> has elapsed. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> The overload accepting <code><phrase role="identifier">pred</phrase></code> returns <code><phrase role="keyword">false</phrase></code> if the call is returning because at least <code><phrase role="identifier">rel_time</phrase></code> has elapsed and the predicate returns <code><phrase role="keyword">false</phrase></code>, <code><phrase role="keyword">true</phrase></code> otherwise. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> See <emphasis role="bold">Note</emphasis> for <link linkend="condition_variable_any_wait"><code>condition_variable_any::wait()</code></link>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="class_condition_variable_bridgehead"> <phrase id="class_condition_variable"/> <link linkend="class_condition_variable">Class <code>condition_variable</code></link> </bridgehead> </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">condition_variable</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">class</phrase> condition_variable <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> condition_variable<phrase role="special">();</phrase> <phrase role="special">~</phrase>condition_variable<phrase role="special">();</phrase> condition_variable<phrase role="special">(</phrase> condition_variable <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> condition_variable <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> condition_variable <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">notify_one</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">notify_all</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> void <phrase role="identifier">wait</phrase><phrase role="special">(</phrase> std::unique_lock&lt; mutex &gt; <phrase role="special">&amp;);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> typename <phrase role="identifier">Pred</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">wait</phrase><phrase role="special">(</phrase> std::unique_lock&lt; mutex &gt; <phrase role="special">&amp;,</phrase> <phrase role="identifier">Pred</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> typename <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">cv_status</phrase> <phrase role="identifier">wait_until</phrase><phrase role="special">(</phrase> std::unique_lock&lt; mutex &gt; <phrase role="special">&amp;,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> typename <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Pred</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">wait_until</phrase><phrase role="special">(</phrase> std::unique_lock&lt; mutex &gt; <phrase role="special">&amp;,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;,</phrase> <phrase role="identifier">Pred</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> typename <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">cv_status</phrase> <phrase role="identifier">wait_for</phrase><phrase role="special">(</phrase> std::unique_lock&lt; mutex &gt; <phrase role="special">&amp;,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> typename <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Period</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Pred</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">wait_for</phrase><phrase role="special">(</phrase> std::unique_lock&lt; mutex &gt; <phrase role="special">&amp;,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;,</phrase> <phrase role="identifier">Pred</phrase><phrase role="special">);</phrase> <phrase role="special">};</phrase> <phrase role="special">}}</phrase> </programlisting> <bridgehead renderas="sect4" id="fiber.synchronization.conditions.h7"> <phrase id="fiber.synchronization.conditions.constructor0"/><link linkend="fiber.synchronization.conditions.constructor0">Constructor</link> </bridgehead> <programlisting>condition_variable<phrase role="special">()</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Creates the object. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect4" id="fiber.synchronization.conditions.h8"> <phrase id="fiber.synchronization.conditions.destructor0"/><link linkend="fiber.synchronization.conditions.destructor0">Destructor</link> </bridgehead> <programlisting><phrase role="special">~</phrase>condition_variable<phrase role="special">()</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> All fibers waiting on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> have been notified by a call to <code><phrase role="identifier">notify_one</phrase></code> or <code><phrase role="identifier">notify_all</phrase></code> (though the respective calls to <code><phrase role="identifier">wait</phrase></code>, <code><phrase role="identifier">wait_for</phrase></code> or <code><phrase role="identifier">wait_until</phrase></code> need not have returned). </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Destroys the object. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="condition_variable_notify_one_bridgehead"> <phrase id="condition_variable_notify_one"/> <link linkend="condition_variable_notify_one">Member function <code>notify_one</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">notify_one</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> If any fibers are currently <link linkend="blocking"><emphasis>blocked</emphasis></link> waiting on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> in a call to <code><phrase role="identifier">wait</phrase></code>, <code><phrase role="identifier">wait_for</phrase></code> or <code><phrase role="identifier">wait_until</phrase></code>, unblocks one of those fibers. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> It is arbitrary which waiting fiber is resumed. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="condition_variable_notify_all_bridgehead"> <phrase id="condition_variable_notify_all"/> <link linkend="condition_variable_notify_all">Member function <code>notify_all</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">notify_all</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> If any fibers are currently <link linkend="blocking"><emphasis>blocked</emphasis></link> waiting on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> in a call to <code><phrase role="identifier">wait</phrase></code>, <code><phrase role="identifier">wait_for</phrase></code> or <code><phrase role="identifier">wait_until</phrase></code>, unblocks all of those fibers. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> This is why a waiting fiber must <emphasis>also</emphasis> check for the desired program state using a mechanism external to the <code>condition_variable</code>, and retry the wait until that state is reached. A fiber waiting on a <code>condition_variable</code> might well wake up a number of times before the desired state is reached. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="condition_variable_wait_bridgehead"> <phrase id="condition_variable_wait"/> <link linkend="condition_variable_wait">Templated member function <code>wait</code>()</link> </bridgehead> </para> <programlisting>void <phrase role="identifier">wait</phrase><phrase role="special">(</phrase> std::unique_lock&lt; mutex &gt; <phrase role="special">&amp;</phrase> <phrase role="identifier">lk</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> typename <phrase role="identifier">Pred</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">wait</phrase><phrase role="special">(</phrase> std::unique_lock&lt; mutex &gt; <phrase role="special">&amp;</phrase> <phrase role="identifier">lk</phrase><phrase role="special">,</phrase> <phrase role="identifier">Pred</phrase> <phrase role="identifier">pred</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> <code><phrase role="identifier">lk</phrase></code> is locked by the current fiber, and either no other fiber is currently waiting on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>, or the execution of the <ulink url="path_to_url"><code><phrase role="identifier">mutex</phrase><phrase role="special">()</phrase></code></ulink> member function on the <code><phrase role="identifier">lk</phrase></code> objects supplied in the calls to <code><phrase role="identifier">wait</phrase></code> in all the fibers currently waiting on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> would return the same value as <code><phrase role="identifier">lk</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">mutex</phrase><phrase role="special">()</phrase></code> for this call to <code><phrase role="identifier">wait</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Atomically call <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">unlock</phrase><phrase role="special">()</phrase></code> and blocks the current fiber. The fiber will unblock when notified by a call to <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">notify_one</phrase><phrase role="special">()</phrase></code> or <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">notify_all</phrase><phrase role="special">()</phrase></code>. When the fiber is unblocked (for whatever reason), the lock is reacquired by invoking <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">lock</phrase><phrase role="special">()</phrase></code> before the call to <code><phrase role="identifier">wait</phrase></code> returns. The lock is also reacquired by invoking <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">lock</phrase><phrase role="special">()</phrase></code> if the function exits with an exception. The member function accepting <code><phrase role="identifier">pred</phrase></code> is shorthand for: <programlisting><phrase role="keyword">while</phrase> <phrase role="special">(</phrase> <phrase role="special">!</phrase> <phrase role="identifier">pred</phrase><phrase role="special">()</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">wait</phrase><phrase role="special">(</phrase> <phrase role="identifier">lk</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> </programlisting> </para> </listitem> </varlistentry> <varlistentry> <term>Postcondition:</term> <listitem> <para> <code><phrase role="identifier">lk</phrase></code> is locked by the current fiber. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">fiber_error</phrase></code> if an error occurs. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> The Precondition is a bit dense. It merely states that all the fibers concurrently calling <code><phrase role="identifier">wait</phrase></code> on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> must wait on <code><phrase role="identifier">lk</phrase></code> objects governing the <emphasis>same</emphasis> <link linkend="class_mutex"><code>mutex</code></link>. Three distinct objects are involved in any <code>condition_variable::wait()</code> call: the <code>condition_variable</code> itself, the <code><phrase role="identifier">mutex</phrase></code> coordinating access between fibers and a local lock object (e.g. <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">unique_lock</phrase></code></ulink>). In general, you can partition the lifespan of a given <code>condition_variable</code> instance into periods with one or more fibers waiting on it, separated by periods when no fibers are waiting on it. When more than one fiber is waiting on that <code>condition_variable</code>, all must pass lock objects referencing the <emphasis>same</emphasis> <code><phrase role="identifier">mutex</phrase></code> instance. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="condition_variable_wait_until_bridgehead"> <phrase id="condition_variable_wait_until"/> <link linkend="condition_variable_wait_until">Templated member function <code>wait_until</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> typename <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">cv_status</phrase> <phrase role="identifier">wait_until</phrase><phrase role="special">(</phrase> std::unique_lock&lt; mutex &gt; <phrase role="special">&amp;</phrase> <phrase role="identifier">lk</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">abs_time</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> typename <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Pred</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">wait_until</phrase><phrase role="special">(</phrase> std::unique_lock&lt; mutex &gt; <phrase role="special">&amp;</phrase> <phrase role="identifier">lk</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">abs_time</phrase><phrase role="special">,</phrase> <phrase role="identifier">Pred</phrase> <phrase role="identifier">pred</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> <code><phrase role="identifier">lk</phrase></code> is locked by the current fiber, and either no other fiber is currently waiting on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>, or the execution of the <code><phrase role="identifier">mutex</phrase><phrase role="special">()</phrase></code> member function on the <code><phrase role="identifier">lk</phrase></code> objects supplied in the calls to <code><phrase role="identifier">wait</phrase></code>, <code><phrase role="identifier">wait_for</phrase></code> or <code><phrase role="identifier">wait_until</phrase></code> in all the fibers currently waiting on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> would return the same value as <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">mutex</phrase><phrase role="special">()</phrase></code> for this call to <code><phrase role="identifier">wait_until</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Atomically call <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">unlock</phrase><phrase role="special">()</phrase></code> and blocks the current fiber. The fiber will unblock when notified by a call to <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">notify_one</phrase><phrase role="special">()</phrase></code> or <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">notify_all</phrase><phrase role="special">()</phrase></code>, when the system time would be equal to or later than the specified <code><phrase role="identifier">abs_time</phrase></code>. When the fiber is unblocked (for whatever reason), the lock is reacquired by invoking <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">lock</phrase><phrase role="special">()</phrase></code> before the call to <code><phrase role="identifier">wait_until</phrase></code> returns. The lock is also reacquired by invoking <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">lock</phrase><phrase role="special">()</phrase></code> if the function exits with an exception. The member function accepting <code><phrase role="identifier">pred</phrase></code> is shorthand for: <programlisting><phrase role="keyword">while</phrase> <phrase role="special">(</phrase> <phrase role="special">!</phrase> <phrase role="identifier">pred</phrase><phrase role="special">()</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">cv_status</phrase><phrase role="special">::</phrase><phrase role="identifier">timeout</phrase> <phrase role="special">==</phrase> <phrase role="identifier">wait_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">lk</phrase><phrase role="special">,</phrase> <phrase role="identifier">abs_time</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">pred</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="keyword">return</phrase> <phrase role="keyword">true</phrase><phrase role="special">;</phrase> </programlisting> That is, even if <code><phrase role="identifier">wait_until</phrase><phrase role="special">()</phrase></code> times out, it can still return <code><phrase role="keyword">true</phrase></code> if <code><phrase role="identifier">pred</phrase><phrase role="special">()</phrase></code> returns <code><phrase role="keyword">true</phrase></code> at that time. </para> </listitem> </varlistentry> <varlistentry> <term>Postcondition:</term> <listitem> <para> <code><phrase role="identifier">lk</phrase></code> is locked by the current fiber. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">fiber_error</phrase></code> if an error occurs or timeout-related exceptions. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> The overload without <code><phrase role="identifier">pred</phrase></code> returns <code><phrase role="identifier">cv_status</phrase><phrase role="special">::</phrase><phrase role="identifier">no_timeout</phrase></code> if awakened by <code><phrase role="identifier">notify_one</phrase><phrase role="special">()</phrase></code> or <code><phrase role="identifier">notify_all</phrase><phrase role="special">()</phrase></code>, or <code><phrase role="identifier">cv_status</phrase><phrase role="special">::</phrase><phrase role="identifier">timeout</phrase></code> if awakened because the system time is past <code><phrase role="identifier">abs_time</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> The overload accepting <code><phrase role="identifier">pred</phrase></code> returns <code><phrase role="keyword">false</phrase></code> if the call is returning because the time specified by <code><phrase role="identifier">abs_time</phrase></code> was reached and the predicate returns <code><phrase role="keyword">false</phrase></code>, <code><phrase role="keyword">true</phrase></code> otherwise. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> See <emphasis role="bold">Note</emphasis> for <link linkend="condition_variable_wait"><code>condition_variable::wait()</code></link>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="condition_variable_wait_for_bridgehead"> <phrase id="condition_variable_wait_for"/> <link linkend="condition_variable_wait_for">Templated member function <code>wait_for</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> typename <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">cv_status</phrase> <phrase role="identifier">wait_for</phrase><phrase role="special">(</phrase> std::unique_lock&lt; mutex &gt; <phrase role="special">&amp;</phrase> <phrase role="identifier">lk</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">rel_time</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> typename <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Period</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Pred</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">wait_for</phrase><phrase role="special">(</phrase> std::unique_lock&lt; mutex &gt; <phrase role="special">&amp;</phrase> <phrase role="identifier">lk</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">rel_time</phrase><phrase role="special">,</phrase> <phrase role="identifier">Pred</phrase> <phrase role="identifier">pred</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> <code><phrase role="identifier">lk</phrase></code> is locked by the current fiber, and either no other fiber is currently waiting on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>, or the execution of the <code><phrase role="identifier">mutex</phrase><phrase role="special">()</phrase></code> member function on the <code><phrase role="identifier">lk</phrase></code> objects supplied in the calls to <code><phrase role="identifier">wait</phrase></code>, <code><phrase role="identifier">wait_for</phrase></code> or <code><phrase role="identifier">wait_until</phrase></code> in all the fibers currently waiting on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> would return the same value as <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">mutex</phrase><phrase role="special">()</phrase></code> for this call to <code><phrase role="identifier">wait_for</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Atomically call <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">unlock</phrase><phrase role="special">()</phrase></code> and blocks the current fiber. The fiber will unblock when notified by a call to <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">notify_one</phrase><phrase role="special">()</phrase></code> or <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">notify_all</phrase><phrase role="special">()</phrase></code>, when a time interval equal to or greater than the specified <code><phrase role="identifier">rel_time</phrase></code> has elapsed. When the fiber is unblocked (for whatever reason), the lock is reacquired by invoking <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">lock</phrase><phrase role="special">()</phrase></code> before the call to <code><phrase role="identifier">wait</phrase></code> returns. The lock is also reacquired by invoking <code><phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">lock</phrase><phrase role="special">()</phrase></code> if the function exits with an exception. The <code><phrase role="identifier">wait_for</phrase><phrase role="special">()</phrase></code> member function accepting <code><phrase role="identifier">pred</phrase></code> is shorthand for: <programlisting><phrase role="keyword">while</phrase> <phrase role="special">(</phrase> <phrase role="special">!</phrase> <phrase role="identifier">pred</phrase><phrase role="special">()</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">cv_status</phrase><phrase role="special">::</phrase><phrase role="identifier">timeout</phrase> <phrase role="special">==</phrase> <phrase role="identifier">wait_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">lk</phrase><phrase role="special">,</phrase> <phrase role="identifier">rel_time</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">pred</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> <phrase role="keyword">return</phrase> <phrase role="keyword">true</phrase><phrase role="special">;</phrase> </programlisting> (except of course that <code><phrase role="identifier">rel_time</phrase></code> is adjusted for each iteration). The point is that, even if <code><phrase role="identifier">wait_for</phrase><phrase role="special">()</phrase></code> times out, it can still return <code><phrase role="keyword">true</phrase></code> if <code><phrase role="identifier">pred</phrase><phrase role="special">()</phrase></code> returns <code><phrase role="keyword">true</phrase></code> at that time. </para> </listitem> </varlistentry> <varlistentry> <term>Postcondition:</term> <listitem> <para> <code><phrase role="identifier">lk</phrase></code> is locked by the current fiber. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">fiber_error</phrase></code> if an error occurs or timeout-related exceptions. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> The overload without <code><phrase role="identifier">pred</phrase></code> returns <code><phrase role="identifier">cv_status</phrase><phrase role="special">::</phrase><phrase role="identifier">no_timeout</phrase></code> if awakened by <code><phrase role="identifier">notify_one</phrase><phrase role="special">()</phrase></code> or <code><phrase role="identifier">notify_all</phrase><phrase role="special">()</phrase></code>, or <code><phrase role="identifier">cv_status</phrase><phrase role="special">::</phrase><phrase role="identifier">timeout</phrase></code> if awakened because at least <code><phrase role="identifier">rel_time</phrase></code> has elapsed. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> The overload accepting <code><phrase role="identifier">pred</phrase></code> returns <code><phrase role="keyword">false</phrase></code> if the call is returning because at least <code><phrase role="identifier">rel_time</phrase></code> has elapsed and the predicate returns <code><phrase role="keyword">false</phrase></code>, <code><phrase role="keyword">true</phrase></code> otherwise. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> See <emphasis role="bold">Note</emphasis> for <link linkend="condition_variable_wait"><code>condition_variable::wait()</code></link>. </para> </listitem> </varlistentry> </variablelist> </section> <section id="fiber.synchronization.barriers"> <title><link linkend="fiber.synchronization.barriers">Barriers</link></title> <para> A barrier is a concept also known as a <emphasis>rendezvous</emphasis>, it is a synchronization point between multiple contexts of execution (fibers). The barrier is configured for a particular number of fibers (<code><phrase role="identifier">n</phrase></code>), and as fibers reach the barrier they must wait until all <code><phrase role="identifier">n</phrase></code> fibers have arrived. Once the <code><phrase role="identifier">n</phrase></code>-th fiber has reached the barrier, all the waiting fibers can proceed, and the barrier is reset. </para> <para> The fact that the barrier automatically resets is significant. Consider a case in which you launch some number of fibers and want to wait only until the first of them has completed. You might be tempted to use a <code><phrase role="identifier">barrier</phrase><phrase role="special">(</phrase><phrase role="number">2</phrase><phrase role="special">)</phrase></code> as the synchronization mechanism, making each new fiber call its <link linkend="barrier_wait"><code>barrier::wait()</code></link> method, then calling <code><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code> in the launching fiber to wait until the first other fiber completes. </para> <para> That will in fact unblock the launching fiber. The unfortunate part is that it will continue blocking the <emphasis>remaining</emphasis> fibers. </para> <para> Consider the following scenario: </para> <orderedlist> <listitem> <simpara> Fiber <quote>main</quote> launches fibers A, B, C and D, then calls <code><phrase role="identifier">barrier</phrase><phrase role="special">::</phrase><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code>. </simpara> </listitem> <listitem> <simpara> Fiber C finishes first and likewise calls <code><phrase role="identifier">barrier</phrase><phrase role="special">::</phrase><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code>. </simpara> </listitem> <listitem> <simpara> Fiber <quote>main</quote> is unblocked, as desired. </simpara> </listitem> <listitem> <simpara> Fiber B calls <code><phrase role="identifier">barrier</phrase><phrase role="special">::</phrase><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code>. Fiber B is <emphasis>blocked!</emphasis> </simpara> </listitem> <listitem> <simpara> Fiber A calls <code><phrase role="identifier">barrier</phrase><phrase role="special">::</phrase><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code>. Fibers A and B are unblocked. </simpara> </listitem> <listitem> <simpara> Fiber D calls <code><phrase role="identifier">barrier</phrase><phrase role="special">::</phrase><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code>. Fiber D is blocked indefinitely. </simpara> </listitem> </orderedlist> <para> (See also <link linkend="wait_first_simple_section">when_any, simple completion</link>.) </para> <note> <para> It is unwise to tie the lifespan of a barrier to any one of its participating fibers. Although conceptually all waiting fibers awaken <quote>simultaneously,</quote> because of the nature of fibers, in practice they will awaken one by one in indeterminate order.<footnote id="fiber.synchronization.barriers.f0"> <para> The current implementation wakes fibers in FIFO order: the first to call <code><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code> wakes first, and so forth. But it is perilous to rely on the order in which the various fibers will reach the <code><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code> call. </para> </footnote> The rest of the waiting fibers will still be blocked in <code><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code>, which must, before returning, access data members in the barrier object. </para> </note> <para> <bridgehead renderas="sect4" id="class_barrier_bridgehead"> <phrase id="class_barrier"/> <link linkend="class_barrier">Class <code>barrier</code></link> </bridgehead> </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">barrier</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">barrier</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="keyword">explicit</phrase> <phrase role="identifier">barrier</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">);</phrase> <phrase role="identifier">barrier</phrase><phrase role="special">(</phrase> <phrase role="identifier">barrier</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">barrier</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">barrier</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">wait</phrase><phrase role="special">();</phrase> <phrase role="special">};</phrase> <phrase role="special">}}</phrase> </programlisting> <para> Instances of <link linkend="class_barrier"><code>barrier</code></link> are not copyable or movable. </para> <bridgehead renderas="sect4" id="fiber.synchronization.barriers.h0"> <phrase id="fiber.synchronization.barriers.constructor"/><link linkend="fiber.synchronization.barriers.constructor">Constructor</link> </bridgehead> <programlisting><phrase role="keyword">explicit</phrase> <phrase role="identifier">barrier</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">initial</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Construct a barrier for <code><phrase role="identifier">initial</phrase></code> fibers. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">fiber_error</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Error Conditions:</term> <listitem> <para> <emphasis role="bold">invalid_argument</emphasis>: if <code><phrase role="identifier">initial</phrase></code> is zero. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="barrier_wait_bridgehead"> <phrase id="barrier_wait"/> <link linkend="barrier_wait">Member function <code>wait</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="identifier">wait</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Block until <code><phrase role="identifier">initial</phrase></code> fibers have called <code><phrase role="identifier">wait</phrase></code> on <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>. When the <code><phrase role="identifier">initial</phrase></code>-th fiber calls <code><phrase role="identifier">wait</phrase></code>, all waiting fibers are unblocked, and the barrier is reset. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> for exactly one fiber from each batch of waiting fibers, <code><phrase role="keyword">false</phrase></code> otherwise. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">fiber_error</phrase></code> </para> </listitem> </varlistentry> </variablelist> </section> <section id="fiber.synchronization.channels"> <title><link linkend="fiber.synchronization.channels">Channels</link></title> <para> A channel is a model to communicate and synchronize <code><phrase role="identifier">Threads</phrase> <phrase role="identifier">of</phrase> <phrase role="identifier">Execution</phrase></code> <footnote id="fiber.synchronization.channels.f0"> <para> The smallest ordered sequence of instructions that can be managed independently by a scheduler is called a <code><phrase role="identifier">Thread</phrase> <phrase role="identifier">of</phrase> <phrase role="identifier">Execution</phrase></code>. </para> </footnote> via message passing. </para> <anchor id="class_channel_op_status"/> <bridgehead renderas="sect4" id="fiber.synchronization.channels.h0"> <phrase id="fiber.synchronization.channels.your_sha256_hashhrase___code_"/><link linkend="fiber.synchronization.channels.your_sha256_hashhrase___code_">Enumeration <code><phrase role="identifier">channel_op_status</phrase></code></link> </bridgehead> <para> channel operations return the state of the channel. </para> <programlisting><phrase role="keyword">enum</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="special">{</phrase> <phrase role="identifier">success</phrase><phrase role="special">,</phrase> <phrase role="identifier">empty</phrase><phrase role="special">,</phrase> <phrase role="identifier">full</phrase><phrase role="special">,</phrase> <phrase role="identifier">closed</phrase><phrase role="special">,</phrase> <phrase role="identifier">timeout</phrase> <phrase role="special">};</phrase> </programlisting> <bridgehead renderas="sect4" id="fiber.synchronization.channels.h1"> <phrase id="fiber.synchronization.channels._code__phrase_role__identifier__success__phrase___code_"/><link linkend="fiber.synchronization.channels._code__phrase_role__identifier__success__phrase___code_"><code><phrase role="identifier">success</phrase></code></link> </bridgehead> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Operation was successful. </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect4" id="fiber.synchronization.channels.h2"> <phrase id="fiber.synchronization.channels._code__phrase_role__identifier__empty__phrase___code_"/><link linkend="fiber.synchronization.channels._code__phrase_role__identifier__empty__phrase___code_"><code><phrase role="identifier">empty</phrase></code></link> </bridgehead> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> channel is empty, operation failed. </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect4" id="fiber.synchronization.channels.h3"> <phrase id="fiber.synchronization.channels._code__phrase_role__identifier__full__phrase___code_"/><link linkend="fiber.synchronization.channels._code__phrase_role__identifier__full__phrase___code_"><code><phrase role="identifier">full</phrase></code></link> </bridgehead> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> channel is full, operation failed. </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect4" id="fiber.synchronization.channels.h4"> <phrase id="fiber.synchronization.channels._code__phrase_role__identifier__closed__phrase___code_"/><link linkend="fiber.synchronization.channels._code__phrase_role__identifier__closed__phrase___code_"><code><phrase role="identifier">closed</phrase></code></link> </bridgehead> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> channel is closed, operation failed. </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect4" id="fiber.synchronization.channels.h5"> <phrase id="fiber.synchronization.channels._code__phrase_role__identifier__timeout__phrase___code_"/><link linkend="fiber.synchronization.channels._code__phrase_role__identifier__timeout__phrase___code_"><code><phrase role="identifier">timeout</phrase></code></link> </bridgehead> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> The operation did not become ready before specified timeout elapsed. </para> </listitem> </varlistentry> </variablelist> <section id="fiber.synchronization.channels.buffered_channel"> <title><link linkend="fiber.synchronization.channels.buffered_channel">Buffered Channel</link></title> <para> <emphasis role="bold">Boost.Fiber</emphasis> provides a bounded, buffered channel (MPMC queue) suitable to synchonize fibers (running on same or different threads) via asynchronouss message passing. </para> <programlisting><phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">buffered_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">send</phrase><phrase role="special">(</phrase> <phrase role="identifier">channel_t</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">chan</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="number">5</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="identifier">i</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">close</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">recv</phrase><phrase role="special">(</phrase> <phrase role="identifier">channel_t</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">chan</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase><phrase role="special">;</phrase> <phrase role="keyword">while</phrase> <phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">channel_op_status</phrase><phrase role="special">::</phrase><phrase role="identifier">success</phrase> <phrase role="special">==</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">pop</phrase><phrase role="special">(</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;received &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> <phrase role="identifier">channel_t</phrase> <phrase role="identifier">chan</phrase><phrase role="special">{</phrase> <phrase role="number">2</phrase> <phrase role="special">};</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase> <phrase role="identifier">f1</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase> <phrase role="identifier">send</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="identifier">chan</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase> <phrase role="identifier">f2</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase> <phrase role="identifier">recv</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="identifier">chan</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="identifier">f1</phrase><phrase role="special">.</phrase><phrase role="identifier">join</phrase><phrase role="special">();</phrase> <phrase role="identifier">f2</phrase><phrase role="special">.</phrase><phrase role="identifier">join</phrase><phrase role="special">();</phrase> </programlisting> <para> Class <code><phrase role="identifier">buffered_channel</phrase></code> supports range-for syntax: </para> <programlisting><phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">buffered_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">foo</phrase><phrase role="special">(</phrase> <phrase role="identifier">channel_t</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">chan</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="number">2</phrase><phrase role="special">);</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="number">3</phrase><phrase role="special">);</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="number">5</phrase><phrase role="special">);</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="number">8</phrase><phrase role="special">);</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="number">12</phrase><phrase role="special">);</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">close</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">bar</phrase><phrase role="special">(</phrase> <phrase role="identifier">channel_t</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">chan</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">value</phrase> <phrase role="special">:</phrase> <phrase role="identifier">chan</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">value</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; &quot;</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> </programlisting> <para> <bridgehead renderas="sect4" id="class_buffered_channel_bridgehead"> <phrase id="class_buffered_channel"/> <link linkend="class_buffered_channel">Template <code>buffered_channel&lt;&gt;</code></link> </bridgehead> </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">buffered_channel</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">buffered_channel</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">value_type</phrase><phrase role="special">;</phrase> <phrase role="keyword">explicit</phrase> <phrase role="identifier">buffered_channel</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">);</phrase> <phrase role="identifier">buffered_channel</phrase><phrase role="special">(</phrase> <phrase role="identifier">buffered_channel</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">buffered_channel</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">buffered_channel</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">close</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">);</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">push_wait_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_duration</phrase><phrase role="special">);</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">push_wait_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_duration</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">push_wait_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_time</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">push_wait_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_time</phrase><phrase role="special">);</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">try_push</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">);</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">try_push</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">);</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">pop</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">);</phrase> <phrase role="identifier">value_type</phrase> <phrase role="identifier">value_pop</phrase><phrase role="special">();</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">pop_wait_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_duration</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">pop_wait_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_time</phrase><phrase role="special">);</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">try_pop</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">);</phrase> <phrase role="special">};</phrase> <phrase role="special">}}</phrase> </programlisting> <bridgehead renderas="sect5" id="fiber.synchronization.channels.buffered_channel.h0"> <phrase id="fiber.synchronization.channels.buffered_channel.constructor"/><link linkend="fiber.synchronization.channels.buffered_channel.constructor">Constructor</link> </bridgehead> <programlisting><phrase role="keyword">explicit</phrase> <phrase role="identifier">buffered_channel</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">capacity</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Preconditions:</term> <listitem> <para> <code><phrase role="number">2</phrase><phrase role="special">&lt;=</phrase><phrase role="identifier">capacity</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="number">0</phrase><phrase role="special">==(</phrase><phrase role="identifier">capacity</phrase> <phrase role="special">&amp;</phrase> <phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">-</phrase><phrase role="number">1</phrase><phrase role="special">))</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> The constructor constructs an object of class <code><phrase role="identifier">buffered_channel</phrase></code> with an internal buffer of size <code><phrase role="identifier">capacity</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">fiber_error</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Error Conditions:</term> <listitem> <para> <emphasis role="bold">invalid_argument</emphasis>: if <code><phrase role="number">0</phrase><phrase role="special">==</phrase><phrase role="identifier">capacity</phrase> <phrase role="special">||</phrase> <phrase role="number">0</phrase><phrase role="special">!=(</phrase><phrase role="identifier">capacity</phrase> <phrase role="special">&amp;</phrase> <phrase role="special">(</phrase><phrase role="identifier">capacity</phrase><phrase role="special">-</phrase><phrase role="number">1</phrase><phrase role="special">))</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Notes:</term> <listitem> <para> A <code><phrase role="identifier">push</phrase><phrase role="special">()</phrase></code>, <code><phrase role="identifier">push_wait_for</phrase><phrase role="special">()</phrase></code> or <code><phrase role="identifier">push_wait_until</phrase><phrase role="special">()</phrase></code> will not block until the number of values in the channel becomes equal to <code><phrase role="identifier">capacity</phrase></code>. The channel can hold only <code><phrase role="identifier">capacity</phrase> <phrase role="special">-</phrase> <phrase role="number">1</phrase></code> elements, otherwise it is considered to be full. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="buffered_channel_close_bridgehead"> <phrase id="buffered_channel_close"/> <link linkend="buffered_channel_close">Member function <code>close</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">close</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Deactivates the channel. No values can be put after calling <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">close</phrase><phrase role="special">()</phrase></code>. Fibers blocked in <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">pop</phrase><phrase role="special">()</phrase></code>, <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">pop_wait_for</phrase><phrase role="special">()</phrase></code> or <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">pop_wait_until</phrase><phrase role="special">()</phrase></code> will return <code><phrase role="identifier">closed</phrase></code>. Fibers blocked in <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">value_pop</phrase><phrase role="special">()</phrase></code> will receive an exception. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> <code><phrase role="identifier">close</phrase><phrase role="special">()</phrase></code> is like closing a pipe. It informs waiting consumers that no more values will arrive. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="buffered_channel_push_bridgehead"> <phrase id="buffered_channel_push"/> <link linkend="buffered_channel_push">Member function <code>push</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">);</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> If channel is closed, returns <code><phrase role="identifier">closed</phrase></code>. Otherwise enqueues the value in the channel, wakes up a fiber blocked on <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">pop</phrase><phrase role="special">()</phrase></code>, <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">value_pop</phrase><phrase role="special">()</phrase></code>, <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">pop_wait_for</phrase><phrase role="special">()</phrase></code> or <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">pop_wait_until</phrase><phrase role="special">()</phrase></code> and returns <code><phrase role="identifier">success</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Exceptions thrown by copy- or move-operations. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="buffered_channel_try_push_bridgehead"> <phrase id="buffered_channel_try_push"/> <link linkend="buffered_channel_try_push">Member function <code>try_push</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">try_push</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">);</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">try_push</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> If channel is closed, returns <code><phrase role="identifier">closed</phrase></code>. Otherwise enqueues the value in the channel, wakes up a fiber blocked on <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">pop</phrase><phrase role="special">()</phrase></code>, <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">value_pop</phrase><phrase role="special">()</phrase></code>, <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">pop_wait_for</phrase><phrase role="special">()</phrase></code> or <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">pop_wait_until</phrase><phrase role="special">()</phrase></code> and returns <code><phrase role="identifier">success</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Exceptions thrown by copy- or move-operations. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="buffered_channel_pop_bridgehead"> <phrase id="buffered_channel_pop"/> <link linkend="buffered_channel_pop">Member function <code>pop</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">pop</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Dequeues a value from the channel. If the channel is empty, the fiber gets suspended until at least one new item is <code><phrase role="identifier">push</phrase><phrase role="special">()</phrase></code>ed (return value <code><phrase role="identifier">success</phrase></code> and <code><phrase role="identifier">va</phrase></code> contains dequeued value) or the channel gets <code><phrase role="identifier">close</phrase><phrase role="special">()</phrase></code>d (return value <code><phrase role="identifier">closed</phrase></code>). </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Exceptions thrown by copy- or move-operations. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="buffered_channel_value_pop_bridgehead"> <phrase id="buffered_channel_value_pop"/> <link linkend="buffered_channel_value_pop">Member function <code>value_pop</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">value_type</phrase> <phrase role="identifier">value_pop</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Dequeues a value from the channel. If the channel is empty, the fiber gets suspended until at least one new item is <code><phrase role="identifier">push</phrase><phrase role="special">()</phrase></code>ed or the channel gets <code><phrase role="identifier">close</phrase><phrase role="special">()</phrase></code>d (which throws an exception). </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">fiber_error</phrase></code> if <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> is closed or by copy- or move-operations. </para> </listitem> </varlistentry> <varlistentry> <term>Error conditions:</term> <listitem> <para> <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">errc</phrase><phrase role="special">::</phrase><phrase role="identifier">operation_not_permitted</phrase></code> </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="buffered_channel_try_pop_bridgehead"> <phrase id="buffered_channel_try_pop"/> <link linkend="buffered_channel_try_pop">Member function <code>try_pop</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">try_pop</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> If channel is empty, returns <code><phrase role="identifier">empty</phrase></code>. If channel is closed, returns <code><phrase role="identifier">closed</phrase></code>. Otherwise it returns <code><phrase role="identifier">success</phrase></code> and <code><phrase role="identifier">va</phrase></code> contains the dequeued value. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Exceptions thrown by copy- or move-operations. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="buffered_channel_pop_wait_for_bridgehead"> <phrase id="buffered_channel_pop_wait_for"/> <link linkend="buffered_channel_pop_wait_for">Member function <code>pop_wait_for</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">pop_wait_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_duration</phrase><phrase role="special">)</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Accepts <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase></code> and internally computes a timeout time as (system time + <code><phrase role="identifier">timeout_duration</phrase></code>). If channel is not empty, immediately dequeues a value from the channel. Otherwise the fiber gets suspended until at least one new item is <code><phrase role="identifier">push</phrase><phrase role="special">()</phrase></code>ed (return value <code><phrase role="identifier">success</phrase></code> and <code><phrase role="identifier">va</phrase></code> contains dequeued value), or the channel gets <code><phrase role="identifier">close</phrase><phrase role="special">()</phrase></code>d (return value <code><phrase role="identifier">closed</phrase></code>), or the system time reaches the computed timeout time (return value <code><phrase role="identifier">timeout</phrase></code>). </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> timeout-related exceptions or by copy- or move-operations. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="buffered_channel_pop_wait_until_bridgehead"> <phrase id="buffered_channel_pop_wait_until"/> <link linkend="buffered_channel_pop_wait_until">Member function <code>pop_wait_until</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">pop_wait_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_time</phrase><phrase role="special">)</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Accepts a <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase></code>. If channel is not empty, immediately dequeues a value from the channel. Otherwise the fiber gets suspended until at least one new item is <code><phrase role="identifier">push</phrase><phrase role="special">()</phrase></code>ed (return value <code><phrase role="identifier">success</phrase></code> and <code><phrase role="identifier">va</phrase></code> contains dequeued value), or the channel gets <code><phrase role="identifier">close</phrase><phrase role="special">()</phrase></code>d (return value <code><phrase role="identifier">closed</phrase></code>), or the system time reaches the passed <code><phrase role="identifier">time_point</phrase></code> (return value <code><phrase role="identifier">timeout</phrase></code>). </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> timeout-related exceptions or by copy- or move-operations. </para> </listitem> </varlistentry> </variablelist> </section> <section id="fiber.synchronization.channels.unbuffered_channel"> <title><link linkend="fiber.synchronization.channels.unbuffered_channel">Unbuffered Channel</link></title> <para> <emphasis role="bold">Boost.Fiber</emphasis> provides template <code><phrase role="identifier">unbuffered_channel</phrase></code> suitable to synchonize fibers (running on same or different threads) via synchronous message passing. A fiber waiting to consume an value will block until the value is produced. If a fiber attempts to send a value through an unbuffered channel and no fiber is waiting to receive the value, the channel will block the sending fiber. </para> <para> The unbuffered channel acts as an <code><phrase role="identifier">rendezvous</phrase> <phrase role="identifier">point</phrase></code>. </para> <programlisting><phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">unbuffered_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">send</phrase><phrase role="special">(</phrase> <phrase role="identifier">channel_t</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">chan</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="number">5</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="identifier">i</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">close</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">recv</phrase><phrase role="special">(</phrase> <phrase role="identifier">channel_t</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">chan</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase><phrase role="special">;</phrase> <phrase role="keyword">while</phrase> <phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">channel_op_status</phrase><phrase role="special">::</phrase><phrase role="identifier">success</phrase> <phrase role="special">==</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">pop</phrase><phrase role="special">(</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;received &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> <phrase role="identifier">channel_t</phrase> <phrase role="identifier">chan</phrase><phrase role="special">{</phrase> <phrase role="number">1</phrase> <phrase role="special">};</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase> <phrase role="identifier">f1</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase> <phrase role="identifier">send</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="identifier">chan</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase> <phrase role="identifier">f2</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase> <phrase role="identifier">recv</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="identifier">chan</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="identifier">f1</phrase><phrase role="special">.</phrase><phrase role="identifier">join</phrase><phrase role="special">();</phrase> <phrase role="identifier">f2</phrase><phrase role="special">.</phrase><phrase role="identifier">join</phrase><phrase role="special">();</phrase> </programlisting> <para> Range-for syntax is supported: </para> <programlisting><phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">unbuffered_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">foo</phrase><phrase role="special">(</phrase> <phrase role="identifier">channel_t</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">chan</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="number">1</phrase><phrase role="special">);</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="number">2</phrase><phrase role="special">);</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="number">3</phrase><phrase role="special">);</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="number">5</phrase><phrase role="special">);</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="number">8</phrase><phrase role="special">);</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="number">12</phrase><phrase role="special">);</phrase> <phrase role="identifier">chan</phrase><phrase role="special">.</phrase><phrase role="identifier">close</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">bar</phrase><phrase role="special">(</phrase> <phrase role="identifier">channel_t</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">chan</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">value</phrase> <phrase role="special">:</phrase> <phrase role="identifier">chan</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">value</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; &quot;</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> </programlisting> <para> <bridgehead renderas="sect4" id="class_unbuffered_channel_bridgehead"> <phrase id="class_unbuffered_channel"/> <link linkend="class_unbuffered_channel">Template <code>unbuffered_channel&lt;&gt;</code></link> </bridgehead> </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">unbuffered_channel</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">unbuffered_channel</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">value_type</phrase><phrase role="special">;</phrase> <phrase role="identifier">unbuffered_channel</phrase><phrase role="special">();</phrase> <phrase role="identifier">unbuffered_channel</phrase><phrase role="special">(</phrase> <phrase role="identifier">unbuffered_channel</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">unbuffered_channel</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">unbuffered_channel</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">close</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">);</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">push_wait_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_duration</phrase><phrase role="special">);</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">push_wait_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_duration</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">push_wait_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_time</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">push_wait_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_time</phrase><phrase role="special">);</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">pop</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">);</phrase> <phrase role="identifier">value_type</phrase> <phrase role="identifier">value_pop</phrase><phrase role="special">();</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">pop_wait_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_duration</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">pop_wait_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_time</phrase><phrase role="special">);</phrase> <phrase role="special">};</phrase> <phrase role="special">}}</phrase> </programlisting> <bridgehead renderas="sect5" id="fiber.synchronization.channels.unbuffered_channel.h0"> <phrase id="fiber.synchronization.channels.unbuffered_channel.constructor"/><link linkend="fiber.synchronization.channels.unbuffered_channel.constructor">Constructor</link> </bridgehead> <programlisting><phrase role="identifier">unbuffered_channel</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> The constructor constructs an object of class <code><phrase role="identifier">unbuffered_channel</phrase></code>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="unbuffered_channel_close_bridgehead"> <phrase id="unbuffered_channel_close"/> <link linkend="unbuffered_channel_close">Member function <code>close</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">close</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Deactivates the channel. No values can be put after calling <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">close</phrase><phrase role="special">()</phrase></code>. Fibers blocked in <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">pop</phrase><phrase role="special">()</phrase></code>, <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">pop_wait_for</phrase><phrase role="special">()</phrase></code> or <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">pop_wait_until</phrase><phrase role="special">()</phrase></code> will return <code><phrase role="identifier">closed</phrase></code>. Fibers blocked in <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">value_pop</phrase><phrase role="special">()</phrase></code> will receive an exception. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> <code><phrase role="identifier">close</phrase><phrase role="special">()</phrase></code> is like closing a pipe. It informs waiting consumers that no more values will arrive. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="unbuffered_channel_push_bridgehead"> <phrase id="unbuffered_channel_push"/> <link linkend="unbuffered_channel_push">Member function <code>push</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">);</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> If channel is closed, returns <code><phrase role="identifier">closed</phrase></code>. Otherwise enqueues the value in the channel, wakes up a fiber blocked on <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">pop</phrase><phrase role="special">()</phrase></code>, <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">value_pop</phrase><phrase role="special">()</phrase></code>, <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">pop_wait_for</phrase><phrase role="special">()</phrase></code> or <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">pop_wait_until</phrase><phrase role="special">()</phrase></code> and returns <code><phrase role="identifier">success</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Exceptions thrown by copy- or move-operations. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="unbuffered_channel_pop_bridgehead"> <phrase id="unbuffered_channel_pop"/> <link linkend="unbuffered_channel_pop">Member function <code>pop</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">pop</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Dequeues a value from the channel. If the channel is empty, the fiber gets suspended until at least one new item is <code><phrase role="identifier">push</phrase><phrase role="special">()</phrase></code>ed (return value <code><phrase role="identifier">success</phrase></code> and <code><phrase role="identifier">va</phrase></code> contains dequeued value) or the channel gets <code><phrase role="identifier">close</phrase><phrase role="special">()</phrase></code>d (return value <code><phrase role="identifier">closed</phrase></code>). </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Exceptions thrown by copy- or move-operations. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="unbuffered_channel_value_pop_bridgehead"> <phrase id="unbuffered_channel_value_pop"/> <link linkend="unbuffered_channel_value_pop">Member function <code>value_pop</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">value_type</phrase> <phrase role="identifier">value_pop</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Dequeues a value from the channel. If the channel is empty, the fiber gets suspended until at least one new item is <code><phrase role="identifier">push</phrase><phrase role="special">()</phrase></code>ed or the channel gets <code><phrase role="identifier">close</phrase><phrase role="special">()</phrase></code>d (which throws an exception). </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">fiber_error</phrase></code> if <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> is closed or by copy- or move-operations. </para> </listitem> </varlistentry> <varlistentry> <term>Error conditions:</term> <listitem> <para> <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">errc</phrase><phrase role="special">::</phrase><phrase role="identifier">operation_not_permitted</phrase></code> </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="unbuffered_channel_pop_wait_for_bridgehead"> <phrase id="unbuffered_channel_pop_wait_for"/> <link linkend="unbuffered_channel_pop_wait_for">Member function <code>pop_wait_for</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">pop_wait_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_duration</phrase><phrase role="special">)</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Accepts <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase></code> and internally computes a timeout time as (system time + <code><phrase role="identifier">timeout_duration</phrase></code>). If channel is not empty, immediately dequeues a value from the channel. Otherwise the fiber gets suspended until at least one new item is <code><phrase role="identifier">push</phrase><phrase role="special">()</phrase></code>ed (return value <code><phrase role="identifier">success</phrase></code> and <code><phrase role="identifier">va</phrase></code> contains dequeued value), or the channel gets <code><phrase role="identifier">close</phrase><phrase role="special">()</phrase></code>d (return value <code><phrase role="identifier">closed</phrase></code>), or the system time reaches the computed timeout time (return value <code><phrase role="identifier">timeout</phrase></code>). </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> timeout-related exceptions or by copy- or move-operations. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="unbuffered_channel_pop_wait_until_bridgehead"> <phrase id="unbuffered_channel_pop_wait_until"/> <link linkend="unbuffered_channel_pop_wait_until">Member function <code>pop_wait_until</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_op_status</phrase> <phrase role="identifier">pop_wait_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_type</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">va</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_time</phrase><phrase role="special">)</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Accepts a <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase></code>. If channel is not empty, immediately dequeues a value from the channel. Otherwise the fiber gets suspended until at least one new item is <code><phrase role="identifier">push</phrase><phrase role="special">()</phrase></code>ed (return value <code><phrase role="identifier">success</phrase></code> and <code><phrase role="identifier">va</phrase></code> contains dequeued value), or the channel gets <code><phrase role="identifier">close</phrase><phrase role="special">()</phrase></code>d (return value <code><phrase role="identifier">closed</phrase></code>), or the system time reaches the passed <code><phrase role="identifier">time_point</phrase></code> (return value <code><phrase role="identifier">timeout</phrase></code>). </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> timeout-related exceptions or by copy- or move-operations. </para> </listitem> </varlistentry> </variablelist> </section> </section> <section id="fiber.synchronization.futures"> <title><link linkend="fiber.synchronization.futures">Futures</link></title> <bridgehead renderas="sect4" id="fiber.synchronization.futures.h0"> <phrase id="fiber.synchronization.futures.overview"/><link linkend="fiber.synchronization.futures.overview">Overview</link> </bridgehead> <para> The futures library provides a means of handling asynchronous future values, whether those values are generated by another fiber, or on a single fiber in response to external stimuli, or on-demand. </para> <para> This is done through the provision of four class templates: <link linkend="class_future"><code>future&lt;&gt;</code></link> and <link linkend="class_shared_future"><code>shared_future&lt;&gt;</code></link> which are used to retrieve the asynchronous results, and <link linkend="class_promise"><code>promise&lt;&gt;</code></link> and <link linkend="class_packaged_task"><code>packaged_task&lt;&gt;</code></link> which are used to generate the asynchronous results. </para> <para> An instance of <link linkend="class_future"><code>future&lt;&gt;</code></link> holds the one and only reference to a result. Ownership can be transferred between instances using the move constructor or move-assignment operator, but at most one instance holds a reference to a given asynchronous result. When the result is ready, it is returned from <link linkend="future_get"><code>future::get()</code></link> by rvalue-reference to allow the result to be moved or copied as appropriate for the type. </para> <para> On the other hand, many instances of <link linkend="class_shared_future"><code>shared_future&lt;&gt;</code></link> may reference the same result. Instances can be freely copied and assigned, and <link linkend="shared_future_get"><code>shared_future::get()</code></link> returns a <code><phrase role="keyword">const</phrase></code> reference so that multiple calls to <link linkend="shared_future_get"><code>shared_future::get()</code></link> are safe. You can move an instance of <link linkend="class_future"><code>future&lt;&gt;</code></link> into an instance of <link linkend="class_shared_future"><code>shared_future&lt;&gt;</code></link>, thus transferring ownership of the associated asynchronous result, but not vice-versa. </para> <para> <link linkend="fibers_async"><code>fibers::async()</code></link> is a simple way of running asynchronous tasks. A call to <code><phrase role="identifier">async</phrase><phrase role="special">()</phrase></code> spawns a fiber and returns a <link linkend="class_future"><code>future&lt;&gt;</code></link> that will deliver the result of the fiber function. </para> <bridgehead renderas="sect4" id="fiber.synchronization.futures.h1"> <phrase id="fiber.synchronization.futures.creating_asynchronous_values"/><link linkend="fiber.synchronization.futures.creating_asynchronous_values">Creating asynchronous values</link> </bridgehead> <para> You can set the value in a future with either a <link linkend="class_promise"><code>promise&lt;&gt;</code></link> or a <link linkend="class_packaged_task"><code>packaged_task&lt;&gt;</code></link>. A <link linkend="class_packaged_task"><code>packaged_task&lt;&gt;</code></link> is a callable object with <code><phrase role="keyword">void</phrase></code> return that wraps a function or callable object returning the specified type. When the <link linkend="class_packaged_task"><code>packaged_task&lt;&gt;</code></link> is invoked, it invokes the contained function in turn, and populates a future with the contained function's return value. This is an answer to the perennial question: <quote>How do I return a value from a fiber?</quote> Package the function you wish to run as a <link linkend="class_packaged_task"><code>packaged_task&lt;&gt;</code></link> and pass the packaged task to the fiber constructor. The future retrieved from the packaged task can then be used to obtain the return value. If the function throws an exception, that is stored in the future in place of the return value. </para> <programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">calculate_the_answer_to_life_the_universe_and_everything</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="number">42</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">packaged_task</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">()&gt;</phrase> <phrase role="identifier">pt</phrase><phrase role="special">(</phrase><phrase role="identifier">calculate_the_answer_to_life_the_universe_and_everything</phrase><phrase role="special">);</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">fi</phrase><phrase role="special">=</phrase><phrase role="identifier">pt</phrase><phrase role="special">.</phrase><phrase role="identifier">get_future</phrase><phrase role="special">();</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">move</phrase><phrase role="special">(</phrase><phrase role="identifier">pt</phrase><phrase role="special">)).</phrase><phrase role="identifier">detach</phrase><phrase role="special">();</phrase> <phrase role="comment">// launch task on a fiber</phrase> <phrase role="identifier">fi</phrase><phrase role="special">.</phrase><phrase role="identifier">wait</phrase><phrase role="special">();</phrase> <phrase role="comment">// wait for it to finish</phrase> <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">fi</phrase><phrase role="special">.</phrase><phrase role="identifier">is_ready</phrase><phrase role="special">());</phrase> <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">fi</phrase><phrase role="special">.</phrase><phrase role="identifier">has_value</phrase><phrase role="special">());</phrase> <phrase role="identifier">assert</phrase><phrase role="special">(!</phrase><phrase role="identifier">fi</phrase><phrase role="special">.</phrase><phrase role="identifier">has_exception</phrase><phrase role="special">());</phrase> <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">fi</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">()==</phrase><phrase role="number">42</phrase><phrase role="special">);</phrase> </programlisting> <para> A <link linkend="class_promise"><code>promise&lt;&gt;</code></link> is a bit more low level: it just provides explicit functions to store a value or an exception in the associated future. A promise can therefore be used where the value might come from more than one possible source. </para> <programlisting><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">promise</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">pi</phrase><phrase role="special">;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">int</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">fi</phrase><phrase role="special">;</phrase> <phrase role="identifier">fi</phrase><phrase role="special">=</phrase><phrase role="identifier">pi</phrase><phrase role="special">.</phrase><phrase role="identifier">get_future</phrase><phrase role="special">();</phrase> <phrase role="identifier">pi</phrase><phrase role="special">.</phrase><phrase role="identifier">set_value</phrase><phrase role="special">(</phrase><phrase role="number">42</phrase><phrase role="special">);</phrase> <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">fi</phrase><phrase role="special">.</phrase><phrase role="identifier">is_ready</phrase><phrase role="special">());</phrase> <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">fi</phrase><phrase role="special">.</phrase><phrase role="identifier">has_value</phrase><phrase role="special">());</phrase> <phrase role="identifier">assert</phrase><phrase role="special">(!</phrase><phrase role="identifier">fi</phrase><phrase role="special">.</phrase><phrase role="identifier">has_exception</phrase><phrase role="special">());</phrase> <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">fi</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">()==</phrase><phrase role="number">42</phrase><phrase role="special">);</phrase> </programlisting> <section id="fiber.synchronization.futures.future"> <title><link linkend="fiber.synchronization.futures.future">Future</link></title> <para> A future provides a mechanism to access the result of an asynchronous operation. </para> <anchor id="shared_state"/> <bridgehead renderas="sect5" id="fiber.synchronization.futures.future.h0"> <phrase id="fiber.synchronization.futures.future.shared_state"/><link linkend="fiber.synchronization.futures.future.shared_state">shared state</link> </bridgehead> <para> Behind a <link linkend="class_promise"><code>promise&lt;&gt;</code></link> and its <link linkend="class_future"><code>future&lt;&gt;</code></link> lies an unspecified object called their <emphasis>shared state</emphasis>. The shared state is what will actually hold the async result (or the exception). </para> <para> The shared state is instantiated along with the <link linkend="class_promise"><code>promise&lt;&gt;</code></link>. </para> <para> Aside from its originating <code><phrase role="identifier">promise</phrase><phrase role="special">&lt;&gt;</phrase></code>, a <link linkend="class_future"><code>future&lt;&gt;</code></link> holds a unique reference to a particular shared state. However, multiple <link linkend="class_shared_future"><code>shared_future&lt;&gt;</code></link> instances can reference the same underlying shared state. </para> <para> As <link linkend="class_packaged_task"><code>packaged_task&lt;&gt;</code></link> and <link linkend="fibers_async"><code>fibers::async()</code></link> are implemented using <link linkend="class_promise"><code>promise&lt;&gt;</code></link>, discussions of shared state apply to them as well. </para> <anchor id="class_future_status"/> <bridgehead renderas="sect5" id="fiber.synchronization.futures.future.h1"> <phrase id="fiber.synchronization.futures.future.your_sha256_hashe___code_"/><link linkend="fiber.synchronization.futures.future.your_sha256_hashe___code_">Enumeration <code><phrase role="identifier">future_status</phrase></code></link> </bridgehead> <para> Timed wait-operations (<link linkend="future_wait_for"><code>future::wait_for()</code></link> and <link linkend="future_wait_until"><code>future::wait_until()</code></link>) return the state of the future. </para> <programlisting><phrase role="keyword">enum</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">future_status</phrase> <phrase role="special">{</phrase> <phrase role="identifier">ready</phrase><phrase role="special">,</phrase> <phrase role="identifier">timeout</phrase><phrase role="special">,</phrase> <phrase role="identifier">deferred</phrase> <phrase role="comment">// not supported yet</phrase> <phrase role="special">};</phrase> </programlisting> <bridgehead renderas="sect5" id="fiber.synchronization.futures.future.h2"> <phrase id="fiber.synchronization.futures.future._code__phrase_role__identifier__ready__phrase___code_"/><link linkend="fiber.synchronization.futures.future._code__phrase_role__identifier__ready__phrase___code_"><code><phrase role="identifier">ready</phrase></code></link> </bridgehead> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> The <link linkend="shared_state">shared state</link> is ready. </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect5" id="fiber.synchronization.futures.future.h3"> <phrase id="fiber.synchronization.futures.future._code__phrase_role__identifier__timeout__phrase___code_"/><link linkend="fiber.synchronization.futures.future._code__phrase_role__identifier__timeout__phrase___code_"><code><phrase role="identifier">timeout</phrase></code></link> </bridgehead> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> The <link linkend="shared_state">shared state</link> did not become ready before timeout has passed. </para> </listitem> </varlistentry> </variablelist> <note> <para> Deferred futures are not supported. </para> </note> <para> <bridgehead renderas="sect4" id="class_future_bridgehead"> <phrase id="class_future"/> <link linkend="class_future">Template <code>future&lt;&gt;</code></link> </bridgehead> </para> <para> A <link linkend="class_future"><code>future&lt;&gt;</code></link> contains a <link linkend="shared_state">shared state</link> which is not shared with any other future. </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">future</phrase><phrase role="special">/</phrase><phrase role="identifier">future</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">future</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="identifier">future</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">future</phrase><phrase role="special">(</phrase> <phrase role="identifier">future</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">future</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">future</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">future</phrase><phrase role="special">(</phrase> <phrase role="identifier">future</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">future</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">future</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="special">~</phrase><phrase role="identifier">future</phrase><phrase role="special">();</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">valid</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">shared_future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">share</phrase><phrase role="special">();</phrase> <phrase role="identifier">R</phrase> <phrase role="identifier">get</phrase><phrase role="special">();</phrase> <phrase role="comment">// member only of generic future template</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">get</phrase><phrase role="special">();</phrase> <phrase role="comment">// member only of future&lt; R &amp; &gt; template specialization</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">get</phrase><phrase role="special">();</phrase> <phrase role="comment">// member only of future&lt; void &gt; template specialization</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception_ptr</phrase> <phrase role="identifier">get_exception_ptr</phrase><phrase role="special">();</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">wait</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future_status</phrase> <phrase role="identifier">wait_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_duration</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future_status</phrase> <phrase role="identifier">wait_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_time</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> <phrase role="special">}}</phrase> </programlisting> <bridgehead renderas="sect5" id="fiber.synchronization.futures.future.h4"> <phrase id="fiber.synchronization.futures.future.default_constructor"/><link linkend="fiber.synchronization.futures.future.default_constructor">Default constructor</link> </bridgehead> <programlisting><phrase role="identifier">future</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Creates a future with no <link linkend="shared_state">shared state</link>. After construction <code><phrase role="keyword">false</phrase> <phrase role="special">==</phrase> <phrase role="identifier">valid</phrase><phrase role="special">()</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect5" id="fiber.synchronization.futures.future.h5"> <phrase id="fiber.synchronization.futures.future.move_constructor"/><link linkend="fiber.synchronization.futures.future.move_constructor">Move constructor</link> </bridgehead> <programlisting><phrase role="identifier">future</phrase><phrase role="special">(</phrase> <phrase role="identifier">future</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Constructs a future with the <link linkend="shared_state">shared state</link> of other. After construction <code><phrase role="keyword">false</phrase> <phrase role="special">==</phrase> <phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">valid</phrase><phrase role="special">()</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect5" id="fiber.synchronization.futures.future.h6"> <phrase id="fiber.synchronization.futures.future.destructor"/><link linkend="fiber.synchronization.futures.future.destructor">Destructor</link> </bridgehead> <programlisting><phrase role="special">~</phrase><phrase role="identifier">future</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Destroys the future; ownership is abandoned. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> <code>~future()</code> does <emphasis>not</emphasis> block the calling fiber. </para> </listitem> </varlistentry> </variablelist> <para> Consider a sequence such as: </para> <orderedlist> <listitem> <simpara> instantiate <link linkend="class_promise"><code>promise&lt;&gt;</code></link> </simpara> </listitem> <listitem> <simpara> obtain its <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code> via <link linkend="promise_get_future"><code>promise::get_future()</code></link> </simpara> </listitem> <listitem> <simpara> launch <link linkend="class_fiber"><code>fiber</code></link>, capturing <code><phrase role="identifier">promise</phrase><phrase role="special">&lt;&gt;</phrase></code> </simpara> </listitem> <listitem> <simpara> destroy <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code> </simpara> </listitem> <listitem> <simpara> call <link linkend="promise_set_value"><code>promise::set_value()</code></link> </simpara> </listitem> </orderedlist> <para> The final <code><phrase role="identifier">set_value</phrase><phrase role="special">()</phrase></code> call succeeds, but the value is silently discarded: no additional <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code> can be obtained from that <code><phrase role="identifier">promise</phrase><phrase role="special">&lt;&gt;</phrase></code>. </para> <para> <bridgehead renderas="sect4" id="future_operator_assign_bridgehead"> <phrase id="future_operator_assign"/> <link linkend="future_operator_assign">Member function <code>operator=</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">future</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">future</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Moves the <link linkend="shared_state">shared state</link> of other to <code><phrase role="keyword">this</phrase></code>. After the assignment, <code><phrase role="keyword">false</phrase> <phrase role="special">==</phrase> <phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">valid</phrase><phrase role="special">()</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="future_valid_bridgehead"> <phrase id="future_valid"/> <link linkend="future_valid">Member function <code>valid</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="identifier">valid</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Returns <code><phrase role="keyword">true</phrase></code> if future contains a <link linkend="shared_state">shared state</link>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="future_share_bridgehead"> <phrase id="future_share"/> <link linkend="future_share">Member function <code>share</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">shared_future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">share</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Move the state to a <link linkend="class_shared_future"><code>shared_future&lt;&gt;</code></link>. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> a <link linkend="class_shared_future"><code>shared_future&lt;&gt;</code></link> containing the <link linkend="shared_state">shared state</link> formerly belonging to <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Postcondition:</term> <listitem> <para> <code><phrase role="keyword">false</phrase> <phrase role="special">==</phrase> <phrase role="identifier">valid</phrase><phrase role="special">()</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">future_error</phrase></code> with error condition <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">no_state</phrase></code>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="future_get_bridgehead"> <phrase id="future_get"/> <link linkend="future_get">Member function <code>get</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">R</phrase> <phrase role="identifier">get</phrase><phrase role="special">();</phrase> <phrase role="comment">// member only of generic future template</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">get</phrase><phrase role="special">();</phrase> <phrase role="comment">// member only of future&lt; R &amp; &gt; template specialization</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">get</phrase><phrase role="special">();</phrase> <phrase role="comment">// member only of future&lt; void &gt; template specialization</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> <code><phrase role="keyword">true</phrase> <phrase role="special">==</phrase> <phrase role="identifier">valid</phrase><phrase role="special">()</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> Waits until <link linkend="promise_set_value"><code>promise::set_value()</code></link> or <link linkend="promise_set_exception"><code>promise::set_exception()</code></link> is called. If <link linkend="promise_set_value"><code>promise::set_value()</code></link> is called, returns the value. If <link linkend="promise_set_exception"><code>promise::set_exception()</code></link> is called, throws the indicated exception. </para> </listitem> </varlistentry> <varlistentry> <term>Postcondition:</term> <listitem> <para> <code><phrase role="keyword">false</phrase> <phrase role="special">==</phrase> <phrase role="identifier">valid</phrase><phrase role="special">()</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">future_error</phrase></code> with error condition <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">no_state</phrase></code>, <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">broken_promise</phrase></code>. Any exception passed to <code><phrase role="identifier">promise</phrase><phrase role="special">::</phrase><phrase role="identifier">set_exception</phrase><phrase role="special">()</phrase></code>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="future_get_exception_ptr_bridgehead"> <phrase id="future_get_exception_ptr"/> <link linkend="future_get_exception_ptr">Member function <code>get_exception_ptr</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception_ptr</phrase> <phrase role="identifier">get_exception_ptr</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> <code><phrase role="keyword">true</phrase> <phrase role="special">==</phrase> <phrase role="identifier">valid</phrase><phrase role="special">()</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> Waits until <link linkend="promise_set_value"><code>promise::set_value()</code></link> or <link linkend="promise_set_exception"><code>promise::set_exception()</code></link> is called. If <code><phrase role="identifier">set_value</phrase><phrase role="special">()</phrase></code> is called, returns a default-constructed <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception_ptr</phrase></code>. If <code><phrase role="identifier">set_exception</phrase><phrase role="special">()</phrase></code> is called, returns the passed <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception_ptr</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">future_error</phrase></code> with error condition <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">no_state</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> <code><phrase role="identifier">get_exception_ptr</phrase><phrase role="special">()</phrase></code> does <emphasis>not</emphasis> invalidate the <code>future</code>. After calling <code><phrase role="identifier">get_exception_ptr</phrase><phrase role="special">()</phrase></code>, you may still call <link linkend="future_get"><code>future::get()</code></link>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="future_wait_bridgehead"> <phrase id="future_wait"/> <link linkend="future_wait">Member function <code>wait</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">wait</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Waits until <link linkend="promise_set_value"><code>promise::set_value()</code></link> or <link linkend="promise_set_exception"><code>promise::set_exception()</code></link> is called. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">future_error</phrase></code> with error condition <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">no_state</phrase></code>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="future_wait_for_bridgehead"> <phrase id="future_wait_for"/> <link linkend="future_wait_for">Templated member function <code>wait_for</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future_status</phrase> <phrase role="identifier">wait_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_duration</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Waits until <link linkend="promise_set_value"><code>promise::set_value()</code></link> or <link linkend="promise_set_exception"><code>promise::set_exception()</code></link> is called, or <code><phrase role="identifier">timeout_duration</phrase></code> has passed. </para> </listitem> </varlistentry> <varlistentry> <term>Result:</term> <listitem> <para> A <code><phrase role="identifier">future_status</phrase></code> is returned indicating the reason for returning. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">future_error</phrase></code> with error condition <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">no_state</phrase></code> or timeout-related exceptions. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="future_wait_until_bridgehead"> <phrase id="future_wait_until"/> <link linkend="future_wait_until">Templated member function <code>wait_until</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future_status</phrase> <phrase role="identifier">wait_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_time</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Waits until <link linkend="promise_set_value"><code>promise::set_value()</code></link> or <link linkend="promise_set_exception"><code>promise::set_exception()</code></link> is called, or <code><phrase role="identifier">timeout_time</phrase></code> has passed. </para> </listitem> </varlistentry> <varlistentry> <term>Result:</term> <listitem> <para> A <code><phrase role="identifier">future_status</phrase></code> is returned indicating the reason for returning. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">future_error</phrase></code> with error condition <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">no_state</phrase></code> or timeout-related exceptions. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="class_shared_future_bridgehead"> <phrase id="class_shared_future"/> <link linkend="class_shared_future">Template <code>shared_future&lt;&gt;</code></link> </bridgehead> </para> <para> A <link linkend="class_shared_future"><code>shared_future&lt;&gt;</code></link> contains a <link linkend="shared_state">shared state</link> which might be shared with other <link linkend="class_shared_future"><code>shared_future&lt;&gt;</code></link> instances. </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">future</phrase><phrase role="special">/</phrase><phrase role="identifier">future</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">shared_future</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="identifier">shared_future</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="special">~</phrase><phrase role="identifier">shared_future</phrase><phrase role="special">();</phrase> <phrase role="identifier">shared_future</phrase><phrase role="special">(</phrase> <phrase role="identifier">shared_future</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">);</phrase> <phrase role="identifier">shared_future</phrase><phrase role="special">(</phrase> <phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">shared_future</phrase><phrase role="special">(</phrase> <phrase role="identifier">shared_future</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">shared_future</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">shared_future</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">shared_future</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">shared_future</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">shared_future</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">valid</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">R</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">get</phrase><phrase role="special">();</phrase> <phrase role="comment">// member only of generic shared_future template</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">get</phrase><phrase role="special">();</phrase> <phrase role="comment">// member only of shared_future&lt; R &amp; &gt; template specialization</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">get</phrase><phrase role="special">();</phrase> <phrase role="comment">// member only of shared_future&lt; void &gt; template specialization</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception_ptr</phrase> <phrase role="identifier">get_exception_ptr</phrase><phrase role="special">();</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">wait</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future_status</phrase> <phrase role="identifier">wait_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_duration</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future_status</phrase> <phrase role="identifier">wait_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_time</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> <phrase role="special">}}</phrase> </programlisting> <bridgehead renderas="sect5" id="fiber.synchronization.futures.future.h7"> <phrase id="fiber.synchronization.futures.future.default_constructor0"/><link linkend="fiber.synchronization.futures.future.default_constructor0">Default constructor</link> </bridgehead> <programlisting><phrase role="identifier">shared_future</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Creates a shared_future with no <link linkend="shared_state">shared state</link>. After construction <code><phrase role="keyword">false</phrase> <phrase role="special">==</phrase> <phrase role="identifier">valid</phrase><phrase role="special">()</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect5" id="fiber.synchronization.futures.future.h8"> <phrase id="fiber.synchronization.futures.future.move_constructor0"/><link linkend="fiber.synchronization.futures.future.move_constructor0">Move constructor</link> </bridgehead> <programlisting><phrase role="identifier">shared_future</phrase><phrase role="special">(</phrase> <phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">shared_future</phrase><phrase role="special">(</phrase> <phrase role="identifier">shared_future</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Constructs a shared_future with the <link linkend="shared_state">shared state</link> of other. After construction <code><phrase role="keyword">false</phrase> <phrase role="special">==</phrase> <phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">valid</phrase><phrase role="special">()</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect5" id="fiber.synchronization.futures.future.h9"> <phrase id="fiber.synchronization.futures.future.copy_constructor"/><link linkend="fiber.synchronization.futures.future.copy_constructor">Copy constructor</link> </bridgehead> <programlisting><phrase role="identifier">shared_future</phrase><phrase role="special">(</phrase> <phrase role="identifier">shared_future</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Constructs a shared_future with the <link linkend="shared_state">shared state</link> of other. After construction <code><phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">valid</phrase><phrase role="special">()</phrase></code> is unchanged. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect5" id="fiber.synchronization.futures.future.h10"> <phrase id="fiber.synchronization.futures.future.destructor0"/><link linkend="fiber.synchronization.futures.future.destructor0">Destructor</link> </bridgehead> <programlisting><phrase role="special">~</phrase><phrase role="identifier">shared_future</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Destroys the shared_future; ownership is abandoned if not shared. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> <code>~shared_future()</code> does <emphasis>not</emphasis> block the calling fiber. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="shared_future_operator_assign_bridgehead"> <phrase id="shared_future_operator_assign"/> <link linkend="shared_future_operator_assign">Member function <code>operator=</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">shared_future</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">shared_future</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">shared_future</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">shared_future</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">shared_future</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Moves or copies the <link linkend="shared_state">shared state</link> of other to <code><phrase role="keyword">this</phrase></code>. After the assignment, the state of <code><phrase role="identifier">other</phrase><phrase role="special">.</phrase><phrase role="identifier">valid</phrase><phrase role="special">()</phrase></code> depends on which overload was invoked: unchanged for the overload accepting <code><phrase role="identifier">shared_future</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase></code>, otherwise <code><phrase role="keyword">false</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="shared_future_valid_bridgehead"> <phrase id="shared_future_valid"/> <link linkend="shared_future_valid">Member function <code>valid</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="identifier">valid</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Returns <code><phrase role="keyword">true</phrase></code> if shared_future contains a <link linkend="shared_state">shared state</link>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="shared_future_get_bridgehead"> <phrase id="shared_future_get"/> <link linkend="shared_future_get">Member function <code>get</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">R</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">get</phrase><phrase role="special">();</phrase> <phrase role="comment">// member only of generic shared_future template</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">get</phrase><phrase role="special">();</phrase> <phrase role="comment">// member only of shared_future&lt; R &amp; &gt; template specialization</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">get</phrase><phrase role="special">();</phrase> <phrase role="comment">// member only of shared_future&lt; void &gt; template specialization</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> <code><phrase role="keyword">true</phrase> <phrase role="special">==</phrase> <phrase role="identifier">valid</phrase><phrase role="special">()</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> Waits until <link linkend="promise_set_value"><code>promise::set_value()</code></link> or <link linkend="promise_set_exception"><code>promise::set_exception()</code></link> is called. If <link linkend="promise_set_value"><code>promise::set_value()</code></link> is called, returns the value. If <link linkend="promise_set_exception"><code>promise::set_exception()</code></link> is called, throws the indicated exception. </para> </listitem> </varlistentry> <varlistentry> <term>Postcondition:</term> <listitem> <para> <code><phrase role="keyword">false</phrase> <phrase role="special">==</phrase> <phrase role="identifier">valid</phrase><phrase role="special">()</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">future_error</phrase></code> with error condition <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">no_state</phrase></code>, <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">broken_promise</phrase></code>. Any exception passed to <code><phrase role="identifier">promise</phrase><phrase role="special">::</phrase><phrase role="identifier">set_exception</phrase><phrase role="special">()</phrase></code>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="shared_future_get_exception_ptr_bridgehead"> <phrase id="shared_future_get_exception_ptr"/> <link linkend="shared_future_get_exception_ptr">Member function <code>get_exception_ptr</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception_ptr</phrase> <phrase role="identifier">get_exception_ptr</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Precondition:</term> <listitem> <para> <code><phrase role="keyword">true</phrase> <phrase role="special">==</phrase> <phrase role="identifier">valid</phrase><phrase role="special">()</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> Waits until <link linkend="promise_set_value"><code>promise::set_value()</code></link> or <link linkend="promise_set_exception"><code>promise::set_exception()</code></link> is called. If <code><phrase role="identifier">set_value</phrase><phrase role="special">()</phrase></code> is called, returns a default-constructed <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception_ptr</phrase></code>. If <code><phrase role="identifier">set_exception</phrase><phrase role="special">()</phrase></code> is called, returns the passed <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception_ptr</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">future_error</phrase></code> with error condition <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">no_state</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> <code><phrase role="identifier">get_exception_ptr</phrase><phrase role="special">()</phrase></code> does <emphasis>not</emphasis> invalidate the <code>shared_future</code>. After calling <code><phrase role="identifier">get_exception_ptr</phrase><phrase role="special">()</phrase></code>, you may still call <link linkend="shared_future_get"><code>shared_future::get()</code></link>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="shared_future_wait_bridgehead"> <phrase id="shared_future_wait"/> <link linkend="shared_future_wait">Member function <code>wait</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">wait</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Waits until <link linkend="promise_set_value"><code>promise::set_value()</code></link> or <link linkend="promise_set_exception"><code>promise::set_exception()</code></link> is called. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">future_error</phrase></code> with error condition <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">no_state</phrase></code>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="shared_future_wait_for_bridgehead"> <phrase id="shared_future_wait_for"/> <link linkend="shared_future_wait_for">Templated member function <code>wait_for</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future_status</phrase> <phrase role="identifier">wait_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">duration</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Rep</phrase><phrase role="special">,</phrase> <phrase role="identifier">Period</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_duration</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Waits until <link linkend="promise_set_value"><code>promise::set_value()</code></link> or <link linkend="promise_set_exception"><code>promise::set_exception()</code></link> is called, or <code><phrase role="identifier">timeout_duration</phrase></code> has passed. </para> </listitem> </varlistentry> <varlistentry> <term>Result:</term> <listitem> <para> A <code><phrase role="identifier">future_status</phrase></code> is returned indicating the reason for returning. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">future_error</phrase></code> with error condition <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">no_state</phrase></code> or timeout-related exceptions. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="shared_future_wait_until_bridgehead"> <phrase id="shared_future_wait_until"/> <link linkend="shared_future_wait_until">Templated member function <code>wait_until</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future_status</phrase> <phrase role="identifier">wait_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Clock</phrase><phrase role="special">,</phrase> <phrase role="identifier">Duration</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">timeout_time</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Waits until <link linkend="promise_set_value"><code>promise::set_value()</code></link> or <link linkend="promise_set_exception"><code>promise::set_exception()</code></link> is called, or <code><phrase role="identifier">timeout_time</phrase></code> has passed. </para> </listitem> </varlistentry> <varlistentry> <term>Result:</term> <listitem> <para> A <code><phrase role="identifier">future_status</phrase></code> is returned indicating the reason for returning. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">future_error</phrase></code> with error condition <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">no_state</phrase></code> or timeout-related exceptions. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="fibers_async_bridgehead"> <phrase id="fibers_async"/> <link linkend="fibers_async">Non-member function <code>fibers::async()</code></link> </bridgehead> </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">future</phrase><phrase role="special">/</phrase><phrase role="identifier">async</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Function</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of_t</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">decay_t</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Function</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">decay_t</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">async</phrase><phrase role="special">(</phrase> <phrase role="identifier">Function</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">fn</phrase><phrase role="special">,</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">args</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Function</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of_t</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">decay_t</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Function</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">decay_t</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">async</phrase><phrase role="special">(</phrase> <link linkend="class_launch"><code><phrase role="identifier">launch</phrase></code></link> <phrase role="identifier">policy</phrase><phrase role="special">,</phrase> <phrase role="identifier">Function</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">fn</phrase><phrase role="special">,</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">args</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <link linkend="stack_allocator_concept"><code><phrase role="identifier">StackAllocator</phrase></code></link><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Function</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of_t</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">decay_t</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Function</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">decay_t</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">async</phrase><phrase role="special">(</phrase> <link linkend="class_launch"><code><phrase role="identifier">launch</phrase></code></link> <phrase role="identifier">policy</phrase><phrase role="special">,</phrase> <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">allocator_arg_t</phrase></code></ulink><phrase role="special">,</phrase> <link linkend="stack_allocator_concept"><code><phrase role="identifier">StackAllocator</phrase></code></link> <phrase role="identifier">salloc</phrase><phrase role="special">,</phrase> <phrase role="identifier">Function</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">fn</phrase><phrase role="special">,</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">args</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <link linkend="stack_allocator_concept"><code><phrase role="identifier">StackAllocator</phrase></code></link><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Function</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of_t</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">decay_t</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Function</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">decay_t</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">async</phrase><phrase role="special">(</phrase> <link linkend="class_launch"><code><phrase role="identifier">launch</phrase></code></link> <phrase role="identifier">policy</phrase><phrase role="special">,</phrase> <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">allocator_arg_t</phrase></code></ulink><phrase role="special">,</phrase> <link linkend="stack_allocator_concept"><code><phrase role="identifier">StackAllocator</phrase></code></link> <phrase role="identifier">salloc</phrase><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase> <phrase role="identifier">alloc</phrase><phrase role="special">,</phrase> <phrase role="identifier">Function</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">fn</phrase><phrase role="special">,</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">args</phrase><phrase role="special">);</phrase> <phrase role="special">}}</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Executes <code><phrase role="identifier">fn</phrase></code> in a <link linkend="class_fiber"><code>fiber</code></link> and returns an associated <link linkend="class_future"><code>future&lt;&gt;</code></link>. </para> </listitem> </varlistentry> <varlistentry> <term>Result:</term> <listitem> <para> <programlisting><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of_t</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">decay_t</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Function</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">decay_t</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase></programlisting> representing the <link linkend="shared_state">shared state</link> associated with the asynchronous execution of <code><phrase role="identifier">fn</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">fiber_error</phrase></code> or <code><phrase role="identifier">future_error</phrase></code> if an error occurs. </para> </listitem> </varlistentry> <varlistentry> <term>Notes:</term> <listitem> <para> The overloads accepting <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">allocator_arg_t</phrase></code></ulink> use the passed <link linkend="stack_allocator_concept"><code><phrase role="identifier">StackAllocator</phrase></code></link> when constructing the launched <code><phrase role="identifier">fiber</phrase></code>. The overloads accepting <link linkend="class_launch"><code>launch</code></link> use the passed <code><phrase role="identifier">launch</phrase></code> when constructing the launched <code><phrase role="identifier">fiber</phrase></code>. The default <code><phrase role="identifier">launch</phrase></code> is <code><phrase role="identifier">post</phrase></code>, as for the <code><phrase role="identifier">fiber</phrase></code> constructor. </para> </listitem> </varlistentry> </variablelist> <note> <para> Deferred futures are not supported. </para> </note> </section> <section id="fiber.synchronization.futures.promise"> <title><anchor id="class_promise"/><link linkend="fiber.synchronization.futures.promise">Template <code><phrase role="identifier">promise</phrase><phrase role="special">&lt;&gt;</phrase></code></link></title> <para> A <link linkend="class_promise"><code>promise&lt;&gt;</code></link> provides a mechanism to store a value (or exception) that can later be retrieved from the corresponding <link linkend="class_future"><code>future&lt;&gt;</code></link> object. <code><phrase role="identifier">promise</phrase><phrase role="special">&lt;&gt;</phrase></code> and <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code> communicate via their underlying <link linkend="shared_state">shared state</link>. </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">future</phrase><phrase role="special">/</phrase><phrase role="identifier">promise</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">promise</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="identifier">promise</phrase><phrase role="special">();</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <ulink url="path_to_url"><code><phrase role="identifier">Allocator</phrase></code></ulink> <phrase role="special">&gt;</phrase> <phrase role="identifier">promise</phrase><phrase role="special">(</phrase> <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">allocator_arg_t</phrase></code></ulink><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase><phrase role="special">);</phrase> <phrase role="identifier">promise</phrase><phrase role="special">(</phrase> <phrase role="identifier">promise</phrase> <phrase role="special">&amp;&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">promise</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">promise</phrase> <phrase role="special">&amp;&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">promise</phrase><phrase role="special">(</phrase> <phrase role="identifier">promise</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">promise</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">promise</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="special">~</phrase><phrase role="identifier">promise</phrase><phrase role="special">();</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase> <phrase role="identifier">promise</phrase> <phrase role="special">&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">get_future</phrase><phrase role="special">();</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">set_value</phrase><phrase role="special">(</phrase> <phrase role="identifier">R</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;);</phrase> <phrase role="comment">// member only of generic promise template</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">set_value</phrase><phrase role="special">(</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&amp;&amp;);</phrase> <phrase role="comment">// member only of generic promise template</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">set_value</phrase><phrase role="special">(</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&amp;);</phrase> <phrase role="comment">// member only of promise&lt; R &amp; &gt; template</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">set_value</phrase><phrase role="special">();</phrase> <phrase role="comment">// member only of promise&lt; void &gt; template</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">set_exception</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception_ptr</phrase> <phrase role="identifier">p</phrase><phrase role="special">);</phrase> <phrase role="special">};</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase> <phrase role="identifier">promise</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;,</phrase> <phrase role="identifier">promise</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> </programlisting> <bridgehead renderas="sect5" id="fiber.synchronization.futures.promise.h0"> <phrase id="fiber.synchronization.futures.promise.default_constructor"/><link linkend="fiber.synchronization.futures.promise.default_constructor">Default constructor</link> </bridgehead> <programlisting><phrase role="identifier">promise</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Creates a promise with an empty <link linkend="shared_state">shared state</link>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Exceptions caused by memory allocation. </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect5" id="fiber.synchronization.futures.promise.h1"> <phrase id="fiber.synchronization.futures.promise.constructor"/><link linkend="fiber.synchronization.futures.promise.constructor">Constructor</link> </bridgehead> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <ulink url="path_to_url"><code><phrase role="identifier">Allocator</phrase></code></ulink> <phrase role="special">&gt;</phrase> <phrase role="identifier">promise</phrase><phrase role="special">(</phrase> <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">allocator_arg_t</phrase></code></ulink><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase> <phrase role="identifier">alloc</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Creates a promise with an empty <link linkend="shared_state">shared state</link> by using <code><phrase role="identifier">alloc</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Exceptions caused by memory allocation. </para> </listitem> </varlistentry> <varlistentry> <term>See also:</term> <listitem> <para> <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">allocator_arg_t</phrase></code></ulink> </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect5" id="fiber.synchronization.futures.promise.h2"> <phrase id="fiber.synchronization.futures.promise.move_constructor"/><link linkend="fiber.synchronization.futures.promise.move_constructor">Move constructor</link> </bridgehead> <programlisting><phrase role="identifier">promise</phrase><phrase role="special">(</phrase> <phrase role="identifier">promise</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Creates a promise by moving the <link linkend="shared_state">shared state</link> from <code><phrase role="identifier">other</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Postcondition:</term> <listitem> <para> <code><phrase role="identifier">other</phrase></code> contains no valid shared state. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect5" id="fiber.synchronization.futures.promise.h3"> <phrase id="fiber.synchronization.futures.promise.destructor"/><link linkend="fiber.synchronization.futures.promise.destructor">Destructor</link> </bridgehead> <programlisting><phrase role="special">~</phrase><phrase role="identifier">promise</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Destroys <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> and abandons the <link linkend="shared_state">shared state</link> if shared state is ready; otherwise stores <code><phrase role="identifier">future_error</phrase></code> with error condition <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">broken_promise</phrase></code> as if by <link linkend="promise_set_exception"><code>promise::set_exception()</code></link>: the shared state is set ready. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="promise_operator_assign_bridgehead"> <phrase id="promise_operator_assign"/> <link linkend="promise_operator_assign">Member function <code>operator=</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">promise</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">promise</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Transfers the ownership of <link linkend="shared_state">shared state</link> to <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Postcondition:</term> <listitem> <para> <code><phrase role="identifier">other</phrase></code> contains no valid shared state. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="promise_swap_bridgehead"> <phrase id="promise_swap"/> <link linkend="promise_swap">Member function <code>swap</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase> <phrase role="identifier">promise</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Swaps the <link linkend="shared_state">shared state</link> between other and <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="promise_get_future_bridgehead"> <phrase id="promise_get_future"/> <link linkend="promise_get_future">Member function <code>get_future</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">get_future</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> A <link linkend="class_future"><code>future&lt;&gt;</code></link> with the same <link linkend="shared_state">shared state</link>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">future_error</phrase></code> with <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">future_already_retrieved</phrase></code> or <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">no_state</phrase></code>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="promise_set_value_bridgehead"> <phrase id="promise_set_value"/> <link linkend="promise_set_value">Member function <code>set_value</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">set_value</phrase><phrase role="special">(</phrase> <phrase role="identifier">R</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase> <phrase role="comment">// member only of generic promise template</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">set_value</phrase><phrase role="special">(</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase> <phrase role="comment">// member only of generic promise template</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">set_value</phrase><phrase role="special">(</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase> <phrase role="comment">// member only of promise&lt; R &amp; &gt; template</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">set_value</phrase><phrase role="special">();</phrase> <phrase role="comment">// member only of promise&lt; void &gt; template</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Store the result in the <link linkend="shared_state">shared state</link> and marks the state as ready. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">future_error</phrase></code> with <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">future_already_satisfied</phrase></code> or <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">no_state</phrase></code>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="promise_set_exception_bridgehead"> <phrase id="promise_set_exception"/> <link linkend="promise_set_exception">Member function <code>set_exception</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">set_exception</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception_ptr</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Store an exception pointer in the <link linkend="shared_state">shared state</link> and marks the state as ready. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">future_error</phrase></code> with <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">future_already_satisfied</phrase></code> or <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">no_state</phrase></code>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="swap_for_promise_bridgehead"> <phrase id="swap_for_promise"/> <link linkend="swap_for_promise">Non-member function <code>swap()</code></link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase> <phrase role="identifier">promise</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">l</phrase><phrase role="special">,</phrase> <phrase role="identifier">promise</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">r</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Same as <code><phrase role="identifier">l</phrase><phrase role="special">.</phrase><phrase role="identifier">swap</phrase><phrase role="special">(</phrase> <phrase role="identifier">r</phrase><phrase role="special">)</phrase></code>. </para> </listitem> </varlistentry> </variablelist> </section> <section id="fiber.synchronization.futures.packaged_task"> <title><anchor id="class_packaged_task"/><link linkend="fiber.synchronization.futures.packaged_task">Template <code><phrase role="identifier">packaged_task</phrase><phrase role="special">&lt;&gt;</phrase></code></link></title> <para> A <link linkend="class_packaged_task"><code>packaged_task&lt;&gt;</code></link> wraps a callable target that returns a value so that the return value can be computed asynchronously. </para> <para> Conventional usage of <code><phrase role="identifier">packaged_task</phrase><phrase role="special">&lt;&gt;</phrase></code> is like this: </para> <orderedlist> <listitem> <simpara> Instantiate <code><phrase role="identifier">packaged_task</phrase><phrase role="special">&lt;&gt;</phrase></code> with template arguments matching the signature of the callable. Pass the callable to the <link linkend="packaged_task_packaged_task">constructor</link>. </simpara> </listitem> <listitem> <simpara> Call <link linkend="packaged_task_get_future"><code>packaged_task::get_future()</code></link> and capture the returned <link linkend="class_future"><code>future&lt;&gt;</code></link> instance. </simpara> </listitem> <listitem> <simpara> Launch a <link linkend="class_fiber"><code>fiber</code></link> to run the new <code><phrase role="identifier">packaged_task</phrase><phrase role="special">&lt;&gt;</phrase></code>, passing any arguments required by the original callable. </simpara> </listitem> <listitem> <simpara> Call <link linkend="fiber_detach"><code>fiber::detach()</code></link> on the newly-launched <code><phrase role="identifier">fiber</phrase></code>. </simpara> </listitem> <listitem> <simpara> At some later point, retrieve the result from the <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code>. </simpara> </listitem> </orderedlist> <para> This is, in fact, pretty much what <link linkend="fibers_async"><code>fibers::async()</code></link> encapsulates. </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">future</phrase><phrase role="special">/</phrase><phrase role="identifier">packaged_task</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">R</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">packaged_task</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase><phrase role="special">(</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="identifier">packaged_task</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">explicit</phrase> <phrase role="identifier">packaged_task</phrase><phrase role="special">(</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <ulink url="path_to_url"><code><phrase role="identifier">Allocator</phrase></code></ulink> <phrase role="special">&gt;</phrase> <phrase role="identifier">packaged_task</phrase><phrase role="special">(</phrase> <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">allocator_arg_t</phrase></code></ulink><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;,</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;);</phrase> <phrase role="identifier">packaged_task</phrase><phrase role="special">(</phrase> <phrase role="identifier">packaged_task</phrase> <phrase role="special">&amp;&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">packaged_task</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">packaged_task</phrase> <phrase role="special">&amp;&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">packaged_task</phrase><phrase role="special">(</phrase> <phrase role="identifier">packaged_task</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">packaged_task</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">packaged_task</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="special">~</phrase><phrase role="identifier">packaged_task</phrase><phrase role="special">();</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase> <phrase role="identifier">packaged_task</phrase> <phrase role="special">&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">valid</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">get_future</phrase><phrase role="special">();</phrase> <phrase role="keyword">void</phrase> <phrase role="keyword">operator</phrase><phrase role="special">()(</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">...);</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">reset</phrase><phrase role="special">();</phrase> <phrase role="special">};</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Signature</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase> <phrase role="identifier">packaged_task</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Signature</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;,</phrase> <phrase role="identifier">packaged_task</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Signature</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="special">}}</phrase> </programlisting> <bridgehead renderas="sect5" id="fiber.synchronization.futures.packaged_task.h0"> <phrase id="fiber.synchronization.futures.packaged_task.your_sha256_hashk__phrase__phrase_role__special______phrase___code_"/><link linkend="fiber.synchronization.futures.packaged_task.your_sha256_hashk__phrase__phrase_role__special______phrase___code_">Default constructor <code><phrase role="identifier">packaged_task</phrase><phrase role="special">()</phrase></code></link> </bridgehead> <programlisting><phrase role="identifier">packaged_task</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Constructs an object of class <code><phrase role="identifier">packaged_task</phrase></code> with no <link linkend="shared_state">shared state</link>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <anchor id="packaged_task_packaged_task"/> <bridgehead renderas="sect5" id="fiber.synchronization.futures.packaged_task.h1"> <phrase id="fiber.synchronization.futures.packaged_task.your_sha256_hashask__phrase__phrase_role__special______phrase___code_"/><link linkend="fiber.synchronization.futures.packaged_task.your_sha256_hashask__phrase__phrase_role__special______phrase___code_">Templated constructor <code><phrase role="identifier">packaged_task</phrase><phrase role="special">()</phrase></code></link> </bridgehead> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">explicit</phrase> <phrase role="identifier">packaged_task</phrase><phrase role="special">(</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">fn</phrase><phrase role="special">);</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <ulink url="path_to_url"><code><phrase role="identifier">Allocator</phrase></code></ulink> <phrase role="special">&gt;</phrase> <phrase role="identifier">packaged_task</phrase><phrase role="special">(</phrase> <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">allocator_arg_t</phrase></code></ulink><phrase role="special">,</phrase> <phrase role="identifier">Allocator</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">alloc</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">fn</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Constructs an object of class <code><phrase role="identifier">packaged_task</phrase></code> with a <link linkend="shared_state">shared state</link> and copies or moves the callable target <code><phrase role="identifier">fn</phrase></code> to internal storage. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Exceptions caused by memory allocation. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> The signature of <code><phrase role="identifier">Fn</phrase></code> should have a return type convertible to <code><phrase role="identifier">R</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>See also:</term> <listitem> <para> <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">allocator_arg_t</phrase></code></ulink> </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect5" id="fiber.synchronization.futures.packaged_task.h2"> <phrase id="fiber.synchronization.futures.packaged_task.move_constructor"/><link linkend="fiber.synchronization.futures.packaged_task.move_constructor">Move constructor</link> </bridgehead> <programlisting><phrase role="identifier">packaged_task</phrase><phrase role="special">(</phrase> <phrase role="identifier">packaged_task</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Creates a packaged_task by moving the <link linkend="shared_state">shared state</link> from <code><phrase role="identifier">other</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Postcondition:</term> <listitem> <para> <code><phrase role="identifier">other</phrase></code> contains no valid shared state. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect5" id="fiber.synchronization.futures.packaged_task.h3"> <phrase id="fiber.synchronization.futures.packaged_task.destructor"/><link linkend="fiber.synchronization.futures.packaged_task.destructor">Destructor</link> </bridgehead> <programlisting><phrase role="special">~</phrase><phrase role="identifier">packaged_task</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Destroys <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> and abandons the <link linkend="shared_state">shared state</link> if shared state is ready; otherwise stores <code><phrase role="identifier">future_error</phrase></code> with error condition <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">broken_promise</phrase></code> as if by <link linkend="promise_set_exception"><code>promise::set_exception()</code></link>: the shared state is set ready. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="packaged_task_operator_assign_bridgehead"> <phrase id="packaged_task_operator_assign"/> <link linkend="packaged_task_operator_assign">Member function <code>operator=</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">packaged_task</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">packaged_task</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Transfers the ownership of <link linkend="shared_state">shared state</link> to <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Postcondition:</term> <listitem> <para> <code><phrase role="identifier">other</phrase></code> contains no valid shared state. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="packaged_task_swap_bridgehead"> <phrase id="packaged_task_swap"/> <link linkend="packaged_task_swap">Member function <code>swap</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase> <phrase role="identifier">packaged_task</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">other</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Swaps the <link linkend="shared_state">shared state</link> between other and <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="packaged_task_valid_bridgehead"> <phrase id="packaged_task_valid"/> <link linkend="packaged_task_valid">Member function <code>valid</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="identifier">valid</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Returns <code><phrase role="keyword">true</phrase></code> if <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code> contains a <link linkend="shared_state">shared state</link>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="packaged_task_get_future_bridgehead"> <phrase id="packaged_task_get_future"/> <link linkend="packaged_task_get_future">Member function <code>get_future</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">R</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">get_future</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> A <link linkend="class_future"><code>future&lt;&gt;</code></link> with the same <link linkend="shared_state">shared state</link>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">future_error</phrase></code> with <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">future_already_retrieved</phrase></code> or <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">no_state</phrase></code>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="packaged_task_operator_apply_bridgehead"> <phrase id="packaged_task_operator_apply"/> <link linkend="packaged_task_operator_apply">Member function <code>operator()</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="keyword">operator</phrase><phrase role="special">()(</phrase> <phrase role="identifier">Args</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">args</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Invokes the stored callable target. Any exception thrown by the callable target <code><phrase role="identifier">fn</phrase></code> is stored in the <link linkend="shared_state">shared state</link> as if by <link linkend="promise_set_exception"><code>promise::set_exception()</code></link>. Otherwise, the value returned by <code><phrase role="identifier">fn</phrase></code> is stored in the shared state as if by <link linkend="promise_set_value"><code>promise::set_value()</code></link>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">future_error</phrase></code> with <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">no_state</phrase></code>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="packaged_task_reset_bridgehead"> <phrase id="packaged_task_reset"/> <link linkend="packaged_task_reset">Member function <code>reset</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">reset</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Resets the <link linkend="shared_state">shared state</link> and abandons the result of previous executions. A new shared state is constructed. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">future_error</phrase></code> with <code><phrase role="identifier">future_errc</phrase><phrase role="special">::</phrase><phrase role="identifier">no_state</phrase></code>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="swap_for_packaged_task_bridgehead"> <phrase id="swap_for_packaged_task"/> <link linkend="swap_for_packaged_task">Non-member function <code>swap()</code></link> </bridgehead> </para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Signature</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">swap</phrase><phrase role="special">(</phrase> <phrase role="identifier">packaged_task</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Signature</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">l</phrase><phrase role="special">,</phrase> <phrase role="identifier">packaged_task</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Signature</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">r</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Same as <code><phrase role="identifier">l</phrase><phrase role="special">.</phrase><phrase role="identifier">swap</phrase><phrase role="special">(</phrase> <phrase role="identifier">r</phrase><phrase role="special">)</phrase></code>. </para> </listitem> </varlistentry> </variablelist> </section> </section> </section> <section id="fiber.fls"> <title><link linkend="fiber.fls">Fiber local storage</link></title> <bridgehead renderas="sect3" id="fiber.fls.h0"> <phrase id="fiber.fls.synopsis"/><link linkend="fiber.fls.synopsis">Synopsis</link> </bridgehead> <para> Fiber local storage allows a separate instance of a given data item for each fiber. </para> <bridgehead renderas="sect3" id="fiber.fls.h1"> <phrase id="fiber.fls.cleanup_at_fiber_exit"/><link linkend="fiber.fls.cleanup_at_fiber_exit">Cleanup at fiber exit</link> </bridgehead> <para> When a fiber exits, the objects associated with each <link linkend="class_fiber_specific_ptr"><code>fiber_specific_ptr</code></link> instance are destroyed. By default, the object pointed to by a pointer <code><phrase role="identifier">p</phrase></code> is destroyed by invoking <code><phrase role="keyword">delete</phrase> <phrase role="identifier">p</phrase></code>, but this can be overridden for a specific instance of <link linkend="class_fiber_specific_ptr"><code>fiber_specific_ptr</code></link> by providing a cleanup routine <code><phrase role="identifier">func</phrase></code> to the constructor. In this case, the object is destroyed by invoking <code><phrase role="identifier">func</phrase><phrase role="special">(</phrase><phrase role="identifier">p</phrase><phrase role="special">)</phrase></code>. The cleanup functions are called in an unspecified order. </para> <para> <bridgehead renderas="sect4" id="class_fiber_specific_ptr_bridgehead"> <phrase id="class_fiber_specific_ptr"/> <link linkend="class_fiber_specific_ptr">Class <code>fiber_specific_ptr</code></link> </bridgehead> </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">fss</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">fiber_specific_ptr</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">element_type</phrase><phrase role="special">;</phrase> <phrase role="identifier">fiber_specific_ptr</phrase><phrase role="special">();</phrase> <phrase role="keyword">explicit</phrase> <phrase role="identifier">fiber_specific_ptr</phrase><phrase role="special">(</phrase> <phrase role="keyword">void</phrase><phrase role="special">(*</phrase><phrase role="identifier">fn</phrase><phrase role="special">)(</phrase><phrase role="identifier">T</phrase><phrase role="special">*)</phrase> <phrase role="special">);</phrase> <phrase role="special">~</phrase><phrase role="identifier">fiber_specific_ptr</phrase><phrase role="special">();</phrase> <phrase role="identifier">fiber_specific_ptr</phrase><phrase role="special">(</phrase> <phrase role="identifier">fiber_specific_ptr</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">fiber_specific_ptr</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">fiber_specific_ptr</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">*</phrase> <phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">*</phrase> <phrase role="keyword">operator</phrase><phrase role="special">-&gt;()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">*()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">*</phrase> <phrase role="identifier">release</phrase><phrase role="special">();</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">reset</phrase><phrase role="special">(</phrase> <phrase role="identifier">T</phrase> <phrase role="special">*);</phrase> <phrase role="special">};</phrase> <phrase role="special">}}</phrase> </programlisting> <bridgehead renderas="sect3" id="fiber.fls.h2"> <phrase id="fiber.fls.constructor"/><link linkend="fiber.fls.constructor">Constructor</link> </bridgehead> <programlisting><phrase role="identifier">fiber_specific_ptr</phrase><phrase role="special">();</phrase> <phrase role="keyword">explicit</phrase> <phrase role="identifier">fiber_specific_ptr</phrase><phrase role="special">(</phrase> <phrase role="keyword">void</phrase><phrase role="special">(*</phrase><phrase role="identifier">fn</phrase><phrase role="special">)(</phrase><phrase role="identifier">T</phrase><phrase role="special">*)</phrase> <phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Requires:</term> <listitem> <para> <code><phrase role="keyword">delete</phrase> <phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code> is well-formed; <code><phrase role="identifier">fn</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">())</phrase></code> does not throw </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Construct a <link linkend="class_fiber_specific_ptr"><code>fiber_specific_ptr</code></link> object for storing a pointer to an object of type <code><phrase role="identifier">T</phrase></code> specific to each fiber. When <code><phrase role="identifier">reset</phrase><phrase role="special">()</phrase></code> is called, or the fiber exits, <link linkend="class_fiber_specific_ptr"><code>fiber_specific_ptr</code></link> calls <code><phrase role="identifier">fn</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">())</phrase></code>. If the no-arguments constructor is used, the default <code><phrase role="keyword">delete</phrase></code>-based cleanup function will be used to destroy the fiber-local objects. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">fiber_error</phrase></code> if an error occurs. </para> </listitem> </varlistentry> </variablelist> <bridgehead renderas="sect3" id="fiber.fls.h3"> <phrase id="fiber.fls.destructor"/><link linkend="fiber.fls.destructor">Destructor</link> </bridgehead> <programlisting><phrase role="special">~</phrase><phrase role="identifier">fiber_specific_ptr</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Requires:</term> <listitem> <para> All the fiber specific instances associated to this <link linkend="class_fiber_specific_ptr"><code>fiber_specific_ptr</code></link> (except maybe the one associated to this fiber) must be nullptr. </para> </listitem> </varlistentry> <varlistentry> <term>Effects:</term> <listitem> <para> Calls <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">reset</phrase><phrase role="special">()</phrase></code> to clean up the associated value for the current fiber, and destroys <code><phrase role="special">*</phrase><phrase role="keyword">this</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Remarks:</term> <listitem> <para> The requirement is an implementation restriction. If the destructor promised to delete instances for all fibers, the implementation would be forced to maintain a list of all the fibers having an associated specific ptr, which is against the goal of fiber specific data. In general, a <link linkend="class_fiber_specific_ptr"><code>fiber_specific_ptr</code></link> should outlive the fibers that use it. </para> </listitem> </varlistentry> </variablelist> <note> <para> Care needs to be taken to ensure that any fibers still running after an instance of <link linkend="class_fiber_specific_ptr"><code>fiber_specific_ptr</code></link> has been destroyed do not call any member functions on that instance. </para> </note> <para> <bridgehead renderas="sect4" id="fiber_specific_ptr_get_bridgehead"> <phrase id="fiber_specific_ptr_get"/> <link linkend="fiber_specific_ptr_get">Member function <code>get</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">T</phrase> <phrase role="special">*</phrase> <phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> The pointer associated with the current fiber. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <note> <para> The initial value associated with an instance of <link linkend="class_fiber_specific_ptr"><code>fiber_specific_ptr</code></link> is <code><phrase role="keyword">nullptr</phrase></code> for each fiber. </para> </note> <para> <bridgehead renderas="sect4" id="fiber_specific_ptr_operator_arrow_bridgehead"> <phrase id="fiber_specific_ptr_operator_arrow"/> <link linkend="fiber_specific_ptr_operator_arrow">Member function <code>operator-&gt;</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">T</phrase> <phrase role="special">*</phrase> <phrase role="keyword">operator</phrase><phrase role="special">-&gt;()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Requires:</term> <listitem> <para> <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code> is not <code><phrase role="keyword">nullptr</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="fiber_specific_ptr_operator_star_bridgehead"> <phrase id="fiber_specific_ptr_operator_star"/> <link linkend="fiber_specific_ptr_operator_star">Member function <code>operator*</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">T</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">*()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Requires:</term> <listitem> <para> <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code> is not <code><phrase role="keyword">nullptr</phrase></code>. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="special">*(</phrase><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">())</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="fiber_specific_ptr_release_bridgehead"> <phrase id="fiber_specific_ptr_release"/> <link linkend="fiber_specific_ptr_release">Member function <code>release</code>()</link> </bridgehead> </para> <programlisting><phrase role="identifier">T</phrase> <phrase role="special">*</phrase> <phrase role="identifier">release</phrase><phrase role="special">();</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Return <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code> and store <code><phrase role="keyword">nullptr</phrase></code> as the pointer associated with the current fiber without invoking the cleanup function. </para> </listitem> </varlistentry> <varlistentry> <term>Postcondition:</term> <listitem> <para> <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">()==</phrase><phrase role="keyword">nullptr</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="fiber_specific_ptr_reset_bridgehead"> <phrase id="fiber_specific_ptr_reset"/> <link linkend="fiber_specific_ptr_reset">Member function <code>reset</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">reset</phrase><phrase role="special">(</phrase> <phrase role="identifier">T</phrase> <phrase role="special">*</phrase> <phrase role="identifier">new_value</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> If <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">()!=</phrase><phrase role="identifier">new_value</phrase></code> and <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code> is not <code><phrase role="keyword">nullptr</phrase></code>, invoke <code><phrase role="keyword">delete</phrase> <phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code> or <code><phrase role="identifier">fn</phrase><phrase role="special">(</phrase><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">())</phrase></code> as appropriate. Store <code><phrase role="identifier">new_value</phrase></code> as the pointer associated with the current fiber. </para> </listitem> </varlistentry> <varlistentry> <term>Postcondition:</term> <listitem> <para> <code><phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get</phrase><phrase role="special">()==</phrase><phrase role="identifier">new_value</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Exception raised during cleanup of previous value. </para> </listitem> </varlistentry> </variablelist> </section> <section id="fiber.migration"> <title><anchor id="migration"/><link linkend="fiber.migration">Migrating fibers between threads</link></title> <bridgehead renderas="sect3" id="fiber.migration.h0"> <phrase id="fiber.migration.overview"/><link linkend="fiber.migration.overview">Overview</link> </bridgehead> <para> Each fiber owns a stack and manages its execution state, including all registers and CPU flags, the instruction pointer and the stack pointer. That means, in general, a fiber is not bound to a specific thread.<footnote id="fiber.migration.f0"> <para> The <quote>main</quote> fiber on each thread, that is, the fiber on which the thread is launched, cannot migrate to any other thread. Also <emphasis role="bold">Boost.Fiber</emphasis> implicitly creates a dispatcher fiber for each thread &mdash; this cannot migrate either. </para> </footnote><superscript>,</superscript><footnote id="fiber.migration.f1"> <para> Of course it would be problematic to migrate a fiber that relies on <link linkend="thread_local_storage">thread-local storage</link>. </para> </footnote> </para> <para> Migrating a fiber from a logical CPU with heavy workload to another logical CPU with a lighter workload might speed up the overall execution. Note that in the case of NUMA-architectures, it is not always advisable to migrate data between threads. Suppose fiber <emphasis>f</emphasis> is running on logical CPU <emphasis>cpu0</emphasis> which belongs to NUMA node <emphasis>node0</emphasis>. The data of <emphasis>f</emphasis> are allocated on the physical memory located at <emphasis>node0</emphasis>. Migrating the fiber from <emphasis>cpu0</emphasis> to another logical CPU <emphasis>cpuX</emphasis> which is part of a different NUMA node <emphasis>nodeX</emphasis> might reduce the performance of the application due to increased latency of memory access. </para> <para> Only fibers that are contained in <link linkend="class_algorithm"><code>algorithm</code></link>&#8217;s ready queue can migrate between threads. You cannot migrate a running fiber, nor one that is <link linkend="blocking"><emphasis>blocked</emphasis></link>. You cannot migrate a fiber if its <link linkend="context_is_context"><code>context::is_context()</code></link> method returns <code><phrase role="keyword">true</phrase></code> for <code><phrase role="identifier">pinned_context</phrase></code>. </para> <para> In <emphasis role="bold">Boost.Fiber</emphasis> a fiber is migrated by invoking <link linkend="context_detach"><code>context::detach()</code></link> on the thread from which the fiber migrates and <link linkend="context_attach"><code>context::attach()</code></link> on the thread to which the fiber migrates. </para> <para> Thus, fiber migration is accomplished by sharing state between instances of a user-coded <link linkend="class_algorithm"><code>algorithm</code></link> implementation running on different threads. The fiber&#8217;s original thread calls <link linkend="algorithm_awakened"><code>algorithm::awakened()</code></link>, passing the fiber&#8217;s <link linkend="class_context"><code>context</code></link><literal>*</literal>. The <code><phrase role="identifier">awakened</phrase><phrase role="special">()</phrase></code> implementation calls <link linkend="context_detach"><code>context::detach()</code></link>. </para> <para> At some later point, when the same or a different thread calls <link linkend="algorithm_pick_next"><code>algorithm::pick_next()</code></link>, the <code><phrase role="identifier">pick_next</phrase><phrase role="special">()</phrase></code> implementation selects a ready fiber and calls <link linkend="context_attach"><code>context::attach()</code></link> on it before returning it. </para> <para> As stated above, a <code><phrase role="identifier">context</phrase></code> for which <code><phrase role="identifier">is_context</phrase><phrase role="special">(</phrase><phrase role="identifier">pinned_context</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="keyword">true</phrase></code> must never be passed to either <link linkend="context_detach"><code>context::detach()</code></link> or <link linkend="context_attach"><code>context::attach()</code></link>. It may only be returned from <code><phrase role="identifier">pick_next</phrase><phrase role="special">()</phrase></code> called by the <emphasis>same</emphasis> thread that passed that context to <code><phrase role="identifier">awakened</phrase><phrase role="special">()</phrase></code>. </para> <bridgehead renderas="sect3" id="fiber.migration.h1"> <phrase id="fiber.migration.example_of_work_sharing"/><link linkend="fiber.migration.example_of_work_sharing">Example of work sharing</link> </bridgehead> <para> In the example <ulink url="../../examples/work_sharing.cpp">work_sharing.cpp</ulink> multiple worker fibers are created on the main thread. Each fiber gets a character as parameter at construction. This character is printed out ten times. Between each iteration the fiber calls <link linkend="this_fiber_yield"><code>this_fiber::yield()</code></link>. That puts the fiber in the ready queue of the fiber-scheduler <emphasis>shared_ready_queue</emphasis>, running in the current thread. The next fiber ready to be executed is dequeued from the shared ready queue and resumed by <emphasis>shared_ready_queue</emphasis> running on <emphasis>any participating thread</emphasis>. </para> <para> All instances of <emphasis>shared_ready_queue</emphasis> share one global concurrent queue, used as ready queue. This mechanism shares all worker fibers between all instances of <emphasis>shared_ready_queue</emphasis>, thus between all participating threads. </para> <bridgehead renderas="sect3" id="fiber.migration.h2"> <phrase id="fiber.migration.setup_of_threads_and_fibers"/><link linkend="fiber.migration.setup_of_threads_and_fibers">Setup of threads and fibers</link> </bridgehead> <para> In <code><phrase role="identifier">main</phrase><phrase role="special">()</phrase></code> the fiber-scheduler is installed and the worker fibers and the threads are launched. </para> <para> <programlisting><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">algo</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_work</phrase> <phrase role="special">&gt;();</phrase> <co id="fiber.migration.c0" linkends="fiber.migration.c1" /> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">char</phrase> <phrase role="identifier">c</phrase> <phrase role="special">:</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase><phrase role="special">(</phrase><phrase role="string">&quot;abcdefghijklmnopqrstuvwxyz&quot;</phrase><phrase role="special">))</phrase> <phrase role="special">{</phrase> <co id="fiber.migration.c2" linkends="fiber.migration.c3" /> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase><phrase role="special">([</phrase><phrase role="identifier">c</phrase><phrase role="special">](){</phrase> <phrase role="identifier">whatevah</phrase><phrase role="special">(</phrase> <phrase role="identifier">c</phrase><phrase role="special">);</phrase> <phrase role="special">}).</phrase><phrase role="identifier">detach</phrase><phrase role="special">();</phrase> <phrase role="special">++</phrase><phrase role="identifier">fiber_count</phrase><phrase role="special">;</phrase> <co id="fiber.migration.c4" linkends="fiber.migration.c5" /> <phrase role="special">}</phrase> <phrase role="identifier">barrier</phrase> <phrase role="identifier">b</phrase><phrase role="special">(</phrase> <phrase role="number">4</phrase><phrase role="special">);</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">thread</phrase> <phrase role="identifier">threads</phrase><phrase role="special">[]</phrase> <phrase role="special">=</phrase> <phrase role="special">{</phrase> <co id="fiber.migration.c6" linkends="fiber.migration.c7" /> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">thread</phrase><phrase role="special">(</phrase> <phrase role="identifier">thread</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">b</phrase><phrase role="special">),</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">thread</phrase><phrase role="special">(</phrase> <phrase role="identifier">thread</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">b</phrase><phrase role="special">),</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">thread</phrase><phrase role="special">(</phrase> <phrase role="identifier">thread</phrase><phrase role="special">,</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">b</phrase><phrase role="special">)</phrase> <phrase role="special">};</phrase> <phrase role="identifier">b</phrase><phrase role="special">.</phrase><phrase role="identifier">wait</phrase><phrase role="special">();</phrase> <co id="fiber.migration.c8" linkends="fiber.migration.c9" /> <phrase role="special">{</phrase> <phrase role="identifier">lock_type</phrase><co id="fiber.migration.c10" linkends="fiber.migration.c11" /> <phrase role="identifier">lk</phrase><phrase role="special">(</phrase> <phrase role="identifier">mtx_count</phrase><phrase role="special">);</phrase> <phrase role="identifier">cnd_count</phrase><phrase role="special">.</phrase><phrase role="identifier">wait</phrase><phrase role="special">(</phrase> <phrase role="identifier">lk</phrase><phrase role="special">,</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="number">0</phrase> <phrase role="special">==</phrase> <phrase role="identifier">fiber_count</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="special">);</phrase> <co id="fiber.migration.c12" linkends="fiber.migration.c13" /> <phrase role="special">}</phrase> <co id="fiber.migration.c14" linkends="fiber.migration.c15" /> <phrase role="identifier">BOOST_ASSERT</phrase><phrase role="special">(</phrase> <phrase role="number">0</phrase> <phrase role="special">==</phrase> <phrase role="identifier">fiber_count</phrase><phrase role="special">);</phrase> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">thread</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">t</phrase> <phrase role="special">:</phrase> <phrase role="identifier">threads</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <co id="fiber.migration.c16" linkends="fiber.migration.c17" /> <phrase role="identifier">t</phrase><phrase role="special">.</phrase><phrase role="identifier">join</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> </programlisting> </para> <calloutlist> <callout arearefs="fiber.migration.c0" id="fiber.migration.c1"> <para> Install the scheduling algorithm <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">algo</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_work</phrase></code> in the main thread too, so each new fiber gets launched into the shared pool. </para> </callout> <callout arearefs="fiber.migration.c2" id="fiber.migration.c3"> <para> Launch a number of worker fibers; each worker fiber picks up a character that is passed as parameter to fiber-function <code><phrase role="identifier">whatevah</phrase></code>. Each worker fiber gets detached. </para> </callout> <callout arearefs="fiber.migration.c4" id="fiber.migration.c5"> <para> Increment fiber counter for each new fiber. </para> </callout> <callout arearefs="fiber.migration.c6" id="fiber.migration.c7"> <para> Launch a couple of threads that join the work sharing. </para> </callout> <callout arearefs="fiber.migration.c8" id="fiber.migration.c9"> <para> sync with other threads: allow them to start processing </para> </callout> <callout arearefs="fiber.migration.c10" id="fiber.migration.c11"> <para> <code><phrase role="identifier">lock_type</phrase></code> is typedef'ed as <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">unique_lock</phrase></code></ulink>&lt; <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">mutex</phrase></code></ulink> &gt; </para> </callout> <callout arearefs="fiber.migration.c12" id="fiber.migration.c13"> <para> Suspend main fiber and resume worker fibers in the meanwhile. Main fiber gets resumed (e.g returns from <code><phrase role="identifier">condition_variable_any</phrase><phrase role="special">::</phrase><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code>) if all worker fibers are complete. </para> </callout> <callout arearefs="fiber.migration.c14" id="fiber.migration.c15"> <para> Releasing lock of mtx_count is required before joining the threads, otherwise the other threads would be blocked inside condition_variable::wait() and would never return (deadlock). </para> </callout> <callout arearefs="fiber.migration.c16" id="fiber.migration.c17"> <para> wait for threads to terminate </para> </callout> </calloutlist> <para> The start of the threads is synchronized with a barrier. The main fiber of each thread (including main thread) is suspended until all worker fibers are complete. When the main fiber returns from <link linkend="condition_variable_wait"><code>condition_variable::wait()</code></link>, the thread terminates: the main thread joins all other threads. </para> <para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">thread</phrase><phrase role="special">(</phrase> <phrase role="identifier">barrier</phrase> <phrase role="special">*</phrase> <phrase role="identifier">b</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">ostringstream</phrase> <phrase role="identifier">buffer</phrase><phrase role="special">;</phrase> <phrase role="identifier">buffer</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;thread started &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase role="identifier">get_id</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">buffer</phrase><phrase role="special">.</phrase><phrase role="identifier">str</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">flush</phrase><phrase role="special">;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">algo</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_work</phrase> <phrase role="special">&gt;();</phrase> <co id="fiber.migration.c18" linkends="fiber.migration.c19" /> <phrase role="identifier">b</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">wait</phrase><phrase role="special">();</phrase> <co id="fiber.migration.c20" linkends="fiber.migration.c21" /> <phrase role="identifier">lock_type</phrase> <phrase role="identifier">lk</phrase><phrase role="special">(</phrase> <phrase role="identifier">mtx_count</phrase><phrase role="special">);</phrase> <phrase role="identifier">cnd_count</phrase><phrase role="special">.</phrase><phrase role="identifier">wait</phrase><phrase role="special">(</phrase> <phrase role="identifier">lk</phrase><phrase role="special">,</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="number">0</phrase> <phrase role="special">==</phrase> <phrase role="identifier">fiber_count</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="special">);</phrase> <co id="fiber.migration.c22" linkends="fiber.migration.c23" /> <phrase role="identifier">BOOST_ASSERT</phrase><phrase role="special">(</phrase> <phrase role="number">0</phrase> <phrase role="special">==</phrase> <phrase role="identifier">fiber_count</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> </programlisting> </para> <calloutlist> <callout arearefs="fiber.migration.c18" id="fiber.migration.c19"> <para> Install the scheduling algorithm <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">algo</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_work</phrase></code> in order to join the work sharing. </para> </callout> <callout arearefs="fiber.migration.c20" id="fiber.migration.c21"> <para> sync with other threads: allow them to start processing </para> </callout> <callout arearefs="fiber.migration.c22" id="fiber.migration.c23"> <para> Suspend main fiber and resume worker fibers in the meanwhile. Main fiber gets resumed (e.g returns from <code><phrase role="identifier">condition_variable_any</phrase><phrase role="special">::</phrase><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code>) if all worker fibers are complete. </para> </callout> </calloutlist> <para> Each worker fiber executes function <code><phrase role="identifier">whatevah</phrase><phrase role="special">()</phrase></code> with character <code><phrase role="identifier">me</phrase></code> as parameter. The fiber yields in a loop and prints out a message if it was migrated to another thread. </para> <para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">whatevah</phrase><phrase role="special">(</phrase> <phrase role="keyword">char</phrase> <phrase role="identifier">me</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">try</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">thread</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase> <phrase role="identifier">my_thread</phrase> <phrase role="special">=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase role="identifier">get_id</phrase><phrase role="special">();</phrase> <co id="fiber.migration.c24" linkends="fiber.migration.c25" /> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">ostringstream</phrase> <phrase role="identifier">buffer</phrase><phrase role="special">;</phrase> <phrase role="identifier">buffer</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;fiber &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">me</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; started on thread &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">my_thread</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="char">'\n'</phrase><phrase role="special">;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">buffer</phrase><phrase role="special">.</phrase><phrase role="identifier">str</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">flush</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">unsigned</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="number">10</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <co id="fiber.migration.c26" linkends="fiber.migration.c27" /> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">yield</phrase><phrase role="special">();</phrase> <co id="fiber.migration.c28" linkends="fiber.migration.c29" /> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">thread</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase> <phrase role="identifier">new_thread</phrase> <phrase role="special">=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase role="identifier">get_id</phrase><phrase role="special">();</phrase> <co id="fiber.migration.c30" linkends="fiber.migration.c31" /> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">new_thread</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">my_thread</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <co id="fiber.migration.c32" linkends="fiber.migration.c33" /> <phrase role="identifier">my_thread</phrase> <phrase role="special">=</phrase> <phrase role="identifier">new_thread</phrase><phrase role="special">;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">ostringstream</phrase> <phrase role="identifier">buffer</phrase><phrase role="special">;</phrase> <phrase role="identifier">buffer</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;fiber &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">me</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; switched to thread &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">my_thread</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="char">'\n'</phrase><phrase role="special">;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">buffer</phrase><phrase role="special">.</phrase><phrase role="identifier">str</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">flush</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="special">}</phrase> <phrase role="identifier">lock_type</phrase> <phrase role="identifier">lk</phrase><phrase role="special">(</phrase> <phrase role="identifier">mtx_count</phrase><phrase role="special">);</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="number">0</phrase> <phrase role="special">==</phrase> <phrase role="special">--</phrase><phrase role="identifier">fiber_count</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <co id="fiber.migration.c34" linkends="fiber.migration.c35" /> <phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">unlock</phrase><phrase role="special">();</phrase> <phrase role="identifier">cnd_count</phrase><phrase role="special">.</phrase><phrase role="identifier">notify_all</phrase><phrase role="special">();</phrase> <co id="fiber.migration.c36" linkends="fiber.migration.c37" /> <phrase role="special">}</phrase> <phrase role="special">}</phrase> </programlisting> </para> <calloutlist> <callout arearefs="fiber.migration.c24" id="fiber.migration.c25"> <para> get ID of initial thread </para> </callout> <callout arearefs="fiber.migration.c26" id="fiber.migration.c27"> <para> loop ten times </para> </callout> <callout arearefs="fiber.migration.c28" id="fiber.migration.c29"> <para> yield to other fibers </para> </callout> <callout arearefs="fiber.migration.c30" id="fiber.migration.c31"> <para> get ID of current thread </para> </callout> <callout arearefs="fiber.migration.c32" id="fiber.migration.c33"> <para> test if fiber was migrated to another thread </para> </callout> <callout arearefs="fiber.migration.c34" id="fiber.migration.c35"> <para> Decrement fiber counter for each completed fiber. </para> </callout> <callout arearefs="fiber.migration.c36" id="fiber.migration.c37"> <para> Notify all fibers waiting on <code><phrase role="identifier">cnd_count</phrase></code>. </para> </callout> </calloutlist> <bridgehead renderas="sect3" id="fiber.migration.h3"> <phrase id="fiber.migration.scheduling_fibers"/><link linkend="fiber.migration.scheduling_fibers">Scheduling fibers</link> </bridgehead> <para> The fiber scheduler <code><phrase role="identifier">shared_ready_queue</phrase></code> is like <code><phrase role="identifier">round_robin</phrase></code>, except that it shares a common ready queue among all participating threads. A thread participates in this pool by executing <link linkend="use_scheduling_algorithm"><code>use_scheduling_algorithm()</code></link> before any other <emphasis role="bold">Boost.Fiber</emphasis> operation. </para> <para> The important point about the ready queue is that it&#8217;s a class static, common to all instances of shared_ready_queue. Fibers that are enqueued via <link linkend="algorithm_awakened"><code>algorithm::awakened()</code></link> (fibers that are ready to be resumed) are thus available to all threads. It is required to reserve a separate, scheduler-specific queue for the thread&#8217;s main fiber and dispatcher fibers: these may <emphasis>not</emphasis> be shared between threads! When we&#8217;re passed either of these fibers, push it there instead of in the shared queue: it would be Bad News for thread B to retrieve and attempt to execute thread A&#8217;s main fiber. </para> <para> [awakened_ws] </para> <para> When <link linkend="algorithm_pick_next"><code>algorithm::pick_next()</code></link> gets called inside one thread, a fiber is dequeued from <emphasis>rqueue_</emphasis> and will be resumed in that thread. </para> <para> [pick_next_ws] </para> <para> The source code above is found in <ulink url="../../examples/work_sharing.cpp">work_sharing.cpp</ulink>. </para> </section> <section id="fiber.callbacks"> <title><anchor id="callbacks"/><link linkend="fiber.callbacks">Integrating Fibers with Asynchronous Callbacks</link></title> <section id="fiber.callbacks.overview"> <title><link linkend="fiber.callbacks.overview">Overview</link></title> <para> One of the primary benefits of <emphasis role="bold">Boost.Fiber</emphasis> is the ability to use asynchronous operations for efficiency, while at the same time structuring the calling code <emphasis>as if</emphasis> the operations were synchronous. Asynchronous operations provide completion notification in a variety of ways, but most involve a callback function of some kind. This section discusses tactics for interfacing <emphasis role="bold">Boost.Fiber</emphasis> with an arbitrary async operation. </para> <para> For purposes of illustration, consider the following hypothetical API: </para> <para> <programlisting><phrase role="keyword">class</phrase> <phrase role="identifier">AsyncAPI</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="comment">// constructor acquires some resource that can be read and written</phrase> <phrase role="identifier">AsyncAPI</phrase><phrase role="special">();</phrase> <phrase role="comment">// callbacks accept an int error code; 0 == success</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">errorcode</phrase><phrase role="special">;</phrase> <phrase role="comment">// write callback only needs to indicate success or failure</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">init_write</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">data</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">callback</phrase><phrase role="special">);</phrase> <phrase role="comment">// read callback needs to accept both errorcode and data</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">init_read</phrase><phrase role="special">(</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">callback</phrase><phrase role="special">);</phrase> <phrase role="comment">// ... other operations ...</phrase> <phrase role="special">};</phrase> </programlisting> </para> <para> The significant points about each of <code><phrase role="identifier">init_write</phrase><phrase role="special">()</phrase></code> and <code><phrase role="identifier">init_read</phrase><phrase role="special">()</phrase></code> are: </para> <itemizedlist> <listitem> <simpara> The <code><phrase role="identifier">AsyncAPI</phrase></code> method only initiates the operation. It returns immediately, while the requested operation is still pending. </simpara> </listitem> <listitem> <simpara> The method accepts a callback. When the operation completes, the callback is called with relevant parameters (error code, data if applicable). </simpara> </listitem> </itemizedlist> <para> We would like to wrap these asynchronous methods in functions that appear synchronous by blocking the calling fiber until the operation completes. This lets us use the wrapper function&#8217;s return value to deliver relevant data. </para> <tip> <para> <link linkend="class_promise"><code>promise&lt;&gt;</code></link> and <link linkend="class_future"><code>future&lt;&gt;</code></link> are your friends here. </para> </tip> </section> <section id="fiber.callbacks.return_errorcode"> <title><link linkend="fiber.callbacks.return_errorcode">Return Errorcode</link></title> <para> The <code><phrase role="identifier">AsyncAPI</phrase><phrase role="special">::</phrase><phrase role="identifier">init_write</phrase><phrase role="special">()</phrase></code> callback passes only an <code><phrase role="identifier">errorcode</phrase></code>. If we simply want the blocking wrapper to return that <code><phrase role="identifier">errorcode</phrase></code>, this is an extremely straightforward use of <link linkend="class_promise"><code>promise&lt;&gt;</code></link> and <link linkend="class_future"><code>future&lt;&gt;</code></link>: </para> <para> <programlisting><phrase role="identifier">AsyncAPI</phrase><phrase role="special">::</phrase><phrase role="identifier">errorcode</phrase> <phrase role="identifier">write_ec</phrase><phrase role="special">(</phrase> <phrase role="identifier">AsyncAPI</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">api</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">data</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">promise</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">AsyncAPI</phrase><phrase role="special">::</phrase><phrase role="identifier">errorcode</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">promise</phrase><phrase role="special">;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">AsyncAPI</phrase><phrase role="special">::</phrase><phrase role="identifier">errorcode</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future</phrase><phrase role="special">(</phrase> <phrase role="identifier">promise</phrase><phrase role="special">.</phrase><phrase role="identifier">get_future</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase> <phrase role="comment">// In general, even though we block waiting for future::get() and therefore</phrase> <phrase role="comment">// won't destroy 'promise' until promise::set_value() has been called, we</phrase> <phrase role="comment">// are advised that with threads it's possible for ~promise() to be</phrase> <phrase role="comment">// entered before promise::set_value() has returned. While that shouldn't</phrase> <phrase role="comment">// happen with fibers::promise, a robust way to deal with the lifespan</phrase> <phrase role="comment">// issue is to bind 'promise' into our lambda. Since promise is move-only,</phrase> <phrase role="comment">// use initialization capture.</phrase> <phrase role="preprocessor">#if</phrase> <phrase role="special">!</phrase> <phrase role="identifier">defined</phrase><phrase role="special">(</phrase><phrase role="identifier">BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES</phrase><phrase role="special">)</phrase> <phrase role="identifier">api</phrase><phrase role="special">.</phrase><phrase role="identifier">init_write</phrase><phrase role="special">(</phrase> <phrase role="identifier">data</phrase><phrase role="special">,</phrase> <phrase role="special">[</phrase><phrase role="identifier">promise</phrase><phrase role="special">=</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">move</phrase><phrase role="special">(</phrase> <phrase role="identifier">promise</phrase><phrase role="special">)](</phrase> <phrase role="identifier">AsyncAPI</phrase><phrase role="special">::</phrase><phrase role="identifier">errorcode</phrase> <phrase role="identifier">ec</phrase><phrase role="special">)</phrase> <phrase role="keyword">mutable</phrase> <phrase role="special">{</phrase> <phrase role="identifier">promise</phrase><phrase role="special">.</phrase><phrase role="identifier">set_value</phrase><phrase role="special">(</phrase> <phrase role="identifier">ec</phrase><phrase role="special">);</phrase> <phrase role="special">});</phrase> <phrase role="preprocessor">#else</phrase> <phrase role="comment">// defined(BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES)</phrase> <phrase role="identifier">api</phrase><phrase role="special">.</phrase><phrase role="identifier">init_write</phrase><phrase role="special">(</phrase> <phrase role="identifier">data</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">([](</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">promise</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">AsyncAPI</phrase><phrase role="special">::</phrase><phrase role="identifier">errorcode</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">promise</phrase><phrase role="special">,</phrase> <phrase role="identifier">AsyncAPI</phrase><phrase role="special">::</phrase><phrase role="identifier">errorcode</phrase> <phrase role="identifier">ec</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">promise</phrase><phrase role="special">.</phrase><phrase role="identifier">set_value</phrase><phrase role="special">(</phrase> <phrase role="identifier">ec</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">move</phrase><phrase role="special">(</phrase> <phrase role="identifier">promise</phrase><phrase role="special">),</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">placeholders</phrase><phrase role="special">::</phrase><phrase role="identifier">_1</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="preprocessor">#endif</phrase> <phrase role="comment">// BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">future</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> All we have to do is: </para> <orderedlist> <listitem> <simpara> Instantiate a <code><phrase role="identifier">promise</phrase><phrase role="special">&lt;&gt;</phrase></code> of correct type. </simpara> </listitem> <listitem> <simpara> Obtain its <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code>. </simpara> </listitem> <listitem> <simpara> Arrange for the callback to call <link linkend="promise_set_value"><code>promise::set_value()</code></link>. </simpara> </listitem> <listitem> <simpara> Block on <link linkend="future_get"><code>future::get()</code></link>. </simpara> </listitem> </orderedlist> <note> <para> This tactic for resuming a pending fiber works even if the callback is called on a different thread than the one on which the initiating fiber is running. In fact, <ulink url="../../examples/adapt_callbacks.cpp">the example program&#8217;s</ulink> dummy <code><phrase role="identifier">AsyncAPI</phrase></code> implementation illustrates that: it simulates async I/O by launching a new thread that sleeps briefly and then calls the relevant callback. </para> </note> </section> <section id="fiber.callbacks.success_or_exception"> <title><link linkend="fiber.callbacks.success_or_exception">Success or Exception</link></title> <para> A wrapper more aligned with modern C++ practice would use an exception, rather than an <code><phrase role="identifier">errorcode</phrase></code>, to communicate failure to its caller. This is straightforward to code in terms of <code><phrase role="identifier">write_ec</phrase><phrase role="special">()</phrase></code>: </para> <para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">write</phrase><phrase role="special">(</phrase> <phrase role="identifier">AsyncAPI</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">api</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">data</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">AsyncAPI</phrase><phrase role="special">::</phrase><phrase role="identifier">errorcode</phrase> <phrase role="identifier">ec</phrase> <phrase role="special">=</phrase> <phrase role="identifier">write_ec</phrase><phrase role="special">(</phrase> <phrase role="identifier">api</phrase><phrase role="special">,</phrase> <phrase role="identifier">data</phrase><phrase role="special">);</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">ec</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">throw</phrase> <phrase role="identifier">make_exception</phrase><phrase role="special">(</phrase><phrase role="string">&quot;write&quot;</phrase><phrase role="special">,</phrase> <phrase role="identifier">ec</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> The point is that since each fiber has its own stack, you need not repeat messy boilerplate: normal encapsulation works. </para> </section> <section id="fiber.callbacks.return_errorcode_or_data"> <title><link linkend="fiber.callbacks.return_errorcode_or_data">Return Errorcode or Data</link></title> <para> Things get a bit more interesting when the async operation&#8217;s callback passes multiple data items of interest. One approach would be to use <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">pair</phrase><phrase role="special">&lt;&gt;</phrase></code> to capture both: </para> <para> <programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">pair</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">AsyncAPI</phrase><phrase role="special">::</phrase><phrase role="identifier">errorcode</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">read_ec</phrase><phrase role="special">(</phrase> <phrase role="identifier">AsyncAPI</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">api</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">pair</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">AsyncAPI</phrase><phrase role="special">::</phrase><phrase role="identifier">errorcode</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">result_pair</phrase><phrase role="special">;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">promise</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">result_pair</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">promise</phrase><phrase role="special">;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">result_pair</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future</phrase><phrase role="special">(</phrase> <phrase role="identifier">promise</phrase><phrase role="special">.</phrase><phrase role="identifier">get_future</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase> <phrase role="comment">// We promise that both 'promise' and 'future' will survive until our</phrase> <phrase role="comment">// lambda has been called.</phrase> <phrase role="preprocessor">#if</phrase> <phrase role="special">!</phrase> <phrase role="identifier">defined</phrase><phrase role="special">(</phrase><phrase role="identifier">BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES</phrase><phrase role="special">)</phrase> <phrase role="identifier">api</phrase><phrase role="special">.</phrase><phrase role="identifier">init_read</phrase><phrase role="special">([</phrase><phrase role="identifier">promise</phrase><phrase role="special">=</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">move</phrase><phrase role="special">(</phrase> <phrase role="identifier">promise</phrase><phrase role="special">)](</phrase> <phrase role="identifier">AsyncAPI</phrase><phrase role="special">::</phrase><phrase role="identifier">errorcode</phrase> <phrase role="identifier">ec</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">data</phrase><phrase role="special">)</phrase> <phrase role="keyword">mutable</phrase> <phrase role="special">{</phrase> <phrase role="identifier">promise</phrase><phrase role="special">.</phrase><phrase role="identifier">set_value</phrase><phrase role="special">(</phrase> <phrase role="identifier">result_pair</phrase><phrase role="special">(</phrase> <phrase role="identifier">ec</phrase><phrase role="special">,</phrase> <phrase role="identifier">data</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="special">});</phrase> <phrase role="preprocessor">#else</phrase> <phrase role="comment">// defined(BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES)</phrase> <phrase role="identifier">api</phrase><phrase role="special">.</phrase><phrase role="identifier">init_read</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">([](</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">promise</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">result_pair</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">promise</phrase><phrase role="special">,</phrase> <phrase role="identifier">AsyncAPI</phrase><phrase role="special">::</phrase><phrase role="identifier">errorcode</phrase> <phrase role="identifier">ec</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">data</phrase><phrase role="special">)</phrase> <phrase role="keyword">mutable</phrase> <phrase role="special">{</phrase> <phrase role="identifier">promise</phrase><phrase role="special">.</phrase><phrase role="identifier">set_value</phrase><phrase role="special">(</phrase> <phrase role="identifier">result_pair</phrase><phrase role="special">(</phrase> <phrase role="identifier">ec</phrase><phrase role="special">,</phrase> <phrase role="identifier">data</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">move</phrase><phrase role="special">(</phrase> <phrase role="identifier">promise</phrase><phrase role="special">),</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">placeholders</phrase><phrase role="special">::</phrase><phrase role="identifier">_1</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">placeholders</phrase><phrase role="special">::</phrase><phrase role="identifier">_2</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="preprocessor">#endif</phrase> <phrase role="comment">// BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">future</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> Once you bundle the interesting data in <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">pair</phrase><phrase role="special">&lt;&gt;</phrase></code>, the code is effectively identical to <code><phrase role="identifier">write_ec</phrase><phrase role="special">()</phrase></code>. You can call it like this: </para> <para> <programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">tie</phrase><phrase role="special">(</phrase> <phrase role="identifier">ec</phrase><phrase role="special">,</phrase> <phrase role="identifier">data</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="identifier">read_ec</phrase><phrase role="special">(</phrase> <phrase role="identifier">api</phrase><phrase role="special">);</phrase> </programlisting> </para> </section> <section id="fiber.callbacks.data_or_exception"> <title><anchor id="Data_or_Exception"/><link linkend="fiber.callbacks.data_or_exception">Data or Exception</link></title> <para> But a more natural API for a function that obtains data is to return only the data on success, throwing an exception on error. </para> <para> As with <code><phrase role="identifier">write</phrase><phrase role="special">()</phrase></code> above, it&#8217;s certainly possible to code a <code><phrase role="identifier">read</phrase><phrase role="special">()</phrase></code> wrapper in terms of <code><phrase role="identifier">read_ec</phrase><phrase role="special">()</phrase></code>. But since a given application is unlikely to need both, let&#8217;s code <code><phrase role="identifier">read</phrase><phrase role="special">()</phrase></code> from scratch, leveraging <link linkend="promise_set_exception"><code>promise::set_exception()</code></link>: </para> <para> <programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">read</phrase><phrase role="special">(</phrase> <phrase role="identifier">AsyncAPI</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">api</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">promise</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">promise</phrase><phrase role="special">;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future</phrase><phrase role="special">(</phrase> <phrase role="identifier">promise</phrase><phrase role="special">.</phrase><phrase role="identifier">get_future</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase> <phrase role="comment">// Both 'promise' and 'future' will survive until our lambda has been</phrase> <phrase role="comment">// called.</phrase> <phrase role="preprocessor">#if</phrase> <phrase role="special">!</phrase> <phrase role="identifier">defined</phrase><phrase role="special">(</phrase><phrase role="identifier">BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES</phrase><phrase role="special">)</phrase> <phrase role="identifier">api</phrase><phrase role="special">.</phrase><phrase role="identifier">init_read</phrase><phrase role="special">([&amp;</phrase><phrase role="identifier">promise</phrase><phrase role="special">](</phrase> <phrase role="identifier">AsyncAPI</phrase><phrase role="special">::</phrase><phrase role="identifier">errorcode</phrase> <phrase role="identifier">ec</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">data</phrase><phrase role="special">)</phrase> <phrase role="keyword">mutable</phrase> <phrase role="special">{</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="special">!</phrase> <phrase role="identifier">ec</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">promise</phrase><phrase role="special">.</phrase><phrase role="identifier">set_value</phrase><phrase role="special">(</phrase> <phrase role="identifier">data</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="keyword">else</phrase> <phrase role="special">{</phrase> <phrase role="identifier">promise</phrase><phrase role="special">.</phrase><phrase role="identifier">set_exception</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">make_exception_ptr</phrase><phrase role="special">(</phrase> <phrase role="identifier">make_exception</phrase><phrase role="special">(</phrase><phrase role="string">&quot;read&quot;</phrase><phrase role="special">,</phrase> <phrase role="identifier">ec</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="special">});</phrase> <phrase role="preprocessor">#else</phrase> <phrase role="comment">// defined(BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES)</phrase> <phrase role="identifier">api</phrase><phrase role="special">.</phrase><phrase role="identifier">init_read</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">([](</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">promise</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">promise</phrase><phrase role="special">,</phrase> <phrase role="identifier">AsyncAPI</phrase><phrase role="special">::</phrase><phrase role="identifier">errorcode</phrase> <phrase role="identifier">ec</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">data</phrase><phrase role="special">)</phrase> <phrase role="keyword">mutable</phrase> <phrase role="special">{</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="special">!</phrase> <phrase role="identifier">ec</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">promise</phrase><phrase role="special">.</phrase><phrase role="identifier">set_value</phrase><phrase role="special">(</phrase> <phrase role="identifier">data</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="keyword">else</phrase> <phrase role="special">{</phrase> <phrase role="identifier">promise</phrase><phrase role="special">.</phrase><phrase role="identifier">set_exception</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">make_exception_ptr</phrase><phrase role="special">(</phrase> <phrase role="identifier">make_exception</phrase><phrase role="special">(</phrase><phrase role="string">&quot;read&quot;</phrase><phrase role="special">,</phrase> <phrase role="identifier">ec</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="special">},</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">move</phrase><phrase role="special">(</phrase> <phrase role="identifier">promise</phrase><phrase role="special">),</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">placeholders</phrase><phrase role="special">::</phrase><phrase role="identifier">_1</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">placeholders</phrase><phrase role="special">::</phrase><phrase role="identifier">_2</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="preprocessor">#endif</phrase> <phrase role="comment">// BOOST_NO_CXX14_INITIALIZED_LAMBDA_CAPTURES</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">future</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> <link linkend="future_get"><code>future::get()</code></link> will do the right thing, either returning <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase></code> or throwing an exception. </para> </section> <section id="fiber.callbacks.success_error_virtual_methods"> <title><link linkend="fiber.callbacks.success_error_virtual_methods">Success/Error Virtual Methods</link></title> <para> One classic approach to completion notification is to define an abstract base class with <code><phrase role="identifier">success</phrase><phrase role="special">()</phrase></code> and <code><phrase role="identifier">error</phrase><phrase role="special">()</phrase></code> methods. Code wishing to perform async I/O must derive a subclass, override each of these methods and pass the async operation a pointer to a subclass instance. The abstract base class might look like this: </para> <para> <programlisting><phrase role="comment">// every async operation receives a subclass instance of this abstract base</phrase> <phrase role="comment">// class through which to communicate its result</phrase> <phrase role="keyword">struct</phrase> <phrase role="identifier">Response</phrase> <phrase role="special">{</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_ptr</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Response</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">ptr</phrase><phrase role="special">;</phrase> <phrase role="comment">// called if the operation succeeds</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">success</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">data</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="comment">// called if the operation fails</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">error</phrase><phrase role="special">(</phrase> <phrase role="identifier">AsyncAPIBase</phrase><phrase role="special">::</phrase><phrase role="identifier">errorcode</phrase> <phrase role="identifier">ec</phrase><phrase role="special">)</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> </programlisting> </para> <para> Now the <code><phrase role="identifier">AsyncAPI</phrase></code> operation might look more like this: </para> <para> <programlisting><phrase role="comment">// derive Response subclass, instantiate, pass Response::ptr</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">init_read</phrase><phrase role="special">(</phrase> <phrase role="identifier">Response</phrase><phrase role="special">::</phrase><phrase role="identifier">ptr</phrase><phrase role="special">);</phrase> </programlisting> </para> <para> We can address this by writing a one-size-fits-all <code><phrase role="identifier">PromiseResponse</phrase></code>: </para> <para> <programlisting><phrase role="keyword">class</phrase> <phrase role="identifier">PromiseResponse</phrase><phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">Response</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="comment">// called if the operation succeeds</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">success</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">data</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">promise_</phrase><phrase role="special">.</phrase><phrase role="identifier">set_value</phrase><phrase role="special">(</phrase> <phrase role="identifier">data</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="comment">// called if the operation fails</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">error</phrase><phrase role="special">(</phrase> <phrase role="identifier">AsyncAPIBase</phrase><phrase role="special">::</phrase><phrase role="identifier">errorcode</phrase> <phrase role="identifier">ec</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">promise_</phrase><phrase role="special">.</phrase><phrase role="identifier">set_exception</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">make_exception_ptr</phrase><phrase role="special">(</phrase> <phrase role="identifier">make_exception</phrase><phrase role="special">(</phrase><phrase role="string">&quot;read&quot;</phrase><phrase role="special">,</phrase> <phrase role="identifier">ec</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">get_future</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">promise_</phrase><phrase role="special">.</phrase><phrase role="identifier">get_future</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="keyword">private</phrase><phrase role="special">:</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">promise</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">promise_</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> </programlisting> </para> <para> Now we can simply obtain the <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code> from that <code><phrase role="identifier">PromiseResponse</phrase></code> and wait on its <code><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code>: </para> <para> <programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">read</phrase><phrase role="special">(</phrase> <phrase role="identifier">AsyncAPI</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">api</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Because init_read() requires a shared_ptr, we must allocate our</phrase> <phrase role="comment">// ResponsePromise on the heap, even though we know its lifespan.</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">promisep</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">make_shared</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">PromiseResponse</phrase> <phrase role="special">&gt;()</phrase> <phrase role="special">);</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future</phrase><phrase role="special">(</phrase> <phrase role="identifier">promisep</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">get_future</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase> <phrase role="comment">// Both 'promisep' and 'future' will survive until our lambda has been</phrase> <phrase role="comment">// called.</phrase> <phrase role="identifier">api</phrase><phrase role="special">.</phrase><phrase role="identifier">init_read</phrase><phrase role="special">(</phrase> <phrase role="identifier">promisep</phrase><phrase role="special">);</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">future</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> The source code above is found in <ulink url="../../examples/adapt_callbacks.cpp">adapt_callbacks.cpp</ulink> and <ulink url="../../examples/adapt_method_calls.cpp">adapt_method_calls.cpp</ulink>. </para> </section> <section id="fiber.callbacks.then_there_s____boost_asio__"> <title><anchor id="callbacks_asio"/><link linkend="fiber.callbacks.then_there_s____boost_asio__">Then There&#8217;s <ulink url="path_to_url">Boost.Asio</ulink></link></title> <para> Since the simplest form of Boost.Asio asynchronous operation completion token is a callback function, we could apply the same tactics for Asio as for our hypothetical <code><phrase role="identifier">AsyncAPI</phrase></code> asynchronous operations. </para> <para> Fortunately we need not. Boost.Asio incorporates a mechanism<footnote id="fiber.callbacks.then_there_s____boost_asio__.f0"> <para> This mechanism has been proposed as a conventional way to allow the caller of an arbitrary async function to specify completion handling: <ulink url="path_to_url">N4045</ulink>. </para> </footnote> by which the caller can customize the notification behavior of any async operation. Therefore we can construct a <emphasis>completion token</emphasis> which, when passed to a <ulink url="path_to_url">Boost.Asio</ulink> async operation, requests blocking for the calling fiber. </para> <para> A typical Asio async function might look something like this:<footnote id="fiber.callbacks.then_there_s____boost_asio__.f1"> <para> per <ulink url="path_to_url">N4045</ulink> </para> </footnote> </para> <programlisting><phrase role="keyword">template</phrase> <phrase role="special">&lt;</phrase> <phrase role="special">...,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">CompletionToken</phrase> <phrase role="special">&gt;</phrase> <emphasis>deduced_return_type</emphasis> <phrase role="identifier">async_something</phrase><phrase role="special">(</phrase> <phrase role="special">...</phrase> <phrase role="special">,</phrase> <phrase role="identifier">CompletionToken</phrase><phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">token</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// construct handler_type instance from CompletionToken</phrase> <phrase role="identifier">handler_type</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">CompletionToken</phrase><phrase role="special">,</phrase> <phrase role="special">...&gt;::</phrase><phrase role="identifier">type</phrase> <emphasis role="bold"><!--quickbook-escape-prefix--><code><!--quickbook-escape-postfix-->handler(token)<!--quickbook-escape-prefix--></code><!--quickbook-escape-postfix--></emphasis><phrase role="special">;</phrase> <phrase role="comment">// construct async_result instance from handler_type</phrase> <phrase role="identifier">async_result</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">decltype</phrase><phrase role="special">(</phrase><phrase role="identifier">handler</phrase><phrase role="special">)&gt;</phrase> <emphasis role="bold"><!--quickbook-escape-prefix--><code><!--quickbook-escape-postfix-->result(handler)<!--quickbook-escape-prefix--></code><!--quickbook-escape-postfix--></emphasis><phrase role="special">;</phrase> <phrase role="comment">// ... arrange to call handler on completion ...</phrase> <phrase role="comment">// ... initiate actual I/O operation ...</phrase> <phrase role="keyword">return</phrase> <emphasis role="bold"><!--quickbook-escape-prefix--><code><!--quickbook-escape-postfix-->result.get()<!--quickbook-escape-prefix--></code><!--quickbook-escape-postfix--></emphasis><phrase role="special">;</phrase> <phrase role="special">}</phrase> </programlisting> <para> We will engage that mechanism, which is based on specializing Asio&#8217;s <code><phrase role="identifier">handler_type</phrase><phrase role="special">&lt;&gt;</phrase></code> template for the <code><phrase role="identifier">CompletionToken</phrase></code> type and the signature of the specific callback. The remainder of this discussion will refer back to <code><phrase role="identifier">async_something</phrase><phrase role="special">()</phrase></code> as the Asio async function under consideration. </para> <para> The implementation described below uses lower-level facilities than <code><phrase role="identifier">promise</phrase></code> and <code><phrase role="identifier">future</phrase></code> because the <code><phrase role="identifier">promise</phrase></code> mechanism interacts badly with <ulink url="path_to_url"><code><phrase role="identifier">io_service</phrase><phrase role="special">::</phrase><phrase role="identifier">stop</phrase><phrase role="special">()</phrase></code></ulink>. It produces <code><phrase role="identifier">broken_promise</phrase></code> exceptions. </para> <para> <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">yield</phrase></code> is a completion token of this kind. <code><phrase role="identifier">yield</phrase></code> is an instance of <code><phrase role="identifier">yield_t</phrase></code>: </para> <para> <programlisting><phrase role="keyword">class</phrase> <phrase role="identifier">yield_t</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="identifier">yield_t</phrase><phrase role="special">()</phrase> <phrase role="special">=</phrase> <phrase role="keyword">default</phrase><phrase role="special">;</phrase> <phrase role="comment">/** * @code * static yield_t yield; * boost::system::error_code myec; * func(yield[myec]); * @endcode * @c yield[myec] returns an instance of @c yield_t whose @c ec_ points * to @c myec. The expression @c yield[myec] &quot;binds&quot; @c myec to that * (anonymous) @c yield_t instance, instructing @c func() to store any * @c error_code it might produce into @c myec rather than throwing @c * boost::system::system_error. */</phrase> <phrase role="identifier">yield_t</phrase> <phrase role="keyword">operator</phrase><phrase role="special">[](</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">system</phrase><phrase role="special">::</phrase><phrase role="identifier">error_code</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">ec</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="identifier">yield_t</phrase> <phrase role="identifier">tmp</phrase><phrase role="special">;</phrase> <phrase role="identifier">tmp</phrase><phrase role="special">.</phrase><phrase role="identifier">ec_</phrase> <phrase role="special">=</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">ec</phrase><phrase role="special">;</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">tmp</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="comment">//private:</phrase> <phrase role="comment">// ptr to bound error_code instance if any</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">system</phrase><phrase role="special">::</phrase><phrase role="identifier">error_code</phrase> <phrase role="special">*</phrase> <phrase role="identifier">ec_</phrase><phrase role="special">{</phrase> <phrase role="keyword">nullptr</phrase> <phrase role="special">};</phrase> <phrase role="special">};</phrase> </programlisting> </para> <para> <code><phrase role="identifier">yield_t</phrase></code> is in fact only a placeholder, a way to trigger Boost.Asio customization. It can bind a <ulink url="path_to_url#Class-error_code"><code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">system</phrase><phrase role="special">::</phrase><phrase role="identifier">error_code</phrase></code></ulink> for use by the actual handler. </para> <para> <code><phrase role="identifier">yield</phrase></code> is declared as: </para> <para> <programlisting><phrase role="comment">// canonical instance</phrase> <phrase role="keyword">thread_local</phrase> <phrase role="identifier">yield_t</phrase> <phrase role="identifier">yield</phrase><phrase role="special">{};</phrase> </programlisting> </para> <para> Asio customization is engaged by specializing <ulink url="path_to_url"><code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">handler_type</phrase><phrase role="special">&lt;&gt;</phrase></code></ulink> for <code><phrase role="identifier">yield_t</phrase></code>: </para> <para> <programlisting><phrase role="comment">// Handler type specialisation for fibers::asio::yield.</phrase> <phrase role="comment">// When 'yield' is passed as a completion handler which accepts only</phrase> <phrase role="comment">// error_code, use yield_handler&lt;void&gt;. yield_handler will take care of the</phrase> <phrase role="comment">// error_code one way or another.</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">ReturnType</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">struct</phrase> <phrase role="identifier">handler_type</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">yield_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">ReturnType</phrase><phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">system</phrase><phrase role="special">::</phrase><phrase role="identifier">error_code</phrase><phrase role="special">)</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">{</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">void</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> </programlisting> </para> <para> (There are actually four different specializations in <ulink url="../../examples/asio/detail/yield.hpp">detail/yield.hpp</ulink>, one for each of the four Asio async callback signatures we expect.) </para> <para> The above directs Asio to use <code><phrase role="identifier">yield_handler</phrase></code> as the actual handler for an async operation to which <code><phrase role="identifier">yield</phrase></code> is passed. There&#8217;s a generic <code><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase></code> implementation and a <code><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase><phrase role="special">&gt;</phrase></code> specialization. Let&#8217;s start with the <code><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase><phrase role="special">&gt;</phrase></code> specialization: </para> <para> <programlisting><phrase role="comment">// yield_handler&lt;void&gt; is like yield_handler&lt;T&gt; without value_. In fact it's</phrase> <phrase role="comment">// just like yield_handler_base.</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;&gt;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">void</phrase> <phrase role="special">&gt;:</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">yield_handler_base</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="keyword">explicit</phrase> <phrase role="identifier">yield_handler</phrase><phrase role="special">(</phrase> <phrase role="identifier">yield_t</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">y</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="identifier">yield_handler_base</phrase><phrase role="special">{</phrase> <phrase role="identifier">y</phrase> <phrase role="special">}</phrase> <phrase role="special">{</phrase> <phrase role="special">}</phrase> <phrase role="comment">// nullary completion callback</phrase> <phrase role="keyword">void</phrase> <phrase role="keyword">operator</phrase><phrase role="special">()()</phrase> <phrase role="special">{</phrase> <phrase role="special">(</phrase> <phrase role="special">*</phrase> <phrase role="keyword">this</phrase><phrase role="special">)(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">system</phrase><phrase role="special">::</phrase><phrase role="identifier">error_code</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="comment">// inherit operator()(error_code) overload from base class</phrase> <phrase role="keyword">using</phrase> <phrase role="identifier">yield_handler_base</phrase><phrase role="special">::</phrase><phrase role="keyword">operator</phrase><phrase role="special">();</phrase> <phrase role="special">};</phrase> </programlisting> </para> <para> <code><phrase role="identifier">async_something</phrase><phrase role="special">()</phrase></code>, having consulted the <code><phrase role="identifier">handler_type</phrase><phrase role="special">&lt;&gt;</phrase></code> traits specialization, instantiates a <code><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase><phrase role="special">&gt;</phrase></code> to be passed as the actual callback for the async operation. <code><phrase role="identifier">yield_handler</phrase></code>&#8217;s constructor accepts the <code><phrase role="identifier">yield_t</phrase></code> instance (the <code><phrase role="identifier">yield</phrase></code> object passed to the async function) and passes it along to <code><phrase role="identifier">yield_handler_base</phrase></code>: </para> <para> <programlisting><phrase role="comment">// This class encapsulates common elements between yield_handler&lt;T&gt; (capturing</phrase> <phrase role="comment">// a value to return from asio async function) and yield_handler&lt;void&gt; (no</phrase> <phrase role="comment">// such value). See yield_handler&lt;T&gt; and its &lt;void&gt; specialization below. Both</phrase> <phrase role="comment">// yield_handler&lt;T&gt; and yield_handler&lt;void&gt; are passed by value through</phrase> <phrase role="comment">// various layers of asio functions. In other words, they're potentially</phrase> <phrase role="comment">// copied multiple times. So key data such as the yield_completion instance</phrase> <phrase role="comment">// must be stored in our async_result&lt;yield_handler&lt;&gt;&gt; specialization, which</phrase> <phrase role="comment">// should be instantiated only once.</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">yield_handler_base</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="identifier">yield_handler_base</phrase><phrase role="special">(</phrase> <phrase role="identifier">yield_t</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">y</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="comment">// capture the context* associated with the running fiber</phrase> <phrase role="identifier">ctx_</phrase><phrase role="special">{</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">context</phrase><phrase role="special">::</phrase><phrase role="identifier">active</phrase><phrase role="special">()</phrase> <phrase role="special">},</phrase> <phrase role="comment">// capture the passed yield_t</phrase> <phrase role="identifier">yt_</phrase><phrase role="special">(</phrase> <phrase role="identifier">y</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="special">}</phrase> <phrase role="comment">// completion callback passing only (error_code)</phrase> <phrase role="keyword">void</phrase> <phrase role="keyword">operator</phrase><phrase role="special">()(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">system</phrase><phrase role="special">::</phrase><phrase role="identifier">error_code</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">ec</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">BOOST_ASSERT_MSG</phrase><phrase role="special">(</phrase> <phrase role="identifier">ycomp_</phrase><phrase role="special">,</phrase> <phrase role="string">&quot;Must inject yield_completion* &quot;</phrase> <phrase role="string">&quot;before calling yield_handler_base::operator()()&quot;</phrase><phrase role="special">);</phrase> <phrase role="identifier">BOOST_ASSERT_MSG</phrase><phrase role="special">(</phrase> <phrase role="identifier">yt_</phrase><phrase role="special">.</phrase><phrase role="identifier">ec_</phrase><phrase role="special">,</phrase> <phrase role="string">&quot;Must inject boost::system::error_code* &quot;</phrase> <phrase role="string">&quot;before calling yield_handler_base::operator()()&quot;</phrase><phrase role="special">);</phrase> <phrase role="comment">// If originating fiber is busy testing state_ flag, wait until it</phrase> <phrase role="comment">// has observed (completed != state_).</phrase> <phrase role="identifier">yield_completion</phrase><phrase role="special">::</phrase><phrase role="identifier">lock_t</phrase> <phrase role="identifier">lk</phrase><phrase role="special">{</phrase> <phrase role="identifier">ycomp_</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">mtx_</phrase> <phrase role="special">};</phrase> <phrase role="identifier">yield_completion</phrase><phrase role="special">::</phrase><phrase role="identifier">state_t</phrase> <phrase role="identifier">state</phrase> <phrase role="special">=</phrase> <phrase role="identifier">ycomp_</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">state_</phrase><phrase role="special">;</phrase> <phrase role="comment">// Notify a subsequent yield_completion::wait() call that it need not</phrase> <phrase role="comment">// suspend.</phrase> <phrase role="identifier">ycomp_</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">state_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">yield_completion</phrase><phrase role="special">::</phrase><phrase role="identifier">complete</phrase><phrase role="special">;</phrase> <phrase role="comment">// set the error_code bound by yield_t</phrase> <phrase role="special">*</phrase> <phrase role="identifier">yt_</phrase><phrase role="special">.</phrase><phrase role="identifier">ec_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">ec</phrase><phrase role="special">;</phrase> <phrase role="comment">// unlock the lock that protects state_</phrase> <phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">unlock</phrase><phrase role="special">();</phrase> <phrase role="comment">// If ctx_ is still active, e.g. because the async operation</phrase> <phrase role="comment">// immediately called its callback (this method!) before the asio</phrase> <phrase role="comment">// async function called async_result_base::get(), we must not set it</phrase> <phrase role="comment">// ready.</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">yield_completion</phrase><phrase role="special">::</phrase><phrase role="identifier">waiting</phrase> <phrase role="special">==</phrase> <phrase role="identifier">state</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// wake the fiber</phrase> <phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">context</phrase><phrase role="special">::</phrase><phrase role="identifier">active</phrase><phrase role="special">()-&gt;</phrase><phrase role="identifier">schedule</phrase><phrase role="special">(</phrase> <phrase role="identifier">ctx_</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> <phrase role="comment">//private:</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">ctx_</phrase><phrase role="special">;</phrase> <phrase role="identifier">yield_t</phrase> <phrase role="identifier">yt_</phrase><phrase role="special">;</phrase> <phrase role="comment">// We depend on this pointer to yield_completion, which will be injected</phrase> <phrase role="comment">// by async_result.</phrase> <phrase role="identifier">yield_completion</phrase><phrase role="special">::</phrase><phrase role="identifier">ptr_t</phrase> <phrase role="identifier">ycomp_</phrase><phrase role="special">{};</phrase> <phrase role="special">};</phrase> </programlisting> </para> <para> <code><phrase role="identifier">yield_handler_base</phrase></code> stores a copy of the <code><phrase role="identifier">yield_t</phrase></code> instance &mdash; which, as shown above, contains only an <code><phrase role="identifier">error_code</phrase><phrase role="special">*</phrase></code>. It also captures the <link linkend="class_context"><code>context</code></link>* for the currently-running fiber by calling <link linkend="context_active"><code>context::active()</code></link>. </para> <para> You will notice that <code><phrase role="identifier">yield_handler_base</phrase></code> has one more data member (<code><phrase role="identifier">ycomp_</phrase></code>) that is initialized to <code><phrase role="keyword">nullptr</phrase></code> by its constructor &mdash; though its <code><phrase role="keyword">operator</phrase><phrase role="special">()()</phrase></code> method relies on <code><phrase role="identifier">ycomp_</phrase></code> being non-null. More on this in a moment. </para> <para> Having constructed the <code><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase><phrase role="special">&gt;</phrase></code> instance, <code><phrase role="identifier">async_something</phrase><phrase role="special">()</phrase></code> goes on to construct an <code><phrase role="identifier">async_result</phrase></code> specialized for the <code><phrase role="identifier">handler_type</phrase><phrase role="special">&lt;&gt;::</phrase><phrase role="identifier">type</phrase></code>: in this case, <code><phrase role="identifier">async_result</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase><phrase role="special">&gt;&gt;</phrase></code>. It passes the <code><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase><phrase role="special">&gt;</phrase></code> instance to the new <code><phrase role="identifier">async_result</phrase></code> instance. </para> <para> <programlisting><phrase role="comment">// Without the need to handle a passed value, our yield_handler&lt;void&gt;</phrase> <phrase role="comment">// specialization is just like async_result_base.</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;&gt;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">async_result</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">void</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">async_result_base</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> <phrase role="keyword">explicit</phrase> <phrase role="identifier">async_result</phrase><phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">void</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">h</phrase><phrase role="special">):</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">async_result_base</phrase><phrase role="special">{</phrase> <phrase role="identifier">h</phrase> <phrase role="special">}</phrase> <phrase role="special">{</phrase> <phrase role="special">}</phrase> <phrase role="special">};</phrase> </programlisting> </para> <para> Naturally that leads us straight to <code><phrase role="identifier">async_result_base</phrase></code>: </para> <para> <programlisting><phrase role="comment">// Factor out commonality between async_result&lt;yield_handler&lt;T&gt;&gt; and</phrase> <phrase role="comment">// async_result&lt;yield_handler&lt;void&gt;&gt;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">async_result_base</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="keyword">explicit</phrase> <phrase role="identifier">async_result_base</phrase><phrase role="special">(</phrase> <phrase role="identifier">yield_handler_base</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">h</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="identifier">ycomp_</phrase><phrase role="special">{</phrase> <phrase role="keyword">new</phrase> <phrase role="identifier">yield_completion</phrase><phrase role="special">{}</phrase> <phrase role="special">}</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Inject ptr to our yield_completion instance into this</phrase> <phrase role="comment">// yield_handler&lt;&gt;.</phrase> <phrase role="identifier">h</phrase><phrase role="special">.</phrase><phrase role="identifier">ycomp_</phrase> <phrase role="special">=</phrase> <phrase role="keyword">this</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">ycomp_</phrase><phrase role="special">;</phrase> <phrase role="comment">// if yield_t didn't bind an error_code, make yield_handler_base's</phrase> <phrase role="comment">// error_code* point to an error_code local to this object so</phrase> <phrase role="comment">// yield_handler_base::operator() can unconditionally store through</phrase> <phrase role="comment">// its error_code*</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="special">!</phrase> <phrase role="identifier">h</phrase><phrase role="special">.</phrase><phrase role="identifier">yt_</phrase><phrase role="special">.</phrase><phrase role="identifier">ec_</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">h</phrase><phrase role="special">.</phrase><phrase role="identifier">yt_</phrase><phrase role="special">.</phrase><phrase role="identifier">ec_</phrase> <phrase role="special">=</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">ec_</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Unless yield_handler_base::operator() has already been called,</phrase> <phrase role="comment">// suspend the calling fiber until that call.</phrase> <phrase role="identifier">ycomp_</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">wait</phrase><phrase role="special">();</phrase> <phrase role="comment">// The only way our own ec_ member could have a non-default value is</phrase> <phrase role="comment">// if our yield_handler did not have a bound error_code AND the</phrase> <phrase role="comment">// completion callback passed a non-default error_code.</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">ec_</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">throw_exception</phrase><phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">system</phrase><phrase role="special">::</phrase><phrase role="identifier">system_error</phrase><phrase role="special">{</phrase> <phrase role="identifier">ec_</phrase> <phrase role="special">}</phrase> <phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> <phrase role="keyword">private</phrase><phrase role="special">:</phrase> <phrase role="comment">// If yield_t does not bind an error_code instance, store into here.</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">system</phrase><phrase role="special">::</phrase><phrase role="identifier">error_code</phrase> <phrase role="identifier">ec_</phrase><phrase role="special">{};</phrase> <phrase role="identifier">yield_completion</phrase><phrase role="special">::</phrase><phrase role="identifier">ptr_t</phrase> <phrase role="identifier">ycomp_</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> </programlisting> </para> <para> This is how <code><phrase role="identifier">yield_handler_base</phrase><phrase role="special">::</phrase><phrase role="identifier">ycomp_</phrase></code> becomes non-null: <code><phrase role="identifier">async_result_base</phrase></code>&#8217;s constructor injects a pointer back to its own <code><phrase role="identifier">yield_completion</phrase></code> member. </para> <para> Recall that the canonical <code><phrase role="identifier">yield_t</phrase></code> instance <code><phrase role="identifier">yield</phrase></code> initializes its <code><phrase role="identifier">error_code</phrase><phrase role="special">*</phrase></code> member <code><phrase role="identifier">ec_</phrase></code> to <code><phrase role="keyword">nullptr</phrase></code>. If this instance is passed to <code><phrase role="identifier">async_something</phrase><phrase role="special">()</phrase></code> (<code><phrase role="identifier">ec_</phrase></code> is still <code><phrase role="keyword">nullptr</phrase></code>), the copy stored in <code><phrase role="identifier">yield_handler_base</phrase></code> will likewise have null <code><phrase role="identifier">ec_</phrase></code>. <code><phrase role="identifier">async_result_base</phrase></code>&#8217;s constructor sets <code><phrase role="identifier">yield_handler_base</phrase></code>&#8217;s <code><phrase role="identifier">yield_t</phrase></code>&#8217;s <code><phrase role="identifier">ec_</phrase></code> member to point to its own <code><phrase role="identifier">error_code</phrase></code> member. </para> <para> The stage is now set. <code><phrase role="identifier">async_something</phrase><phrase role="special">()</phrase></code> initiates the actual async operation, arranging to call its <code><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase><phrase role="special">&gt;</phrase></code> instance on completion. Let&#8217;s say, for the sake of argument, that the actual async operation&#8217;s callback has signature <code><phrase role="keyword">void</phrase><phrase role="special">(</phrase><phrase role="identifier">error_code</phrase><phrase role="special">)</phrase></code>. </para> <para> But since it&#8217;s an async operation, control returns at once to <code><phrase role="identifier">async_something</phrase><phrase role="special">()</phrase></code>. <code><phrase role="identifier">async_something</phrase><phrase role="special">()</phrase></code> calls <code><phrase role="identifier">async_result</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase><phrase role="special">&gt;&gt;::</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code>, and will return its return value. </para> <para> <code><phrase role="identifier">async_result</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase><phrase role="special">&gt;&gt;::</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code> inherits <code><phrase role="identifier">async_result_base</phrase><phrase role="special">::</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code>. </para> <para> <code><phrase role="identifier">async_result_base</phrase><phrase role="special">::</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code> immediately calls <code><phrase role="identifier">yield_completion</phrase><phrase role="special">::</phrase><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code>. </para> <para> <programlisting><phrase role="comment">// Bundle a completion bool flag with a spinlock to protect it.</phrase> <phrase role="keyword">struct</phrase> <phrase role="identifier">yield_completion</phrase> <phrase role="special">{</phrase> <phrase role="keyword">enum</phrase> <phrase role="identifier">state_t</phrase> <phrase role="special">{</phrase> <phrase role="identifier">init</phrase><phrase role="special">,</phrase> <phrase role="identifier">waiting</phrase><phrase role="special">,</phrase> <phrase role="identifier">complete</phrase> <phrase role="special">};</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">spinlock</phrase> <phrase role="identifier">mutex_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">unique_lock</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">mutex_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">lock_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">intrusive_ptr</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">yield_completion</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">ptr_t</phrase><phrase role="special">;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">atomic</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">use_count_</phrase><phrase role="special">{</phrase> <phrase role="number">0</phrase> <phrase role="special">};</phrase> <phrase role="identifier">mutex_t</phrase> <phrase role="identifier">mtx_</phrase><phrase role="special">{};</phrase> <phrase role="identifier">state_t</phrase> <phrase role="identifier">state_</phrase><phrase role="special">{</phrase> <phrase role="identifier">init</phrase> <phrase role="special">};</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">wait</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="comment">// yield_handler_base::operator()() will set state_ `complete` and</phrase> <phrase role="comment">// attempt to wake a suspended fiber. It would be Bad if that call</phrase> <phrase role="comment">// happened between our detecting (complete != state_) and suspending.</phrase> <phrase role="identifier">lock_t</phrase> <phrase role="identifier">lk</phrase><phrase role="special">{</phrase> <phrase role="identifier">mtx_</phrase> <phrase role="special">};</phrase> <phrase role="comment">// If state_ is already set, we're done here: don't suspend.</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">complete</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">state_</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">state_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">waiting</phrase><phrase role="special">;</phrase> <phrase role="comment">// suspend(unique_lock&lt;spinlock&gt;) unlocks the lock in the act of</phrase> <phrase role="comment">// resuming another fiber</phrase> <phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">context</phrase><phrase role="special">::</phrase><phrase role="identifier">active</phrase><phrase role="special">()-&gt;</phrase><phrase role="identifier">suspend</phrase><phrase role="special">(</phrase> <phrase role="identifier">lk</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> <phrase role="keyword">friend</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">intrusive_ptr_add_ref</phrase><phrase role="special">(</phrase> <phrase role="identifier">yield_completion</phrase> <phrase role="special">*</phrase> <phrase role="identifier">yc</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">{</phrase> <phrase role="identifier">BOOST_ASSERT</phrase><phrase role="special">(</phrase> <phrase role="keyword">nullptr</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">yc</phrase><phrase role="special">);</phrase> <phrase role="identifier">yc</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">use_count_</phrase><phrase role="special">.</phrase><phrase role="identifier">fetch_add</phrase><phrase role="special">(</phrase> <phrase role="number">1</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">memory_order_relaxed</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="keyword">friend</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">intrusive_ptr_release</phrase><phrase role="special">(</phrase> <phrase role="identifier">yield_completion</phrase> <phrase role="special">*</phrase> <phrase role="identifier">yc</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">{</phrase> <phrase role="identifier">BOOST_ASSERT</phrase><phrase role="special">(</phrase> <phrase role="keyword">nullptr</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">yc</phrase><phrase role="special">);</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="number">1</phrase> <phrase role="special">==</phrase> <phrase role="identifier">yc</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">use_count_</phrase><phrase role="special">.</phrase><phrase role="identifier">fetch_sub</phrase><phrase role="special">(</phrase> <phrase role="number">1</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">memory_order_release</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">atomic_thread_fence</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">memory_order_acquire</phrase><phrase role="special">);</phrase> <phrase role="keyword">delete</phrase> <phrase role="identifier">yc</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> <phrase role="special">};</phrase> </programlisting> </para> <para> Supposing that the pending async operation has not yet completed, <code><phrase role="identifier">yield_completion</phrase><phrase role="special">::</phrase><phrase role="identifier">completed_</phrase></code> will still be <code><phrase role="keyword">false</phrase></code>, and <code><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code> will call <link linkend="context_suspend"><code>context::suspend()</code></link> on the currently-running fiber. </para> <para> Other fibers will now have a chance to run. </para> <para> Some time later, the async operation completes. It calls <code><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase><phrase role="special">&gt;::</phrase><phrase role="keyword">operator</phrase><phrase role="special">()(</phrase><phrase role="identifier">error_code</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase></code> with an <code><phrase role="identifier">error_code</phrase></code> indicating either success or failure. We&#8217;ll consider both cases. </para> <para> <code><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase><phrase role="special">&gt;</phrase></code> explicitly inherits <code><phrase role="keyword">operator</phrase><phrase role="special">()(</phrase><phrase role="identifier">error_code</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase></code> from <code><phrase role="identifier">yield_handler_base</phrase></code>. </para> <para> <code><phrase role="identifier">yield_handler_base</phrase><phrase role="special">::</phrase><phrase role="keyword">operator</phrase><phrase role="special">()(</phrase><phrase role="identifier">error_code</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase></code> first sets <code><phrase role="identifier">yield_completion</phrase><phrase role="special">::</phrase><phrase role="identifier">completed_</phrase></code> <code><phrase role="keyword">true</phrase></code>. This way, if <code><phrase role="identifier">async_something</phrase><phrase role="special">()</phrase></code>&#8217;s async operation completes immediately &mdash; if <code><phrase role="identifier">yield_handler_base</phrase><phrase role="special">::</phrase><phrase role="keyword">operator</phrase><phrase role="special">()</phrase></code> is called even before <code><phrase role="identifier">async_result_base</phrase><phrase role="special">::</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code> &mdash; the calling fiber will <emphasis>not</emphasis> suspend. </para> <para> The actual <code><phrase role="identifier">error_code</phrase></code> produced by the async operation is then stored through the stored <code><phrase role="identifier">yield_t</phrase><phrase role="special">::</phrase><phrase role="identifier">ec_</phrase></code> pointer. If <code><phrase role="identifier">async_something</phrase><phrase role="special">()</phrase></code>&#8217;s caller used (e.g.) <code><phrase role="identifier">yield</phrase><phrase role="special">[</phrase><phrase role="identifier">my_ec</phrase><phrase role="special">]</phrase></code> to bind a local <code><phrase role="identifier">error_code</phrase></code> instance, the actual <code><phrase role="identifier">error_code</phrase></code> value is stored into the caller&#8217;s variable. Otherwise, it is stored into <code><phrase role="identifier">async_result_base</phrase><phrase role="special">::</phrase><phrase role="identifier">ec_</phrase></code>. </para> <para> If the stored fiber context <code><phrase role="identifier">yield_handler_base</phrase><phrase role="special">::</phrase><phrase role="identifier">ctx_</phrase></code> is not already running, it is marked as ready to run by passing it to <link linkend="context_set_ready"><code>context::set_ready()</code></link>. Control then returns from <code><phrase role="identifier">yield_handler_base</phrase><phrase role="special">::</phrase><phrase role="keyword">operator</phrase><phrase role="special">()</phrase></code>: the callback is done. </para> <para> In due course, that fiber is resumed. Control returns from <link linkend="context_suspend"><code>context::suspend()</code></link> to <code><phrase role="identifier">yield_completion</phrase><phrase role="special">::</phrase><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code>, which returns to <code><phrase role="identifier">async_result_base</phrase><phrase role="special">::</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code>. </para> <itemizedlist> <listitem> <simpara> If the original caller passed <code><phrase role="identifier">yield</phrase><phrase role="special">[</phrase><phrase role="identifier">my_ec</phrase><phrase role="special">]</phrase></code> to <code><phrase role="identifier">async_something</phrase><phrase role="special">()</phrase></code> to bind a local <code><phrase role="identifier">error_code</phrase></code> instance, then <code><phrase role="identifier">yield_handler_base</phrase><phrase role="special">::</phrase><phrase role="keyword">operator</phrase><phrase role="special">()</phrase></code> stored its <code><phrase role="identifier">error_code</phrase></code> to the caller&#8217;s <code><phrase role="identifier">my_ec</phrase></code> instance, leaving <code><phrase role="identifier">async_result_base</phrase><phrase role="special">::</phrase><phrase role="identifier">ec_</phrase></code> initialized to success. </simpara> </listitem> <listitem> <simpara> If the original caller passed <code><phrase role="identifier">yield</phrase></code> to <code><phrase role="identifier">async_something</phrase><phrase role="special">()</phrase></code> without binding a local <code><phrase role="identifier">error_code</phrase></code> variable, then <code><phrase role="identifier">yield_handler_base</phrase><phrase role="special">::</phrase><phrase role="keyword">operator</phrase><phrase role="special">()</phrase></code> stored its <code><phrase role="identifier">error_code</phrase></code> into <code><phrase role="identifier">async_result_base</phrase><phrase role="special">::</phrase><phrase role="identifier">ec_</phrase></code>. If in fact that <code><phrase role="identifier">error_code</phrase></code> is success, then all is well. </simpara> </listitem> <listitem> <simpara> Otherwise &mdash; the original caller did not bind a local <code><phrase role="identifier">error_code</phrase></code> and <code><phrase role="identifier">yield_handler_base</phrase><phrase role="special">::</phrase><phrase role="keyword">operator</phrase><phrase role="special">()</phrase></code> was called with an <code><phrase role="identifier">error_code</phrase></code> indicating error &mdash; <code><phrase role="identifier">async_result_base</phrase><phrase role="special">::</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code> throws <code><phrase role="identifier">system_error</phrase></code> with that <code><phrase role="identifier">error_code</phrase></code>. </simpara> </listitem> </itemizedlist> <para> The case in which <code><phrase role="identifier">async_something</phrase><phrase role="special">()</phrase></code>&#8217;s completion callback has signature <code><phrase role="keyword">void</phrase><phrase role="special">()</phrase></code> is similar. <code><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase><phrase role="special">&gt;::</phrase><phrase role="keyword">operator</phrase><phrase role="special">()()</phrase></code> invokes the machinery above with a <quote>success</quote> <code><phrase role="identifier">error_code</phrase></code>. </para> <para> A completion callback with signature <code><phrase role="keyword">void</phrase><phrase role="special">(</phrase><phrase role="identifier">error_code</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">)</phrase></code> (that is: in addition to <code><phrase role="identifier">error_code</phrase></code>, callback receives some data item) is handled somewhat differently. For this kind of signature, <code><phrase role="identifier">handler_type</phrase><phrase role="special">&lt;&gt;::</phrase><phrase role="identifier">type</phrase></code> specifies <code><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase></code> (for <code><phrase role="identifier">T</phrase></code> other than <code><phrase role="keyword">void</phrase></code>). </para> <para> A <code><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase></code> reserves a <code><phrase role="identifier">value_</phrase></code> pointer to a value of type <code><phrase role="identifier">T</phrase></code>: </para> <para> <programlisting><phrase role="comment">// asio uses handler_type&lt;completion token type, signature&gt;::type to decide</phrase> <phrase role="comment">// what to instantiate as the actual handler. Below, we specialize</phrase> <phrase role="comment">// handler_type&lt; yield_t, ... &gt; to indicate yield_handler&lt;&gt;. So when you pass</phrase> <phrase role="comment">// an instance of yield_t as an asio completion token, asio selects</phrase> <phrase role="comment">// yield_handler&lt;&gt; as the actual handler class.</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">yield_handler</phrase><phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">yield_handler_base</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="comment">// asio passes the completion token to the handler constructor</phrase> <phrase role="keyword">explicit</phrase> <phrase role="identifier">yield_handler</phrase><phrase role="special">(</phrase> <phrase role="identifier">yield_t</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">y</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="identifier">yield_handler_base</phrase><phrase role="special">{</phrase> <phrase role="identifier">y</phrase> <phrase role="special">}</phrase> <phrase role="special">{</phrase> <phrase role="special">}</phrase> <phrase role="comment">// completion callback passing only value (T)</phrase> <phrase role="keyword">void</phrase> <phrase role="keyword">operator</phrase><phrase role="special">()(</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">t</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// just like callback passing success error_code</phrase> <phrase role="special">(*</phrase><phrase role="keyword">this</phrase><phrase role="special">)(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">system</phrase><phrase role="special">::</phrase><phrase role="identifier">error_code</phrase><phrase role="special">(),</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">move</phrase><phrase role="special">(</phrase><phrase role="identifier">t</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="comment">// completion callback passing (error_code, T)</phrase> <phrase role="keyword">void</phrase> <phrase role="keyword">operator</phrase><phrase role="special">()(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">system</phrase><phrase role="special">::</phrase><phrase role="identifier">error_code</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">ec</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">t</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">BOOST_ASSERT_MSG</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_</phrase><phrase role="special">,</phrase> <phrase role="string">&quot;Must inject value ptr &quot;</phrase> <phrase role="string">&quot;before caling yield_handler&lt;T&gt;::operator()()&quot;</phrase><phrase role="special">);</phrase> <phrase role="comment">// move the value to async_result&lt;&gt; instance BEFORE waking up a</phrase> <phrase role="comment">// suspended fiber</phrase> <phrase role="special">*</phrase> <phrase role="identifier">value_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">move</phrase><phrase role="special">(</phrase> <phrase role="identifier">t</phrase><phrase role="special">);</phrase> <phrase role="comment">// forward the call to base-class completion handler</phrase> <phrase role="identifier">yield_handler_base</phrase><phrase role="special">::</phrase><phrase role="keyword">operator</phrase><phrase role="special">()(</phrase> <phrase role="identifier">ec</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="comment">//private:</phrase> <phrase role="comment">// pointer to destination for eventual value</phrase> <phrase role="comment">// this must be injected by async_result before operator()() is called</phrase> <phrase role="identifier">T</phrase> <phrase role="special">*</phrase> <phrase role="identifier">value_</phrase><phrase role="special">{</phrase> <phrase role="keyword">nullptr</phrase> <phrase role="special">};</phrase> <phrase role="special">};</phrase> </programlisting> </para> <para> This pointer is initialized to <code><phrase role="keyword">nullptr</phrase></code>. </para> <para> When <code><phrase role="identifier">async_something</phrase><phrase role="special">()</phrase></code> instantiates <code><phrase role="identifier">async_result</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;&gt;</phrase></code>: </para> <para> <programlisting><phrase role="comment">// asio constructs an async_result&lt;&gt; instance from the yield_handler specified</phrase> <phrase role="comment">// by handler_type&lt;&gt;::type. A particular asio async method constructs the</phrase> <phrase role="comment">// yield_handler, constructs this async_result specialization from it, then</phrase> <phrase role="comment">// returns the result of calling its get() method.</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">async_result</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">async_result_base</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="comment">// type returned by get()</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> <phrase role="keyword">explicit</phrase> <phrase role="identifier">async_result</phrase><phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">h</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">async_result_base</phrase><phrase role="special">{</phrase> <phrase role="identifier">h</phrase> <phrase role="special">}</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Inject ptr to our value_ member into yield_handler&lt;&gt;: result will</phrase> <phrase role="comment">// be stored here.</phrase> <phrase role="identifier">h</phrase><phrase role="special">.</phrase><phrase role="identifier">value_</phrase> <phrase role="special">=</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">value_</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="comment">// asio async method returns result of calling get()</phrase> <phrase role="identifier">type</phrase> <phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">async_result_base</phrase><phrase role="special">::</phrase><phrase role="identifier">get</phrase><phrase role="special">();</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">move</phrase><phrase role="special">(</phrase> <phrase role="identifier">value_</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="keyword">private</phrase><phrase role="special">:</phrase> <phrase role="identifier">type</phrase> <phrase role="identifier">value_</phrase><phrase role="special">{};</phrase> <phrase role="special">};</phrase> </programlisting> </para> <para> this <code><phrase role="identifier">async_result</phrase><phrase role="special">&lt;&gt;</phrase></code> specialization reserves a member of type <code><phrase role="identifier">T</phrase></code> to receive the passed data item, and sets <code><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="identifier">value_</phrase></code> to point to its own data member. </para> <para> <code><phrase role="identifier">async_result</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;&gt;</phrase></code> overrides <code><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code>. The override calls <code><phrase role="identifier">async_result_base</phrase><phrase role="special">::</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code>, so the calling fiber suspends as described above. </para> <para> <code><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="keyword">operator</phrase><phrase role="special">()(</phrase><phrase role="identifier">error_code</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">)</phrase></code> stores its passed <code><phrase role="identifier">T</phrase></code> value into <code><phrase role="identifier">async_result</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;&gt;::</phrase><phrase role="identifier">value_</phrase></code>. </para> <para> Then it passes control to <code><phrase role="identifier">yield_handler_base</phrase><phrase role="special">::</phrase><phrase role="keyword">operator</phrase><phrase role="special">()(</phrase><phrase role="identifier">error_code</phrase><phrase role="special">)</phrase></code> to deal with waking the original fiber as described above. </para> <para> When <code><phrase role="identifier">async_result</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;&gt;::</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code> resumes, it returns the stored <code><phrase role="identifier">value_</phrase></code> to <code><phrase role="identifier">async_something</phrase><phrase role="special">()</phrase></code> and ultimately to <code><phrase role="identifier">async_something</phrase><phrase role="special">()</phrase></code>&#8217;s caller. </para> <para> The case of a callback signature <code><phrase role="keyword">void</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase></code> is handled by having <code><phrase role="identifier">yield_handler</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;::</phrase><phrase role="keyword">operator</phrase><phrase role="special">()(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase></code> engage the <code><phrase role="keyword">void</phrase><phrase role="special">(</phrase><phrase role="identifier">error_code</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">)</phrase></code> machinery, passing a <quote>success</quote> <code><phrase role="identifier">error_code</phrase></code>. </para> <para> The source code above is found in <ulink url="../../examples/asio/yield.hpp">yield.hpp</ulink> and <ulink url="../../examples/asio/detail/yield.hpp">detail/yield.hpp</ulink>. </para> </section> </section> <section id="fiber.nonblocking"> <title><anchor id="nonblocking"/><link linkend="fiber.nonblocking">Integrating Fibers with Nonblocking I/O</link></title> <bridgehead renderas="sect3" id="fiber.nonblocking.h0"> <phrase id="fiber.nonblocking.overview"/><link linkend="fiber.nonblocking.overview">Overview</link> </bridgehead> <para> <emphasis>Nonblocking</emphasis> I/O is distinct from <emphasis>asynchronous</emphasis> I/O. A true async I/O operation promises to initiate the operation and notify the caller on completion, usually via some sort of callback (as described in <link linkend="callbacks">Integrating Fibers with Asynchronous Callbacks</link>). </para> <para> In contrast, a nonblocking I/O operation refuses to start at all if it would be necessary to block, returning an error code such as <ulink url="path_to_url"><code><phrase role="identifier">EWOULDBLOCK</phrase></code></ulink>. The operation is performed only when it can complete immediately. In effect, the caller must repeatedly retry the operation until it stops returning <code><phrase role="identifier">EWOULDBLOCK</phrase></code>. </para> <para> In a classic event-driven program, it can be something of a headache to use nonblocking I/O. At the point where the nonblocking I/O is attempted, a return value of <code><phrase role="identifier">EWOULDBLOCK</phrase></code> requires the caller to pass control back to the main event loop, arranging to retry again on the next iteration. </para> <para> Worse, a nonblocking I/O operation might <emphasis>partially</emphasis> succeed. That means that the relevant business logic must continue receiving control on every main loop iteration until all required data have been processed: a doubly-nested loop, implemented as a callback-driven state machine. </para> <para> <emphasis role="bold">Boost.Fiber</emphasis> can simplify this problem immensely. Once you have integrated with the application's main loop as described in <link linkend="integration">Sharing a Thread with Another Main Loop</link>, waiting for the next main-loop iteration is as simple as calling <link linkend="this_fiber_yield"><code>this_fiber::yield()</code></link>. </para> <bridgehead renderas="sect3" id="fiber.nonblocking.h1"> <phrase id="fiber.nonblocking.example_nonblocking_api"/><link linkend="fiber.nonblocking.example_nonblocking_api">Example Nonblocking API</link> </bridgehead> <para> For purposes of illustration, consider this API: </para> <para> <programlisting><phrase role="keyword">class</phrase> <phrase role="identifier">NonblockingAPI</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="identifier">NonblockingAPI</phrase><phrase role="special">();</phrase> <phrase role="comment">// nonblocking operation: may return EWOULDBLOCK</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">read</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">data</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">desired</phrase><phrase role="special">);</phrase> <phrase role="special">...</phrase> <phrase role="special">};</phrase> </programlisting> </para> <bridgehead renderas="sect3" id="fiber.nonblocking.h2"> <phrase id="fiber.nonblocking.polling_for_completion"/><link linkend="fiber.nonblocking.polling_for_completion">Polling for Completion</link> </bridgehead> <para> We can build a low-level wrapper around <code><phrase role="identifier">NonblockingAPI</phrase><phrase role="special">::</phrase><phrase role="identifier">read</phrase><phrase role="special">()</phrase></code> that shields its caller from ever having to deal with <code><phrase role="identifier">EWOULDBLOCK</phrase></code>: </para> <para> <programlisting><phrase role="comment">// guaranteed not to return EWOULDBLOCK</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">read_chunk</phrase><phrase role="special">(</phrase> <phrase role="identifier">NonblockingAPI</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">api</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">data</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">desired</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">error</phrase><phrase role="special">;</phrase> <phrase role="keyword">while</phrase> <phrase role="special">(</phrase> <phrase role="identifier">EWOULDBLOCK</phrase> <phrase role="special">==</phrase> <phrase role="special">(</phrase> <phrase role="identifier">error</phrase> <phrase role="special">=</phrase> <phrase role="identifier">api</phrase><phrase role="special">.</phrase><phrase role="identifier">read</phrase><phrase role="special">(</phrase> <phrase role="identifier">data</phrase><phrase role="special">,</phrase> <phrase role="identifier">desired</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// not ready yet -- try again on the next iteration of the</phrase> <phrase role="comment">// application's main loop</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">yield</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">error</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> </programlisting> </para> <bridgehead renderas="sect3" id="fiber.nonblocking.h3"> <phrase id="fiber.nonblocking.filling_all_desired_data"/><link linkend="fiber.nonblocking.filling_all_desired_data">Filling All Desired Data</link> </bridgehead> <para> Given <code><phrase role="identifier">read_chunk</phrase><phrase role="special">()</phrase></code>, we can straightforwardly iterate until we have all desired data: </para> <para> <programlisting><phrase role="comment">// keep reading until desired length, EOF or error</phrase> <phrase role="comment">// may return both partial data and nonzero error</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">read_desired</phrase><phrase role="special">(</phrase> <phrase role="identifier">NonblockingAPI</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">api</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">data</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">desired</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// we're going to accumulate results into 'data'</phrase> <phrase role="identifier">data</phrase><phrase role="special">.</phrase><phrase role="identifier">clear</phrase><phrase role="special">();</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">chunk</phrase><phrase role="special">;</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">error</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="keyword">while</phrase> <phrase role="special">(</phrase> <phrase role="identifier">data</phrase><phrase role="special">.</phrase><phrase role="identifier">length</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">desired</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">(</phrase> <phrase role="identifier">error</phrase> <phrase role="special">=</phrase> <phrase role="identifier">read_chunk</phrase><phrase role="special">(</phrase> <phrase role="identifier">api</phrase><phrase role="special">,</phrase> <phrase role="identifier">chunk</phrase><phrase role="special">,</phrase> <phrase role="identifier">desired</phrase> <phrase role="special">-</phrase> <phrase role="identifier">data</phrase><phrase role="special">.</phrase><phrase role="identifier">length</phrase><phrase role="special">()</phrase> <phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">data</phrase><phrase role="special">.</phrase><phrase role="identifier">append</phrase><phrase role="special">(</phrase> <phrase role="identifier">chunk</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">error</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> (Of <emphasis>course</emphasis> there are more efficient ways to accumulate string data. That's not the point of this example.) </para> <bridgehead renderas="sect3" id="fiber.nonblocking.h4"> <phrase id="fiber.nonblocking.wrapping_it_up"/><link linkend="fiber.nonblocking.wrapping_it_up">Wrapping it Up</link> </bridgehead> <para> Finally, we can define a relevant exception: </para> <para> <programlisting><phrase role="comment">// exception class augmented with both partially-read data and errorcode</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">IncompleteRead</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">runtime_error</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="identifier">IncompleteRead</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">what</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">partial</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">ec</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">runtime_error</phrase><phrase role="special">(</phrase> <phrase role="identifier">what</phrase><phrase role="special">),</phrase> <phrase role="identifier">partial_</phrase><phrase role="special">(</phrase> <phrase role="identifier">partial</phrase><phrase role="special">),</phrase> <phrase role="identifier">ec_</phrase><phrase role="special">(</phrase> <phrase role="identifier">ec</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="special">}</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">get_partial</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">partial_</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">get_errorcode</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">ec_</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="keyword">private</phrase><phrase role="special">:</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">partial_</phrase><phrase role="special">;</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">ec_</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> </programlisting> </para> <para> and write a simple <code><phrase role="identifier">read</phrase><phrase role="special">()</phrase></code> function that either returns all desired data or throws <code><phrase role="identifier">IncompleteRead</phrase></code>: </para> <para> <programlisting><phrase role="comment">// read all desired data or throw IncompleteRead</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">read</phrase><phrase role="special">(</phrase> <phrase role="identifier">NonblockingAPI</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">api</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">desired</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">data</phrase><phrase role="special">;</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">ec</phrase><phrase role="special">(</phrase> <phrase role="identifier">read_desired</phrase><phrase role="special">(</phrase> <phrase role="identifier">api</phrase><phrase role="special">,</phrase> <phrase role="identifier">data</phrase><phrase role="special">,</phrase> <phrase role="identifier">desired</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="comment">// for present purposes, EOF isn't a failure</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="number">0</phrase> <phrase role="special">==</phrase> <phrase role="identifier">ec</phrase> <phrase role="special">||</phrase> <phrase role="identifier">EOF</phrase> <phrase role="special">==</phrase> <phrase role="identifier">ec</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">data</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="comment">// oh oh, partial read</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">ostringstream</phrase> <phrase role="identifier">msg</phrase><phrase role="special">;</phrase> <phrase role="identifier">msg</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;NonblockingAPI::read() error &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">ec</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; after &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">data</phrase><phrase role="special">.</phrase><phrase role="identifier">length</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; of &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">desired</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; characters&quot;</phrase><phrase role="special">;</phrase> <phrase role="keyword">throw</phrase> <phrase role="identifier">IncompleteRead</phrase><phrase role="special">(</phrase> <phrase role="identifier">msg</phrase><phrase role="special">.</phrase><phrase role="identifier">str</phrase><phrase role="special">(),</phrase> <phrase role="identifier">data</phrase><phrase role="special">,</phrase> <phrase role="identifier">ec</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> Once we can transparently wait for the next main-loop iteration using <link linkend="this_fiber_yield"><code>this_fiber::yield()</code></link>, ordinary encapsulation Just Works. </para> <para> The source code above is found in <ulink url="../../examples/adapt_nonblocking.cpp">adapt_nonblocking.cpp</ulink>. </para> </section> <section id="fiber.when_any"> <title><anchor id="when_any"/><link linkend="fiber.when_any">when_any / when_all functionality</link></title> <bridgehead renderas="sect3" id="fiber.when_any.h0"> <phrase id="fiber.when_any.overview"/><link linkend="fiber.when_any.overview">Overview</link> </bridgehead> <para> A bit of wisdom from the early days of computing still holds true today: prefer to model program state using the instruction pointer rather than with Boolean flags. In other words, if the program must <quote>do something</quote> and then do something almost the same, but with minor changes... perhaps parts of that something should be broken out as smaller separate functions, rather than introducing flags to alter the internal behavior of a monolithic function. </para> <para> To that we would add: prefer to describe control flow using C++ native constructs such as function calls, <code><phrase role="keyword">if</phrase></code>, <code><phrase role="keyword">while</phrase></code>, <code><phrase role="keyword">for</phrase></code>, <code><phrase role="keyword">do</phrase></code> et al. rather than as chains of callbacks. </para> <para> One of the great strengths of <emphasis role="bold">Boost.Fiber</emphasis> is the flexibility it confers on the coder to restructure an application from chains of callbacks to straightforward C++ statement sequence, even when code in that fiber is in fact interleaved with code running in other fibers. </para> <para> There has been much recent discussion about the benefits of when_any and when_all functionality. When dealing with asynchronous and possibly unreliable services, these are valuable idioms. But of course when_any and when_all are closely tied to the use of chains of callbacks. </para> <para> This section presents recipes for achieving the same ends, in the context of a fiber that wants to <quote>do something</quote> when one or more other independent activities have completed. Accordingly, these are <code><phrase role="identifier">wait_something</phrase><phrase role="special">()</phrase></code> functions rather than <code><phrase role="identifier">when_something</phrase><phrase role="special">()</phrase></code> functions. The expectation is that the calling fiber asks to launch those independent activities, then waits for them, then sequentially proceeds with whatever processing depends on those results. </para> <para> The function names shown (e.g. <link linkend="wait_first_simple"><code><phrase role="identifier">wait_first_simple</phrase><phrase role="special">()</phrase></code></link>) are for illustrative purposes only, because all these functions have been bundled into a single source file. Presumably, if (say) <link linkend="wait_first_success"><code><phrase role="identifier">wait_first_success</phrase><phrase role="special">()</phrase></code></link> best suits your application needs, you could introduce that variant with the name <code><phrase role="identifier">wait_any</phrase><phrase role="special">()</phrase></code>. </para> <note> <para> The functions presented in this section accept variadic argument lists of task functions. Corresponding <code><phrase role="identifier">wait_something</phrase><phrase role="special">()</phrase></code> functions accepting a container of task functions are left as an exercise for the interested reader. Those should actually be simpler. Most of the complexity would arise from overloading the same name for both purposes. </para> </note> <para> All the source code for this section is found in <ulink url="../../examples/wait_stuff.cpp">wait_stuff.cpp</ulink>. </para> <bridgehead renderas="sect3" id="fiber.when_any.h1"> <phrase id="fiber.when_any.example_task_function"/><link linkend="fiber.when_any.example_task_function">Example Task Function</link> </bridgehead> <para> <anchor id="wait_sleeper"/>We found it convenient to model an asynchronous task using this function: </para> <para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">sleeper_impl</phrase><phrase role="special">(</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">item</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">ms</phrase><phrase role="special">,</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">thrw</phrase> <phrase role="special">=</phrase> <phrase role="keyword">false</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">ostringstream</phrase> <phrase role="identifier">descb</phrase><phrase role="special">,</phrase> <phrase role="identifier">funcb</phrase><phrase role="special">;</phrase> <phrase role="identifier">descb</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">item</phrase><phrase role="special">;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">desc</phrase><phrase role="special">(</phrase> <phrase role="identifier">descb</phrase><phrase role="special">.</phrase><phrase role="identifier">str</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase> <phrase role="identifier">funcb</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; sleeper(&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">item</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;)&quot;</phrase><phrase role="special">;</phrase> <phrase role="identifier">Verbose</phrase> <phrase role="identifier">v</phrase><phrase role="special">(</phrase> <phrase role="identifier">funcb</phrase><phrase role="special">.</phrase><phrase role="identifier">str</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">sleep_for</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">milliseconds</phrase><phrase role="special">(</phrase> <phrase role="identifier">ms</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">thrw</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">throw</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">runtime_error</phrase><phrase role="special">(</phrase> <phrase role="identifier">desc</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">item</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> with type-specific <code><phrase role="identifier">sleeper</phrase><phrase role="special">()</phrase></code> <quote>front ends</quote> for <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase></code>, <code><phrase role="keyword">double</phrase></code> and <code><phrase role="keyword">int</phrase></code>. </para> <para> <code><phrase role="identifier">Verbose</phrase></code> simply prints a message to <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase></code> on construction and destruction. </para> <para> Basically: </para> <orderedlist> <listitem> <simpara> <code><phrase role="identifier">sleeper</phrase><phrase role="special">()</phrase></code> prints a start message; </simpara> </listitem> <listitem> <simpara> sleeps for the specified number of milliseconds; </simpara> </listitem> <listitem> <simpara> if <code><phrase role="identifier">thrw</phrase></code> is passed as <code><phrase role="keyword">true</phrase></code>, throws a string description of the passed <code><phrase role="identifier">item</phrase></code>; </simpara> </listitem> <listitem> <simpara> else returns the passed <code><phrase role="identifier">item</phrase></code>. </simpara> </listitem> <listitem> <simpara> On the way out, <code><phrase role="identifier">sleeper</phrase><phrase role="special">()</phrase></code> produces a stop message. </simpara> </listitem> </orderedlist> <para> This function will feature in the example calls to the various functions presented below. </para> <section id="fiber.when_any.when_any"> <title><link linkend="fiber.when_any.when_any">when_any</link></title> <section id="fiber.when_any.when_any.when_any__simple_completion"> <title><anchor id="wait_first_simple_section"/><link linkend="fiber.when_any.when_any.when_any__simple_completion">when_any, simple completion</link></title> <para> The simplest case is when you only need to know that the first of a set of asynchronous tasks has completed &mdash; but you don't need to obtain a return value, and you're confident that they will not throw exceptions. </para> <para> <anchor id="wait_done"/>For this we introduce a <code><phrase role="identifier">Done</phrase></code> class to wrap a <code><phrase role="keyword">bool</phrase></code> variable with a <link linkend="class_condition_variable"><code>condition_variable</code></link> and a <link linkend="class_mutex"><code>mutex</code></link>: </para> <para> <programlisting><phrase role="comment">// Wrap canonical pattern for condition_variable + bool flag</phrase> <phrase role="keyword">struct</phrase> <phrase role="identifier">Done</phrase> <phrase role="special">{</phrase> <phrase role="keyword">private</phrase><phrase role="special">:</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_variable</phrase> <phrase role="identifier">cond</phrase><phrase role="special">;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">mutex</phrase> <phrase role="identifier">mutex</phrase><phrase role="special">;</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">ready</phrase> <phrase role="special">=</phrase> <phrase role="keyword">false</phrase><phrase role="special">;</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_ptr</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Done</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">ptr</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">wait</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">unique_lock</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">mutex</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">lock</phrase><phrase role="special">(</phrase> <phrase role="identifier">mutex</phrase><phrase role="special">);</phrase> <phrase role="identifier">cond</phrase><phrase role="special">.</phrase><phrase role="identifier">wait</phrase><phrase role="special">(</phrase> <phrase role="identifier">lock</phrase><phrase role="special">,</phrase> <phrase role="special">[</phrase><phrase role="keyword">this</phrase><phrase role="special">](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">ready</phrase><phrase role="special">;</phrase> <phrase role="special">});</phrase> <phrase role="special">}</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">notify</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">unique_lock</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">mutex</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">lock</phrase><phrase role="special">(</phrase> <phrase role="identifier">mutex</phrase><phrase role="special">);</phrase> <phrase role="identifier">ready</phrase> <phrase role="special">=</phrase> <phrase role="keyword">true</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="comment">// release mutex</phrase> <phrase role="identifier">cond</phrase><phrase role="special">.</phrase><phrase role="identifier">notify_one</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="special">};</phrase> </programlisting> </para> <para> The pattern we follow throughout this section is to pass a <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_ptr</phrase><phrase role="special">&lt;&gt;</phrase></code></ulink> to the relevant synchronization object to the various tasks' fiber functions. This eliminates nagging questions about the lifespan of the synchronization object relative to the last of the fibers. </para> <para> <anchor id="wait_first_simple"/><code><phrase role="identifier">wait_first_simple</phrase><phrase role="special">()</phrase></code> uses that tactic for <link linkend="wait_done"><code><phrase role="identifier">Done</phrase></code></link>: </para> <para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">wait_first_simple</phrase><phrase role="special">(</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Use shared_ptr because each function's fiber will bind it separately,</phrase> <phrase role="comment">// and we're going to return before the last of them completes.</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">done</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">make_shared</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Done</phrase> <phrase role="special">&gt;()</phrase> <phrase role="special">);</phrase> <phrase role="identifier">wait_first_simple_impl</phrase><phrase role="special">(</phrase> <phrase role="identifier">done</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">...</phrase> <phrase role="special">);</phrase> <phrase role="identifier">done</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">wait</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> <anchor id="wait_first_simple_impl"/><code><phrase role="identifier">wait_first_simple_impl</phrase><phrase role="special">()</phrase></code> is an ordinary recursion over the argument pack, capturing <code><phrase role="identifier">Done</phrase><phrase role="special">::</phrase><phrase role="identifier">ptr</phrase></code> for each new fiber: </para> <para> <programlisting><phrase role="comment">// Degenerate case: when there are no functions to wait for, return</phrase> <phrase role="comment">// immediately.</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">wait_first_simple_impl</phrase><phrase role="special">(</phrase> <phrase role="identifier">Done</phrase><phrase role="special">::</phrase><phrase role="identifier">ptr</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="special">}</phrase> <phrase role="comment">// When there's at least one function to wait for, launch it and recur to</phrase> <phrase role="comment">// process the rest.</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">wait_first_simple_impl</phrase><phrase role="special">(</phrase> <phrase role="identifier">Done</phrase><phrase role="special">::</phrase><phrase role="identifier">ptr</phrase> <phrase role="identifier">done</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">function</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <phrase role="special">[</phrase><phrase role="identifier">done</phrase><phrase role="special">,</phrase> <phrase role="identifier">function</phrase><phrase role="special">](){</phrase> <phrase role="identifier">function</phrase><phrase role="special">();</phrase> <phrase role="identifier">done</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">notify</phrase><phrase role="special">();</phrase> <phrase role="special">}).</phrase><phrase role="identifier">detach</phrase><phrase role="special">();</phrase> <phrase role="identifier">wait_first_simple_impl</phrase><phrase role="special">(</phrase> <phrase role="identifier">done</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">...</phrase> <phrase role="special">);</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> The body of the fiber's lambda is extremely simple, as promised: call the function, notify <link linkend="wait_done"><code><phrase role="identifier">Done</phrase></code></link> when it returns. The first fiber to do so allows <code><phrase role="identifier">wait_first_simple</phrase><phrase role="special">()</phrase></code> to return &mdash; which is why it's useful to have <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">Done</phrase><phrase role="special">&gt;</phrase></code> manage the lifespan of our <code><phrase role="identifier">Done</phrase></code> object rather than declaring it as a stack variable in <code><phrase role="identifier">wait_first_simple</phrase><phrase role="special">()</phrase></code>. </para> <para> This is how you might call it: </para> <para> <programlisting><phrase role="identifier">wait_first_simple</phrase><phrase role="special">(</phrase> <phrase role="special">[](){</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wfs_long&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">150</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wfs_medium&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">100</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wfs_short&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">50</phrase><phrase role="special">);</phrase> <phrase role="special">});</phrase> </programlisting> </para> <para> In this example, control resumes after <code><phrase role="identifier">wait_first_simple</phrase><phrase role="special">()</phrase></code> when <link linkend="wait_sleeper"><code><phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wfs_short&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">50</phrase><phrase role="special">)</phrase></code></link> completes &mdash; even though the other two <code><phrase role="identifier">sleeper</phrase><phrase role="special">()</phrase></code> fibers are still running. </para> </section> <section id="fiber.when_any.when_any.when_any__return_value"> <title><link linkend="fiber.when_any.when_any.when_any__return_value">when_any, return value</link></title> <para> It seems more useful to add the ability to capture the return value from the first of the task functions to complete. Again, we assume that none will throw an exception. </para> <para> One tactic would be to adapt our <link linkend="wait_done"><code><phrase role="identifier">Done</phrase></code></link> class to store the first of the return values, rather than a simple <code><phrase role="keyword">bool</phrase></code>. However, we choose instead to use a <link linkend="class_buffered_channel"><code>buffered_channel&lt;&gt;</code></link>. We'll only need to enqueue the first value, so we'll <link linkend="buffered_channel_close"><code>buffered_channel::close()</code></link> it once we've retrieved that value. Subsequent <code><phrase role="identifier">push</phrase><phrase role="special">()</phrase></code> calls will return <code><phrase role="identifier">closed</phrase></code>. </para> <para> <anchor id="wait_first_value"/> <programlisting><phrase role="comment">// Assume that all passed functions have the same return type. The return type</phrase> <phrase role="comment">// of wait_first_value() is the return type of the first passed function. It is</phrase> <phrase role="comment">// simply invalid to pass NO functions.</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">wait_first_value</phrase><phrase role="special">(</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">function</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">return_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">buffered_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">return_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">make_shared</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">channel_t</phrase> <phrase role="special">&gt;(</phrase> <phrase role="number">64</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="comment">// launch all the relevant fibers</phrase> <phrase role="identifier">wait_first_value_impl</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">return_t</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">function</phrase><phrase role="special">),</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">...</phrase> <phrase role="special">);</phrase> <phrase role="comment">// retrieve the first value</phrase> <phrase role="identifier">return_t</phrase> <phrase role="identifier">value</phrase><phrase role="special">(</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">value_pop</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase> <phrase role="comment">// close the channel: no subsequent push() has to succeed</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">close</phrase><phrase role="special">();</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">value</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> <anchor id="wait_first_value_impl"/>The meat of the <code><phrase role="identifier">wait_first_value_impl</phrase><phrase role="special">()</phrase></code> function is as you might expect: </para> <para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">wait_first_value_impl</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_ptr</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">buffered_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">chan</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">function</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <phrase role="special">[</phrase><phrase role="identifier">chan</phrase><phrase role="special">,</phrase> <phrase role="identifier">function</phrase><phrase role="special">](){</phrase> <phrase role="comment">// Ignore channel_op_status returned by push():</phrase> <phrase role="comment">// might be closed; we simply don't care.</phrase> <phrase role="identifier">chan</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="identifier">function</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase> <phrase role="special">}).</phrase><phrase role="identifier">detach</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> It calls the passed function, pushes its return value and ignores the <code><phrase role="identifier">push</phrase><phrase role="special">()</phrase></code> result. You might call it like this: </para> <para> <programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">wait_first_value</phrase><phrase role="special">(</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wfv_third&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">150</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wfv_second&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">100</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wfv_first&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">50</phrase><phrase role="special">);</phrase> <phrase role="special">});</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;wait_first_value() =&gt; &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">result</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="string">&quot;wfv_first&quot;</phrase><phrase role="special">);</phrase> </programlisting> </para> </section> <section id="fiber.when_any.when_any.when_any__produce_first_outcome__whether_result_or_exception"> <title><link linkend="fiber.when_any.when_any.when_any__produce_first_outcome__whether_result_or_exception">when_any, produce first outcome, whether result or exception</link></title> <para> We may not be running in an environment in which we can guarantee no exception will be thrown by any of our task functions. In that case, the above implementations of <code><phrase role="identifier">wait_first_something</phrase><phrase role="special">()</phrase></code> would be nave: as mentioned in <link linkend="exceptions">the section on Fiber Management</link>, an uncaught exception in one of our task fibers would cause <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">terminate</phrase><phrase role="special">()</phrase></code> to be called. </para> <para> Let's at least ensure that such an exception would propagate to the fiber awaiting the first result. We can use <link linkend="class_future"><code>future&lt;&gt;</code></link> to transport either a return value or an exception. Therefore, we will change <link linkend="wait_first_value"><code><phrase role="identifier">wait_first_value</phrase><phrase role="special">()</phrase></code></link>'s <link linkend="class_buffered_channel"><code>buffered_channel&lt;&gt;</code></link> to hold <code><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase></code> items instead of simply <code><phrase role="identifier">T</phrase></code>. </para> <para> Once we have a <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code> in hand, all we need do is call <link linkend="future_get"><code>future::get()</code></link>, which will either return the value or rethrow the exception. </para> <para> <anchor id="wait_first_outcome"/> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">wait_first_outcome</phrase><phrase role="special">(</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">function</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// In this case, the value we pass through the channel is actually a</phrase> <phrase role="comment">// future -- which is already ready. future can carry either a value or an</phrase> <phrase role="comment">// exception.</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">return_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">return_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">buffered_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">future_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">make_shared</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">channel_t</phrase> <phrase role="special">&gt;(</phrase> <phrase role="number">64</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="comment">// launch all the relevant fibers</phrase> <phrase role="identifier">wait_first_outcome_impl</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">return_t</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">function</phrase><phrase role="special">),</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">...</phrase> <phrase role="special">);</phrase> <phrase role="comment">// retrieve the first future</phrase> <phrase role="identifier">future_t</phrase> <phrase role="identifier">future</phrase><phrase role="special">(</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">value_pop</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase> <phrase role="comment">// close the channel: no subsequent push() has to succeed</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">close</phrase><phrase role="special">();</phrase> <phrase role="comment">// either return value or throw exception</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">future</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> So far so good &mdash; but there's a timing issue. How should we obtain the <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code> to <link linkend="buffered_channel_push"><code>buffered_channel::push()</code></link> on the queue? </para> <para> We could call <link linkend="fibers_async"><code>fibers::async()</code></link>. That would certainly produce a <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code> for the task function. The trouble is that it would return too quickly! We only want <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code> items for <emphasis>completed</emphasis> tasks on our <code><phrase role="identifier">queue</phrase><phrase role="special">&lt;&gt;</phrase></code>. In fact, we only want the <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code> for the one that completes first. If each fiber launched by <code><phrase role="identifier">wait_first_outcome</phrase><phrase role="special">()</phrase></code> were to <code><phrase role="identifier">push</phrase><phrase role="special">()</phrase></code> the result of calling <code><phrase role="identifier">async</phrase><phrase role="special">()</phrase></code>, the queue would only ever report the result of the leftmost task item &mdash; <emphasis>not</emphasis> the one that completes most quickly. </para> <para> Calling <link linkend="future_get"><code>future::get()</code></link> on the future returned by <code><phrase role="identifier">async</phrase><phrase role="special">()</phrase></code> wouldn't be right. You can only call <code><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code> once per <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code> instance! And if there were an exception, it would be rethrown inside the helper fiber at the producer end of the queue, rather than propagated to the consumer end. </para> <para> We could call <link linkend="future_wait"><code>future::wait()</code></link>. That would block the helper fiber until the <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code> became ready, at which point we could <code><phrase role="identifier">push</phrase><phrase role="special">()</phrase></code> it to be retrieved by <code><phrase role="identifier">wait_first_outcome</phrase><phrase role="special">()</phrase></code>. </para> <para> That would work &mdash; but there's a simpler tactic that avoids creating an extra fiber. We can wrap the task function in a <link linkend="class_packaged_task"><code>packaged_task&lt;&gt;</code></link>. While one naturally thinks of passing a <code><phrase role="identifier">packaged_task</phrase><phrase role="special">&lt;&gt;</phrase></code> to a new fiber &mdash; that is, in fact, what <code><phrase role="identifier">async</phrase><phrase role="special">()</phrase></code> does &mdash; in this case, we're already running in the helper fiber at the producer end of the queue! We can simply <emphasis>call</emphasis> the <code><phrase role="identifier">packaged_task</phrase><phrase role="special">&lt;&gt;</phrase></code>. On return from that call, the task function has completed, meaning that the <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code> obtained from the <code><phrase role="identifier">packaged_task</phrase><phrase role="special">&lt;&gt;</phrase></code> is certain to be ready. At that point we can simply <code><phrase role="identifier">push</phrase><phrase role="special">()</phrase></code> it to the queue. </para> <para> <anchor id="wait_first_outcome_impl"/> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">CHANP</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">wait_first_outcome_impl</phrase><phrase role="special">(</phrase> <phrase role="identifier">CHANP</phrase> <phrase role="identifier">chan</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">function</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <phrase role="comment">// Use std::bind() here for C++11 compatibility. C++11 lambda capture</phrase> <phrase role="comment">// can't move a move-only Fn type, but bind() can. Let bind() move the</phrase> <phrase role="comment">// channel pointer and the function into the bound object, passing</phrase> <phrase role="comment">// references into the lambda.</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase> <phrase role="special">[](</phrase> <phrase role="identifier">CHANP</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">chan</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">decay</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">function</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Instantiate a packaged_task to capture any exception thrown by</phrase> <phrase role="comment">// function.</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">packaged_task</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">T</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">task</phrase><phrase role="special">(</phrase> <phrase role="identifier">function</phrase><phrase role="special">);</phrase> <phrase role="comment">// Immediately run this packaged_task on same fiber. We want</phrase> <phrase role="comment">// function() to have completed BEFORE we push the future.</phrase> <phrase role="identifier">task</phrase><phrase role="special">();</phrase> <phrase role="comment">// Pass the corresponding future to consumer. Ignore</phrase> <phrase role="comment">// channel_op_status returned by push(): might be closed; we</phrase> <phrase role="comment">// simply don't care.</phrase> <phrase role="identifier">chan</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase> <phrase role="identifier">task</phrase><phrase role="special">.</phrase><phrase role="identifier">get_future</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="identifier">chan</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">function</phrase><phrase role="special">)</phrase> <phrase role="special">)).</phrase><phrase role="identifier">detach</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> Calling it might look like this: </para> <para> <programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">wait_first_outcome</phrase><phrase role="special">(</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wfos_first&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">50</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wfos_second&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">100</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wfos_third&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">150</phrase><phrase role="special">);</phrase> <phrase role="special">});</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;wait_first_outcome(success) =&gt; &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">result</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="string">&quot;wfos_first&quot;</phrase><phrase role="special">);</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">thrown</phrase><phrase role="special">;</phrase> <phrase role="keyword">try</phrase> <phrase role="special">{</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">wait_first_outcome</phrase><phrase role="special">(</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wfof_first&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">50</phrase><phrase role="special">,</phrase> <phrase role="keyword">true</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wfof_second&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">100</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wfof_third&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">150</phrase><phrase role="special">);</phrase> <phrase role="special">});</phrase> <phrase role="special">}</phrase> <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">e</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">thrown</phrase> <phrase role="special">=</phrase> <phrase role="identifier">e</phrase><phrase role="special">.</phrase><phrase role="identifier">what</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;wait_first_outcome(fail) threw '&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">thrown</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;'&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">thrown</phrase> <phrase role="special">==</phrase> <phrase role="string">&quot;wfof_first&quot;</phrase><phrase role="special">);</phrase> </programlisting> </para> </section> <section id="fiber.when_any.when_any.when_any__produce_first_success"> <title><link linkend="fiber.when_any.when_any.when_any__produce_first_success">when_any, produce first success</link></title> <para> One scenario for <quote>when_any</quote> functionality is when we're redundantly contacting some number of possibly-unreliable web services. Not only might they be slow &mdash; any one of them might produce a failure rather than the desired result. </para> <para> In such a case, <link linkend="wait_first_outcome"><code><phrase role="identifier">wait_first_outcome</phrase><phrase role="special">()</phrase></code></link> isn't the right approach. If one of the services produces an error quickly, while another follows up with a real answer, we don't want to prefer the error just because it arrived first! </para> <para> Given the <code><phrase role="identifier">queue</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase></code> we already constructed for <code><phrase role="identifier">wait_first_outcome</phrase><phrase role="special">()</phrase></code>, though, we can readily recast the interface function to deliver the first <emphasis>successful</emphasis> result. </para> <para> That does beg the question: what if <emphasis>all</emphasis> the task functions throw an exception? In that case we'd probably better know about it. </para> <para> <anchor id="exception_list"/>The <ulink url="path_to_url#parallel.exceptions.synopsis">C++ Parallelism Draft Technical Specification</ulink> proposes a <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception_list</phrase></code> exception capable of delivering a collection of <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception_ptr</phrase></code>s. Until that becomes universally available, let's fake up an <code><phrase role="identifier">exception_list</phrase></code> of our own: </para> <para> <programlisting><phrase role="keyword">class</phrase> <phrase role="identifier">exception_list</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">runtime_error</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="identifier">exception_list</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">what</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">runtime_error</phrase><phrase role="special">(</phrase> <phrase role="identifier">what</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="special">}</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception_ptr</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">bundle_t</phrase><phrase role="special">;</phrase> <phrase role="comment">// N4407 proposed std::exception_list API</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">bundle_t</phrase><phrase role="special">::</phrase><phrase role="identifier">const_iterator</phrase> <phrase role="identifier">iterator</phrase><phrase role="special">;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">bundle_</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="identifier">iterator</phrase> <phrase role="identifier">begin</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">bundle_</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="identifier">iterator</phrase> <phrase role="identifier">end</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">bundle_</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="comment">// extension to populate</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">add</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception_ptr</phrase> <phrase role="identifier">ep</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">bundle_</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase> <phrase role="identifier">ep</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="keyword">private</phrase><phrase role="special">:</phrase> <phrase role="identifier">bundle_t</phrase> <phrase role="identifier">bundle_</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> </programlisting> </para> <para> Now we can build <code><phrase role="identifier">wait_first_success</phrase><phrase role="special">()</phrase></code>, using <link linkend="wait_first_outcome_impl"><code><phrase role="identifier">wait_first_outcome_impl</phrase><phrase role="special">()</phrase></code></link>. </para> <para> Instead of retrieving only the first <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code> from the queue, we must now loop over <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code> items. Of course we must limit that iteration! If we launch only <code><phrase role="identifier">count</phrase></code> producer fibers, the <code><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">+</phrase><phrase role="number">1</phrase><phrase role="special">)</phrase></code><superscript>st</superscript> <link linkend="buffered_channel_pop"><code>buffered_channel::pop()</code></link> call would block forever. </para> <para> Given a ready <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code>, we can distinguish failure by calling <link linkend="future_get_exception_ptr"><code>future::get_exception_ptr()</code></link>. If the <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code> in fact contains a result rather than an exception, <code><phrase role="identifier">get_exception_ptr</phrase><phrase role="special">()</phrase></code> returns <code><phrase role="keyword">nullptr</phrase></code>. In that case, we can confidently call <link linkend="future_get"><code>future::get()</code></link> to return that result to our caller. </para> <para> If the <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception_ptr</phrase></code> is <emphasis>not</emphasis> <code><phrase role="keyword">nullptr</phrase></code>, though, we collect it into our pending <code><phrase role="identifier">exception_list</phrase></code> and loop back for the next <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code> from the queue. </para> <para> If we fall out of the loop &mdash; if every single task fiber threw an exception &mdash; we throw the <code><phrase role="identifier">exception_list</phrase></code> exception into which we've been collecting those <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception_ptr</phrase></code>s. </para> <para> <anchor id="wait_first_success"/> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">wait_first_success</phrase><phrase role="special">(</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">function</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">count</phrase><phrase role="special">(</phrase> <phrase role="number">1</phrase> <phrase role="special">+</phrase> <phrase role="keyword">sizeof</phrase> <phrase role="special">...</phrase> <phrase role="special">(</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="comment">// In this case, the value we pass through the channel is actually a</phrase> <phrase role="comment">// future -- which is already ready. future can carry either a value or an</phrase> <phrase role="comment">// exception.</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">decay</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">return_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">return_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">buffered_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">future_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">make_shared</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">channel_t</phrase> <phrase role="special">&gt;(</phrase> <phrase role="number">64</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="comment">// launch all the relevant fibers</phrase> <phrase role="identifier">wait_first_outcome_impl</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">return_t</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">function</phrase><phrase role="special">),</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">...</phrase> <phrase role="special">);</phrase> <phrase role="comment">// instantiate exception_list, just in case</phrase> <phrase role="identifier">exception_list</phrase> <phrase role="identifier">exceptions</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wait_first_success() produced only errors&quot;</phrase><phrase role="special">);</phrase> <phrase role="comment">// retrieve up to 'count' results -- but stop there!</phrase> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">count</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// retrieve the next future</phrase> <phrase role="identifier">future_t</phrase> <phrase role="identifier">future</phrase><phrase role="special">(</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">value_pop</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase> <phrase role="comment">// retrieve exception_ptr if any</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception_ptr</phrase> <phrase role="identifier">error</phrase><phrase role="special">(</phrase> <phrase role="identifier">future</phrase><phrase role="special">.</phrase><phrase role="identifier">get_exception_ptr</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase> <phrase role="comment">// if no error, then yay, return value</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="special">!</phrase> <phrase role="identifier">error</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// close the channel: no subsequent push() has to succeed</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">close</phrase><phrase role="special">();</phrase> <phrase role="comment">// show caller the value we got</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">future</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="comment">// error is non-null: collect</phrase> <phrase role="identifier">exceptions</phrase><phrase role="special">.</phrase><phrase role="identifier">add</phrase><phrase role="special">(</phrase> <phrase role="identifier">error</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="comment">// We only arrive here when every passed function threw an exception.</phrase> <phrase role="comment">// Throw our collection to inform caller.</phrase> <phrase role="keyword">throw</phrase> <phrase role="identifier">exceptions</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> A call might look like this: </para> <para> <programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">wait_first_success</phrase><phrase role="special">(</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wfss_first&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">50</phrase><phrase role="special">,</phrase> <phrase role="keyword">true</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wfss_second&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">100</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wfss_third&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">150</phrase><phrase role="special">);</phrase> <phrase role="special">});</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;wait_first_success(success) =&gt; &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">result</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">result</phrase> <phrase role="special">==</phrase> <phrase role="string">&quot;wfss_second&quot;</phrase><phrase role="special">);</phrase> </programlisting> </para> </section> <section id="fiber.when_any.when_any.when_any__heterogeneous_types"> <title><link linkend="fiber.when_any.when_any.when_any__heterogeneous_types">when_any, heterogeneous types</link></title> <para> We would be remiss to ignore the case in which the various task functions have distinct return types. That means that the value returned by the first of them might have any one of those types. We can express that with <ulink url="path_to_url">Boost.Variant</ulink>. </para> <para> To keep the example simple, we'll revert to pretending that none of them can throw an exception. That makes <code><phrase role="identifier">wait_first_value_het</phrase><phrase role="special">()</phrase></code> strongly resemble <link linkend="wait_first_value"><code><phrase role="identifier">wait_first_value</phrase><phrase role="special">()</phrase></code></link>. We can actually reuse <link linkend="wait_first_value_impl"><code><phrase role="identifier">wait_first_value_impl</phrase><phrase role="special">()</phrase></code></link>, merely passing <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variant</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T0</phrase><phrase role="special">,</phrase> <phrase role="identifier">T1</phrase><phrase role="special">,</phrase> <phrase role="special">...&gt;</phrase></code> as the queue's value type rather than the common <code><phrase role="identifier">T</phrase></code>! </para> <para> Naturally this could be extended to use <link linkend="wait_first_success"><code><phrase role="identifier">wait_first_success</phrase><phrase role="special">()</phrase></code></link> semantics instead. </para> <para> <programlisting><phrase role="comment">// No need to break out the first Fn for interface function: let the compiler</phrase> <phrase role="comment">// complain if empty.</phrase> <phrase role="comment">// Our functions have different return types, and we might have to return any</phrase> <phrase role="comment">// of them. Use a variant, expanding std::result_of&lt;Fn()&gt;::type for each Fn in</phrase> <phrase role="comment">// parameter pack.</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variant</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fns</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase> <phrase role="special">...</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">wait_first_value_het</phrase><phrase role="special">(</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Use buffered_channel&lt;boost::variant&lt;T1, T2, ...&gt;&gt;; see remarks above.</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variant</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fns</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase> <phrase role="special">...</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">return_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">buffered_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">return_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">make_shared</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">channel_t</phrase> <phrase role="special">&gt;(</phrase> <phrase role="number">64</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="comment">// launch all the relevant fibers</phrase> <phrase role="identifier">wait_first_value_impl</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">return_t</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">...</phrase> <phrase role="special">);</phrase> <phrase role="comment">// retrieve the first value</phrase> <phrase role="identifier">return_t</phrase> <phrase role="identifier">value</phrase><phrase role="special">(</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">value_pop</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase> <phrase role="comment">// close the channel: no subsequent push() has to succeed</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">close</phrase><phrase role="special">();</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">value</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> It might be called like this: </para> <para> <programlisting><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variant</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">wait_first_value_het</phrase><phrase role="special">(</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wfvh_third&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">150</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="number">3.14</phrase><phrase role="special">,</phrase> <phrase role="number">100</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="number">17</phrase><phrase role="special">,</phrase> <phrase role="number">50</phrase><phrase role="special">);</phrase> <phrase role="special">});</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;wait_first_value_het() =&gt; &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">result</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="identifier">assert</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">get</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="number">17</phrase><phrase role="special">);</phrase> </programlisting> </para> </section> <section id="fiber.when_any.when_any.when_any__a_dubious_alternative"> <title><link linkend="fiber.when_any.when_any.when_any__a_dubious_alternative">when_any, a dubious alternative</link></title> <para> Certain topics in C++ can arouse strong passions, and exceptions are no exception. We cannot resist mentioning &mdash; for purely informational purposes &mdash; that when you need only the <emphasis>first</emphasis> result from some number of concurrently-running fibers, it would be possible to pass a <literal>shared_ptr&lt;<link linkend="class_promise"><code>promise&lt;&gt;</code></link>&gt;</literal> to the participating fibers, then cause the initiating fiber to call <link linkend="future_get"><code>future::get()</code></link> on its <link linkend="class_future"><code>future&lt;&gt;</code></link>. The first fiber to call <link linkend="promise_set_value"><code>promise::set_value()</code></link> on that shared <code><phrase role="identifier">promise</phrase></code> will succeed; subsequent <code><phrase role="identifier">set_value</phrase><phrase role="special">()</phrase></code> calls on the same <code><phrase role="identifier">promise</phrase></code> instance will throw <code><phrase role="identifier">future_error</phrase></code>. </para> <para> Use this information at your own discretion. Beware the dark side. </para> </section> </section> <section id="fiber.when_any.when_all_functionality"> <title><link linkend="fiber.when_any.when_all_functionality">when_all functionality</link></title> <section id="fiber.when_any.when_all_functionality.when_all__simple_completion"> <title><link linkend="fiber.when_any.when_all_functionality.when_all__simple_completion">when_all, simple completion</link></title> <para> For the case in which we must wait for <emphasis>all</emphasis> task functions to complete &mdash; but we don't need results (or expect exceptions) from any of them &mdash; we can write <code><phrase role="identifier">wait_all_simple</phrase><phrase role="special">()</phrase></code> that looks remarkably like <link linkend="wait_first_simple"><code><phrase role="identifier">wait_first_simple</phrase><phrase role="special">()</phrase></code></link>. The difference is that instead of our <link linkend="wait_done"><code><phrase role="identifier">Done</phrase></code></link> class, we instantiate a <link linkend="class_barrier"><code>barrier</code></link> and call its <link linkend="barrier_wait"><code>barrier::wait()</code></link>. </para> <para> We initialize the <code><phrase role="identifier">barrier</phrase></code> with <code><phrase role="special">(</phrase><phrase role="identifier">count</phrase><phrase role="special">+</phrase><phrase role="number">1</phrase><phrase role="special">)</phrase></code> because we are launching <code><phrase role="identifier">count</phrase></code> fibers, plus the <code><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code> call within <code><phrase role="identifier">wait_all_simple</phrase><phrase role="special">()</phrase></code> itself. </para> <para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">wait_all_simple</phrase><phrase role="special">(</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">count</phrase><phrase role="special">(</phrase> <phrase role="keyword">sizeof</phrase> <phrase role="special">...</phrase> <phrase role="special">(</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="comment">// Initialize a barrier(count+1) because we'll immediately wait on it. We</phrase> <phrase role="comment">// don't want to wake up until 'count' more fibers wait on it. Even though</phrase> <phrase role="comment">// we'll stick around until the last of them completes, use shared_ptr</phrase> <phrase role="comment">// anyway because it's easier to be confident about lifespan issues.</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">barrier</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">make_shared</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">barrier</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">count</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="identifier">wait_all_simple_impl</phrase><phrase role="special">(</phrase> <phrase role="identifier">barrier</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">...</phrase> <phrase role="special">);</phrase> <phrase role="identifier">barrier</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">wait</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> As stated above, the only difference between <code><phrase role="identifier">wait_all_simple_impl</phrase><phrase role="special">()</phrase></code> and <link linkend="wait_first_simple_impl"><code><phrase role="identifier">wait_first_simple_impl</phrase><phrase role="special">()</phrase></code></link> is that the former calls <code><phrase role="identifier">barrier</phrase><phrase role="special">::</phrase><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code> rather than <code><phrase role="identifier">Done</phrase><phrase role="special">::</phrase><phrase role="identifier">notify</phrase><phrase role="special">()</phrase></code>: </para> <para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">wait_all_simple_impl</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_ptr</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">barrier</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">barrier</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">function</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">bind</phrase><phrase role="special">(</phrase> <phrase role="special">[](</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_ptr</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">barrier</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">barrier</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">decay</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">function</phrase><phrase role="special">)</phrase> <phrase role="keyword">mutable</phrase> <phrase role="special">{</phrase> <phrase role="identifier">function</phrase><phrase role="special">();</phrase> <phrase role="identifier">barrier</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">wait</phrase><phrase role="special">();</phrase> <phrase role="special">},</phrase> <phrase role="identifier">barrier</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">function</phrase><phrase role="special">)</phrase> <phrase role="special">)).</phrase><phrase role="identifier">detach</phrase><phrase role="special">();</phrase> <phrase role="identifier">wait_all_simple_impl</phrase><phrase role="special">(</phrase> <phrase role="identifier">barrier</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">...</phrase> <phrase role="special">);</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> You might call it like this: </para> <para> <programlisting><phrase role="identifier">wait_all_simple</phrase><phrase role="special">(</phrase> <phrase role="special">[](){</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;was_long&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">150</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;was_medium&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">100</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;was_short&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">50</phrase><phrase role="special">);</phrase> <phrase role="special">});</phrase> </programlisting> </para> <para> Control will not return from the <code><phrase role="identifier">wait_all_simple</phrase><phrase role="special">()</phrase></code> call until the last of its task functions has completed. </para> </section> <section id="fiber.when_any.when_all_functionality.when_all__return_values"> <title><link linkend="fiber.when_any.when_all_functionality.when_all__return_values">when_all, return values</link></title> <para> As soon as we want to collect return values from all the task functions, we can see right away how to reuse <link linkend="wait_first_value"><code><phrase role="identifier">wait_first_value</phrase><phrase role="special">()</phrase></code></link>'s queue&lt;T&gt; for the purpose. All we have to do is avoid closing it after the first value! </para> <para> But in fact, collecting multiple values raises an interesting question: do we <emphasis>really</emphasis> want to wait until the slowest of them has arrived? Wouldn't we rather process each result as soon as it becomes available? </para> <para> Fortunately we can present both APIs. Let's define <code><phrase role="identifier">wait_all_values_source</phrase><phrase role="special">()</phrase></code> to return <code><phrase role="identifier">shared_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">buffered_channel</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;&gt;</phrase></code>. </para> <para> <anchor id="wait_all_values"/>Given <code><phrase role="identifier">wait_all_values_source</phrase><phrase role="special">()</phrase></code>, it's straightforward to implement <code><phrase role="identifier">wait_all_values</phrase><phrase role="special">()</phrase></code>: </para> <para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">wait_all_values</phrase><phrase role="special">(</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">function</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">count</phrase><phrase role="special">(</phrase> <phrase role="number">1</phrase> <phrase role="special">+</phrase> <phrase role="keyword">sizeof</phrase> <phrase role="special">...</phrase> <phrase role="special">(</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">return_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">return_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">vector_t</phrase><phrase role="special">;</phrase> <phrase role="identifier">vector_t</phrase> <phrase role="identifier">results</phrase><phrase role="special">;</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">reserve</phrase><phrase role="special">(</phrase> <phrase role="identifier">count</phrase><phrase role="special">);</phrase> <phrase role="comment">// get channel</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_ptr</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">buffered_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">return_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">chan</phrase> <phrase role="special">=</phrase> <phrase role="identifier">wait_all_values_source</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">function</phrase><phrase role="special">),</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">...</phrase> <phrase role="special">);</phrase> <phrase role="comment">// fill results vector</phrase> <phrase role="identifier">return_t</phrase> <phrase role="identifier">value</phrase><phrase role="special">;</phrase> <phrase role="keyword">while</phrase> <phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">channel_op_status</phrase><phrase role="special">::</phrase><phrase role="identifier">success</phrase> <phrase role="special">==</phrase> <phrase role="identifier">chan</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">pop</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase> <phrase role="identifier">value</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="comment">// return vector to caller</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">results</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> It might be called like this: </para> <para> <programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">values</phrase> <phrase role="special">=</phrase> <phrase role="identifier">wait_all_values</phrase><phrase role="special">(</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wav_late&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">150</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wav_middle&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">100</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wav_early&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">50</phrase><phrase role="special">);</phrase> <phrase role="special">});</phrase> </programlisting> </para> <para> As you can see from the loop in <code><phrase role="identifier">wait_all_values</phrase><phrase role="special">()</phrase></code>, instead of requiring its caller to count values, we define <code><phrase role="identifier">wait_all_values_source</phrase><phrase role="special">()</phrase></code> to <link linkend="buffered_channel_close"><code>buffered_channel::close()</code></link> the queue when done. But how do we do that? Each producer fiber is independent. It has no idea whether it is the last one to <link linkend="buffered_channel_push"><code>buffered_channel::push()</code></link> a value. </para> <para> <anchor id="wait_nqueue"/>We can address that problem with a counting faade for the <code><phrase role="identifier">queue</phrase><phrase role="special">&lt;&gt;</phrase></code>. In fact, our faade need only support the producer end of the queue. </para> <para> [wait_nqueue] </para> <para> <anchor id="wait_all_values_source"/>Armed with <code><phrase role="identifier">nqueue</phrase><phrase role="special">&lt;&gt;</phrase></code>, we can implement <code><phrase role="identifier">wait_all_values_source</phrase><phrase role="special">()</phrase></code>. It starts just like <link linkend="wait_first_value"><code><phrase role="identifier">wait_first_value</phrase><phrase role="special">()</phrase></code></link>. The difference is that we wrap the <code><phrase role="identifier">queue</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase></code> with an <code><phrase role="identifier">nqueue</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase></code> to pass to the producer fibers. </para> <para> Then, of course, instead of popping the first value, closing the queue and returning it, we simply return the <code><phrase role="identifier">shared_ptr</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">queue</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;&gt;</phrase></code>. </para> <para> <programlisting><phrase role="comment">// Return a shared_ptr&lt;buffered_channel&lt;T&gt;&gt; from which the caller can</phrase> <phrase role="comment">// retrieve each new result as it arrives, until 'closed'.</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_ptr</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">buffered_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">wait_all_values_source</phrase><phrase role="special">(</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">function</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">count</phrase><phrase role="special">(</phrase> <phrase role="number">1</phrase> <phrase role="special">+</phrase> <phrase role="keyword">sizeof</phrase> <phrase role="special">...</phrase> <phrase role="special">(</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">return_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">buffered_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">return_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_t</phrase><phrase role="special">;</phrase> <phrase role="comment">// make the channel</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">make_shared</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">channel_t</phrase> <phrase role="special">&gt;(</phrase> <phrase role="number">64</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="comment">// and make an nchannel facade to close it after 'count' items</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">ncp</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">make_shared</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">nchannel</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">return_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">,</phrase> <phrase role="identifier">count</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="comment">// pass that nchannel facade to all the relevant fibers</phrase> <phrase role="identifier">wait_all_values_impl</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">return_t</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">ncp</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">function</phrase><phrase role="special">),</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">...</phrase> <phrase role="special">);</phrase> <phrase role="comment">// then return the channel for consumer</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> For example: </para> <para> <programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_ptr</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">buffered_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">chan</phrase> <phrase role="special">=</phrase> <phrase role="identifier">wait_all_values_source</phrase><phrase role="special">(</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wavs_third&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">150</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wavs_second&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">100</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wavs_first&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">50</phrase><phrase role="special">);</phrase> <phrase role="special">});</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">value</phrase><phrase role="special">;</phrase> <phrase role="keyword">while</phrase> <phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">channel_op_status</phrase><phrase role="special">::</phrase><phrase role="identifier">success</phrase> <phrase role="special">==</phrase> <phrase role="identifier">chan</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">pop</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;wait_all_values_source() =&gt; '&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">value</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;'&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> <anchor id="wait_all_values_impl"/><code><phrase role="identifier">wait_all_values_impl</phrase><phrase role="special">()</phrase></code> really is just like <link linkend="wait_first_value_impl"><code><phrase role="identifier">wait_first_value_impl</phrase><phrase role="special">()</phrase></code></link> except for the use of <code><phrase role="identifier">nqueue</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase></code> rather than <code><phrase role="identifier">queue</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase></code>: </para> <para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">wait_all_values_impl</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_ptr</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">nchannel</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">chan</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">function</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <phrase role="special">[</phrase><phrase role="identifier">chan</phrase><phrase role="special">,</phrase> <phrase role="identifier">function</phrase><phrase role="special">](){</phrase> <phrase role="identifier">chan</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">push</phrase><phrase role="special">(</phrase><phrase role="identifier">function</phrase><phrase role="special">());</phrase> <phrase role="special">}).</phrase><phrase role="identifier">detach</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> </programlisting> </para> </section> <section id="fiber.when_any.when_all_functionality.when_all_until_first_exception"> <title><link linkend="fiber.when_any.when_all_functionality.when_all_until_first_exception">when_all until first exception</link></title> <para> Naturally, just as with <link linkend="wait_first_outcome"><code><phrase role="identifier">wait_first_outcome</phrase><phrase role="special">()</phrase></code></link>, we can elaborate <link linkend="wait_all_values"><code><phrase role="identifier">wait_all_values</phrase><phrase role="special">()</phrase></code></link> and <link linkend="wait_all_values_source"><code><phrase role="identifier">wait_all_values_source</phrase><phrase role="special">()</phrase></code></link> by passing <code><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase></code> instead of plain <code><phrase role="identifier">T</phrase></code>. </para> <para> <anchor id="wait_all_until_error"/><code><phrase role="identifier">wait_all_until_error</phrase><phrase role="special">()</phrase></code> pops that <code><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase></code> and calls its <link linkend="future_get"><code>future::get()</code></link>: </para> <para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">wait_all_until_error</phrase><phrase role="special">(</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">function</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">count</phrase><phrase role="special">(</phrase> <phrase role="number">1</phrase> <phrase role="special">+</phrase> <phrase role="keyword">sizeof</phrase> <phrase role="special">...</phrase> <phrase role="special">(</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">return_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">return_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">return_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">vector_t</phrase><phrase role="special">;</phrase> <phrase role="identifier">vector_t</phrase> <phrase role="identifier">results</phrase><phrase role="special">;</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">reserve</phrase><phrase role="special">(</phrase> <phrase role="identifier">count</phrase><phrase role="special">);</phrase> <phrase role="comment">// get channel</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_ptr</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">buffered_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">future_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">chan</phrase><phrase role="special">(</phrase> <phrase role="identifier">wait_all_until_error_source</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">function</phrase><phrase role="special">),</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="comment">// fill results vector</phrase> <phrase role="identifier">future_t</phrase> <phrase role="identifier">future</phrase><phrase role="special">;</phrase> <phrase role="keyword">while</phrase> <phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">channel_op_status</phrase><phrase role="special">::</phrase><phrase role="identifier">success</phrase> <phrase role="special">==</phrase> <phrase role="identifier">chan</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">pop</phrase><phrase role="special">(</phrase> <phrase role="identifier">future</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase> <phrase role="identifier">future</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="comment">// return vector to caller</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">results</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> For example: </para> <para> <programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">thrown</phrase><phrase role="special">;</phrase> <phrase role="keyword">try</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">values</phrase> <phrase role="special">=</phrase> <phrase role="identifier">wait_all_until_error</phrase><phrase role="special">(</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;waue_late&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">150</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;waue_middle&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">100</phrase><phrase role="special">,</phrase> <phrase role="keyword">true</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;waue_early&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">50</phrase><phrase role="special">);</phrase> <phrase role="special">});</phrase> <phrase role="special">}</phrase> <phrase role="keyword">catch</phrase> <phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">e</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">thrown</phrase> <phrase role="special">=</phrase> <phrase role="identifier">e</phrase><phrase role="special">.</phrase><phrase role="identifier">what</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;wait_all_until_error(fail) threw '&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">thrown</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;'&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> </programlisting> </para> <para> <anchor id="wait_all_until_error_source"/>Naturally this complicates the API for <code><phrase role="identifier">wait_all_until_error_source</phrase><phrase role="special">()</phrase></code>. The caller must both retrieve a <code><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">T</phrase> <phrase role="special">&gt;</phrase></code> and call its <code><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code> method. It would, of course, be possible to return a faade over the consumer end of the queue that would implicitly perform the <code><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code> and return a simple <code><phrase role="identifier">T</phrase></code> (or throw). </para> <para> The implementation is just as you would expect. Notice, however, that we can reuse <link linkend="wait_first_outcome_impl"><code><phrase role="identifier">wait_first_outcome_impl</phrase><phrase role="special">()</phrase></code></link>, passing the <code><phrase role="identifier">nqueue</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase></code> rather than <code><phrase role="identifier">queue</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">T</phrase><phrase role="special">&gt;</phrase></code>. </para> <para> <programlisting><phrase role="comment">// Return a shared_ptr&lt;buffered_channel&lt;future&lt;T&gt;&gt;&gt; from which the caller can</phrase> <phrase role="comment">// get() each new result as it arrives, until 'closed'.</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_ptr</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">buffered_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">wait_all_until_error_source</phrase><phrase role="special">(</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">function</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">count</phrase><phrase role="special">(</phrase> <phrase role="number">1</phrase> <phrase role="special">+</phrase> <phrase role="keyword">sizeof</phrase> <phrase role="special">...</phrase> <phrase role="special">(</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">return_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">return_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">buffered_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">future_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">channel_t</phrase><phrase role="special">;</phrase> <phrase role="comment">// make the channel</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">make_shared</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">channel_t</phrase> <phrase role="special">&gt;(</phrase> <phrase role="number">64</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="comment">// and make an nchannel facade to close it after 'count' items</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">ncp</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">make_shared</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">nchannel</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">future_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">,</phrase> <phrase role="identifier">count</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="comment">// pass that nchannel facade to all the relevant fibers</phrase> <phrase role="identifier">wait_first_outcome_impl</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">return_t</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">ncp</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">function</phrase><phrase role="special">),</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">...</phrase> <phrase role="special">);</phrase> <phrase role="comment">// then return the channel for consumer</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">chanp</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> For example: </para> <para> <programlisting><phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future_t</phrase><phrase role="special">;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_ptr</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">buffered_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">future_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">chan</phrase> <phrase role="special">=</phrase> <phrase role="identifier">wait_all_until_error_source</phrase><phrase role="special">(</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wauess_third&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">150</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wauess_second&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">100</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wauess_first&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">50</phrase><phrase role="special">);</phrase> <phrase role="special">});</phrase> <phrase role="identifier">future_t</phrase> <phrase role="identifier">future</phrase><phrase role="special">;</phrase> <phrase role="keyword">while</phrase> <phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">channel_op_status</phrase><phrase role="special">::</phrase><phrase role="identifier">success</phrase> <phrase role="special">==</phrase> <phrase role="identifier">chan</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">pop</phrase><phrase role="special">(</phrase> <phrase role="identifier">future</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">value</phrase><phrase role="special">(</phrase> <phrase role="identifier">future</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;wait_all_until_error_source(success) =&gt; '&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">value</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;'&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> </programlisting> </para> </section> <section id="fiber.when_any.when_all_functionality.wait_all__collecting_all_exceptions"> <title><link linkend="fiber.when_any.when_all_functionality.wait_all__collecting_all_exceptions">wait_all, collecting all exceptions</link></title> <para> <anchor id="wait_all_collect_errors"/>Given <link linkend="wait_all_until_error_source"><code><phrase role="identifier">wait_all_until_error_source</phrase><phrase role="special">()</phrase></code></link>, it might be more reasonable to make a <code><phrase role="identifier">wait_all_</phrase><phrase role="special">...()</phrase></code> that collects <emphasis>all</emphasis> errors instead of presenting only the first: </para> <para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">wait_all_collect_errors</phrase><phrase role="special">(</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">function</phrase><phrase role="special">,</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">count</phrase><phrase role="special">(</phrase> <phrase role="number">1</phrase> <phrase role="special">+</phrase> <phrase role="keyword">sizeof</phrase> <phrase role="special">...</phrase> <phrase role="special">(</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">result_of</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase><phrase role="special">()</phrase> <phrase role="special">&gt;::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">return_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">future</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">return_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">future_t</phrase><phrase role="special">;</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">return_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">vector_t</phrase><phrase role="special">;</phrase> <phrase role="identifier">vector_t</phrase> <phrase role="identifier">results</phrase><phrase role="special">;</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">reserve</phrase><phrase role="special">(</phrase> <phrase role="identifier">count</phrase><phrase role="special">);</phrase> <phrase role="identifier">exception_list</phrase> <phrase role="identifier">exceptions</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wait_all_collect_errors() exceptions&quot;</phrase><phrase role="special">);</phrase> <phrase role="comment">// get channel</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_ptr</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">buffered_channel</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">future_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">chan</phrase><phrase role="special">(</phrase> <phrase role="identifier">wait_all_until_error_source</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">function</phrase><phrase role="special">),</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">...</phrase> <phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="comment">// fill results and/or exceptions vectors</phrase> <phrase role="identifier">future_t</phrase> <phrase role="identifier">future</phrase><phrase role="special">;</phrase> <phrase role="keyword">while</phrase> <phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">channel_op_status</phrase><phrase role="special">::</phrase><phrase role="identifier">success</phrase> <phrase role="special">==</phrase> <phrase role="identifier">chan</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">pop</phrase><phrase role="special">(</phrase> <phrase role="identifier">future</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">exception_ptr</phrase> <phrase role="identifier">exp</phrase> <phrase role="special">=</phrase> <phrase role="identifier">future</phrase><phrase role="special">.</phrase><phrase role="identifier">get_exception_ptr</phrase><phrase role="special">();</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="special">!</phrase> <phrase role="identifier">exp</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">results</phrase><phrase role="special">.</phrase><phrase role="identifier">push_back</phrase><phrase role="special">(</phrase> <phrase role="identifier">future</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="keyword">else</phrase> <phrase role="special">{</phrase> <phrase role="identifier">exceptions</phrase><phrase role="special">.</phrase><phrase role="identifier">add</phrase><phrase role="special">(</phrase> <phrase role="identifier">exp</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> <phrase role="comment">// if there were any exceptions, throw</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">exceptions</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">()</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">throw</phrase> <phrase role="identifier">exceptions</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="comment">// no exceptions: return vector to caller</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">results</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> The implementation is a simple variation on <link linkend="wait_first_success"><code><phrase role="identifier">wait_first_success</phrase><phrase role="special">()</phrase></code></link>, using the same <link linkend="exception_list"><code><phrase role="identifier">exception_list</phrase></code></link> exception class. </para> </section> <section id="fiber.when_any.when_all_functionality.when_all__heterogeneous_types"> <title><link linkend="fiber.when_any.when_all_functionality.when_all__heterogeneous_types">when_all, heterogeneous types</link></title> <para> But what about the case when we must wait for all results of different types? </para> <para> We can present an API that is frankly quite cool. Consider a sample struct: </para> <para> <programlisting><phrase role="keyword">struct</phrase> <phrase role="identifier">Data</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">str</phrase><phrase role="special">;</phrase> <phrase role="keyword">double</phrase> <phrase role="identifier">inexact</phrase><phrase role="special">;</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">exact</phrase><phrase role="special">;</phrase> <phrase role="keyword">friend</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">ostream</phrase><phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">&lt;&lt;(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">ostream</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">out</phrase><phrase role="special">,</phrase> <phrase role="identifier">Data</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">data</phrase><phrase role="special">);</phrase> <phrase role="special">...</phrase> <phrase role="special">};</phrase> </programlisting> </para> <para> Let's fill its members from task functions all running concurrently: </para> <para> <programlisting><phrase role="identifier">Data</phrase> <phrase role="identifier">data</phrase> <phrase role="special">=</phrase> <phrase role="identifier">wait_all_members</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Data</phrase> <phrase role="special">&gt;(</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wams_left&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">100</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="number">3.14</phrase><phrase role="special">,</phrase> <phrase role="number">150</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="number">17</phrase><phrase role="special">,</phrase> <phrase role="number">50</phrase><phrase role="special">);</phrase> <phrase role="special">});</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;wait_all_members&lt;Data&gt;(success) =&gt; &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">data</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> </programlisting> </para> <para> Note that for this case, we abandon the notion of capturing the earliest result first, and so on: we must fill exactly the passed struct in left-to-right order. </para> <para> That permits a beautifully simple implementation: </para> <para> <programlisting><phrase role="comment">// Explicitly pass Result. This can be any type capable of being initialized</phrase> <phrase role="comment">// from the results of the passed functions, such as a struct.</phrase> <phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Result</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">Result</phrase> <phrase role="identifier">wait_all_members</phrase><phrase role="special">(</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Run each of the passed functions on a separate fiber, passing all their</phrase> <phrase role="comment">// futures to helper function for processing.</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">wait_all_members_get</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Result</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">forward</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">Fns</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">functions</phrase><phrase role="special">)</phrase> <phrase role="special">)</phrase> <phrase role="special">...</phrase> <phrase role="special">);</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Result</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="special">...</phrase> <phrase role="identifier">Futures</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">Result</phrase> <phrase role="identifier">wait_all_members_get</phrase><phrase role="special">(</phrase> <phrase role="identifier">Futures</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="special">...</phrase> <phrase role="identifier">futures</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Fetch the results from the passed futures into Result's initializer</phrase> <phrase role="comment">// list. It's true that the get() calls here will block the implicit</phrase> <phrase role="comment">// iteration over futures -- but that doesn't matter because we won't be</phrase> <phrase role="comment">// done until the slowest of them finishes anyway. As results are</phrase> <phrase role="comment">// processed in argument-list order rather than order of completion, the</phrase> <phrase role="comment">// leftmost get() to throw an exception will cause that exception to</phrase> <phrase role="comment">// propagate to the caller.</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">Result</phrase><phrase role="special">{</phrase> <phrase role="identifier">futures</phrase><phrase role="special">.</phrase><phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="special">...</phrase> <phrase role="special">};</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> It is tempting to try to implement <code><phrase role="identifier">wait_all_members</phrase><phrase role="special">()</phrase></code> as a one-liner like this: </para> <programlisting><phrase role="keyword">return</phrase> <phrase role="identifier">Result</phrase><phrase role="special">{</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase><phrase role="special">(</phrase><phrase role="identifier">functions</phrase><phrase role="special">).</phrase><phrase role="identifier">get</phrase><phrase role="special">()...</phrase> <phrase role="special">};</phrase> </programlisting> <para> The trouble with this tactic is that it would serialize all the task functions. The runtime makes a single pass through <code><phrase role="identifier">functions</phrase></code>, calling <link linkend="fibers_async"><code>fibers::async()</code></link> for each and then immediately calling <link linkend="future_get"><code>future::get()</code></link> on its returned <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code>. That blocks the implicit loop. The above is almost equivalent to writing: </para> <programlisting><phrase role="keyword">return</phrase> <phrase role="identifier">Result</phrase><phrase role="special">{</phrase> <phrase role="identifier">functions</phrase><phrase role="special">()...</phrase> <phrase role="special">};</phrase> </programlisting> <para> in which, of course, there is no concurrency at all. </para> <para> Passing the argument pack through a function-call boundary (<code><phrase role="identifier">wait_all_members_get</phrase><phrase role="special">()</phrase></code>) forces the runtime to make <emphasis>two</emphasis> passes: one in <code><phrase role="identifier">wait_all_members</phrase><phrase role="special">()</phrase></code> to collect the <code><phrase role="identifier">future</phrase><phrase role="special">&lt;&gt;</phrase></code>s from all the <code><phrase role="identifier">async</phrase><phrase role="special">()</phrase></code> calls, the second in <code><phrase role="identifier">wait_all_members_get</phrase><phrase role="special">()</phrase></code> to fetch each of the results. </para> <para> As noted in comments, within the <code><phrase role="identifier">wait_all_members_get</phrase><phrase role="special">()</phrase></code> parameter pack expansion pass, the blocking behavior of <code><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code> becomes irrelevant. Along the way, we will hit the <code><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code> for the slowest task function; after that every subsequent <code><phrase role="identifier">get</phrase><phrase role="special">()</phrase></code> will complete in trivial time. </para> <para> By the way, we could also use this same API to fill a vector or other collection: </para> <para> <programlisting><phrase role="comment">// If we don't care about obtaining results as soon as they arrive, and we</phrase> <phrase role="comment">// prefer a result vector in passed argument order rather than completion</phrase> <phrase role="comment">// order, wait_all_members() is another possible implementation of</phrase> <phrase role="comment">// wait_all_until_error().</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">strings</phrase> <phrase role="special">=</phrase> <phrase role="identifier">wait_all_members</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;(</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wamv_left&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">150</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wamv_middle&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">100</phrase><phrase role="special">);</phrase> <phrase role="special">},</phrase> <phrase role="special">[](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">sleeper</phrase><phrase role="special">(</phrase><phrase role="string">&quot;wamv_right&quot;</phrase><phrase role="special">,</phrase> <phrase role="number">50</phrase><phrase role="special">);</phrase> <phrase role="special">});</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;wait_all_members&lt;vector&gt;() =&gt;&quot;</phrase><phrase role="special">;</phrase> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">str</phrase> <phrase role="special">:</phrase> <phrase role="identifier">strings</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; '&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">str</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;'&quot;</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> </programlisting> </para> </section> </section> </section> <section id="fiber.integration"> <title><anchor id="integration"/><link linkend="fiber.integration">Sharing a Thread with Another Main Loop</link></title> <section id="fiber.integration.overview"> <title><link linkend="fiber.integration.overview">Overview</link></title> <para> As always with cooperative concurrency, it is important not to let any one fiber monopolize the processor too long: that could <quote>starve</quote> other ready fibers. This section discusses a couple of solutions. </para> </section> <section id="fiber.integration.event_driven_program"> <title><link linkend="fiber.integration.event_driven_program">Event-Driven Program</link></title> <para> Consider a classic event-driven program, organized around a main loop that fetches and dispatches incoming I/O events. You are introducing <emphasis role="bold">Boost.Fiber</emphasis> because certain asynchronous I/O sequences are logically sequential, and for those you want to write and maintain code that looks and acts sequential. </para> <para> You are launching fibers on the application&#8217;s main thread because certain of their actions will affect its user interface, and the application&#8217;s UI framework permits UI operations only on the main thread. Or perhaps those fibers need access to main-thread data, and it would be too expensive in runtime (or development time) to robustly defend every such data item with thread synchronization primitives. </para> <para> You must ensure that the application&#8217;s main loop <emphasis>itself</emphasis> doesn&#8217;t monopolize the processor: that the fibers it launches will get the CPU cycles they need. </para> <para> The solution is the same as for any fiber that might claim the CPU for an extended time: introduce calls to <link linkend="this_fiber_yield"><code>this_fiber::yield()</code></link>. The most straightforward approach is to call <code><phrase role="identifier">yield</phrase><phrase role="special">()</phrase></code> on every iteration of your existing main loop. In effect, this unifies the application&#8217;s main loop with <emphasis role="bold">Boost.Fiber</emphasis>&#8217;s internal main loop. <code><phrase role="identifier">yield</phrase><phrase role="special">()</phrase></code> allows the fiber manager to run any fibers that have become ready since the previous iteration of the application&#8217;s main loop. When these fibers have had a turn, control passes to the thread&#8217;s main fiber, which returns from <code><phrase role="identifier">yield</phrase><phrase role="special">()</phrase></code> and resumes the application&#8217;s main loop. </para> </section> <section id="fiber.integration.embedded_main_loop"> <title><anchor id="embedded_main_loop"/><link linkend="fiber.integration.embedded_main_loop">Embedded Main Loop</link></title> <para> More challenging is when the application&#8217;s main loop is embedded in some other library or framework. Such an application will typically, after performing all necessary setup, pass control to some form of <code><phrase role="identifier">run</phrase><phrase role="special">()</phrase></code> function from which control does not return until application shutdown. </para> <para> A <ulink url="path_to_url">Boost.Asio</ulink> program might call <ulink url="path_to_url"><code><phrase role="identifier">io_service</phrase><phrase role="special">::</phrase><phrase role="identifier">run</phrase><phrase role="special">()</phrase></code></ulink> in this way. </para> <para> In general, the trick is to arrange to pass control to <link linkend="this_fiber_yield"><code>this_fiber::yield()</code></link> frequently. You could use an <ulink url="path_to_url">Asio timer</ulink> for that purpose. You could instantiate the timer, arranging to call a handler function when the timer expires. The handler function could call <code><phrase role="identifier">yield</phrase><phrase role="special">()</phrase></code>, then reset the timer and arrange to wake up again on its next expiration. </para> <para> Since, in this thought experiment, we always pass control to the fiber manager via <code><phrase role="identifier">yield</phrase><phrase role="special">()</phrase></code>, the calling fiber is never blocked. Therefore there is always at least one ready fiber. Therefore the fiber manager never calls <link linkend="algorithm_suspend_until"><code>algorithm::suspend_until()</code></link>. </para> <para> Using <ulink url="path_to_url"><code><phrase role="identifier">io_service</phrase><phrase role="special">::</phrase><phrase role="identifier">post</phrase><phrase role="special">()</phrase></code></ulink> instead of setting a timer for some nonzero interval would be unfriendly to other threads. When all I/O is pending and all fibers are blocked, the io_service and the fiber manager would simply spin the CPU, passing control back and forth to each other. Using a timer allows tuning the responsiveness of this thread relative to others. </para> </section> <section id="fiber.integration.deeper_dive_into___boost_asio__"> <title><link linkend="fiber.integration.deeper_dive_into___boost_asio__">Deeper Dive into <ulink url="path_to_url">Boost.Asio</ulink></link></title> <para> By now the alert reader is thinking: but surely, with Asio in particular, we ought to be able to do much better than periodic polling pings! </para> <para> This turns out to be surprisingly tricky. We present a possible approach in <ulink url="../../examples/asio/round_robin.hpp"><code><phrase role="identifier">examples</phrase><phrase role="special">/</phrase><phrase role="identifier">asio</phrase><phrase role="special">/</phrase><phrase role="identifier">round_robin</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase></code></ulink>. </para> <para> One consequence of using <ulink url="path_to_url">Boost.Asio</ulink> is that you must always let Asio suspend the running thread. Since Asio is aware of pending I/O requests, it can arrange to suspend the thread in such a way that the OS will wake it on I/O completion. No one else has sufficient knowledge. </para> <para> So the fiber scheduler must depend on Asio for suspension and resumption. It requires Asio handler calls to wake it. </para> <para> One dismaying implication is that we cannot support multiple threads calling <ulink url="path_to_url"><code><phrase role="identifier">io_service</phrase><phrase role="special">::</phrase><phrase role="identifier">run</phrase><phrase role="special">()</phrase></code></ulink> on the same <code><phrase role="identifier">io_service</phrase></code> instance. The reason is that Asio provides no way to constrain a particular handler to be called only on a specified thread. A fiber scheduler instance is locked to a particular thread: that instance cannot manage any other thread&#8217;s fibers. Yet if we allow multiple threads to call <code><phrase role="identifier">io_service</phrase><phrase role="special">::</phrase><phrase role="identifier">run</phrase><phrase role="special">()</phrase></code> on the same <code><phrase role="identifier">io_service</phrase></code> instance, a fiber scheduler which needs to sleep can have no guarantee that it will reawaken in a timely manner. It can set an Asio timer, as described above &mdash; but that timer&#8217;s handler may well execute on a different thread! </para> <para> Another implication is that since an Asio-aware fiber scheduler (not to mention <link linkend="callbacks_asio"><code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">yield</phrase></code></link>) depends on handler calls from the <code><phrase role="identifier">io_service</phrase></code>, it is the application&#8217;s responsibility to ensure that <ulink url="path_to_url"><code><phrase role="identifier">io_service</phrase><phrase role="special">::</phrase><phrase role="identifier">stop</phrase><phrase role="special">()</phrase></code></ulink> is not called until every fiber has terminated. </para> <para> It is easier to reason about the behavior of the presented <code><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">round_robin</phrase></code> scheduler if we require that after initial setup, the thread&#8217;s main fiber is the fiber that calls <code><phrase role="identifier">io_service</phrase><phrase role="special">::</phrase><phrase role="identifier">run</phrase><phrase role="special">()</phrase></code>, so let&#8217;s impose that requirement. </para> <para> Naturally, the first thing we must do on each thread using a custom fiber scheduler is call <link linkend="use_scheduling_algorithm"><code>use_scheduling_algorithm()</code></link>. However, since <code><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">round_robin</phrase></code> requires an <code><phrase role="identifier">io_service</phrase></code> instance, we must first declare that. </para> <para> <programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_ptr</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">io_service</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">io_svc</phrase> <phrase role="special">=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">make_shared</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">io_service</phrase> <phrase role="special">&gt;();</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">round_robin</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">io_svc</phrase><phrase role="special">);</phrase> </programlisting> </para> <para> <code><phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">()</phrase></code> instantiates <code><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">round_robin</phrase></code>, which naturally calls its constructor: </para> <para> <programlisting><phrase role="identifier">round_robin</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_ptr</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">io_service</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">io_svc</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="identifier">io_svc_</phrase><phrase role="special">(</phrase> <phrase role="identifier">io_svc</phrase><phrase role="special">),</phrase> <phrase role="identifier">suspend_timer_</phrase><phrase role="special">(</phrase> <phrase role="special">*</phrase> <phrase role="identifier">io_svc_</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// We use add_service() very deliberately. This will throw</phrase> <phrase role="comment">// service_already_exists if you pass the same io_service instance to</phrase> <phrase role="comment">// more than one round_robin instance.</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">add_service</phrase><phrase role="special">(</phrase> <phrase role="special">*</phrase> <phrase role="identifier">io_svc_</phrase><phrase role="special">,</phrase> <phrase role="keyword">new</phrase> <phrase role="identifier">service</phrase><phrase role="special">(</phrase> <phrase role="special">*</phrase> <phrase role="identifier">io_svc_</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="identifier">io_svc_</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">post</phrase><phrase role="special">([</phrase><phrase role="keyword">this</phrase><phrase role="special">]()</phrase> <phrase role="keyword">mutable</phrase> <phrase role="special">{</phrase> </programlisting> </para> <para> <code><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">round_robin</phrase></code> binds the passed <code><phrase role="identifier">io_service</phrase></code> pointer and initializes a <ulink url="path_to_url"><code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">steady_timer</phrase></code></ulink>: </para> <para> <programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">shared_ptr</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">io_service</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">io_svc_</phrase><phrase role="special">;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">steady_timer</phrase> <phrase role="identifier">suspend_timer_</phrase><phrase role="special">;</phrase> </programlisting> </para> <para> Then it calls <ulink url="path_to_url"><code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">add_service</phrase><phrase role="special">()</phrase></code></ulink> with a nested <code><phrase role="identifier">service</phrase></code> struct: </para> <para> <programlisting><phrase role="keyword">struct</phrase> <phrase role="identifier">service</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">io_service</phrase><phrase role="special">::</phrase><phrase role="identifier">service</phrase> <phrase role="special">{</phrase> <phrase role="keyword">static</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">io_service</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase> <phrase role="identifier">id</phrase><phrase role="special">;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">unique_ptr</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">io_service</phrase><phrase role="special">::</phrase><phrase role="identifier">work</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">work_</phrase><phrase role="special">;</phrase> <phrase role="identifier">service</phrase><phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">io_service</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">io_svc</phrase><phrase role="special">)</phrase> <phrase role="special">:</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">io_service</phrase><phrase role="special">::</phrase><phrase role="identifier">service</phrase><phrase role="special">(</phrase> <phrase role="identifier">io_svc</phrase><phrase role="special">),</phrase> <phrase role="identifier">work_</phrase><phrase role="special">{</phrase> <phrase role="keyword">new</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">io_service</phrase><phrase role="special">::</phrase><phrase role="identifier">work</phrase><phrase role="special">(</phrase> <phrase role="identifier">io_svc</phrase><phrase role="special">)</phrase> <phrase role="special">}</phrase> <phrase role="special">{</phrase> <phrase role="special">}</phrase> <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">service</phrase><phrase role="special">()</phrase> <phrase role="special">{}</phrase> <phrase role="identifier">service</phrase><phrase role="special">(</phrase> <phrase role="identifier">service</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">service</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">service</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">shutdown_service</phrase><phrase role="special">()</phrase> <phrase role="identifier">override</phrase> <phrase role="identifier">final</phrase> <phrase role="special">{</phrase> <phrase role="identifier">work_</phrase><phrase role="special">.</phrase><phrase role="identifier">reset</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="special">};</phrase> </programlisting> </para> <para> ... [asio_rr_service_bottom] </para> <para> The <code><phrase role="identifier">service</phrase></code> struct has a couple of roles. </para> <para> Its foremost role is to manage a <literal>std::unique_ptr&lt;<ulink url="path_to_url"><code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">io_service</phrase><phrase role="special">::</phrase><phrase role="identifier">work</phrase></code></ulink>&gt;</literal>. We want the <code><phrase role="identifier">io_service</phrase></code> instance to continue its main loop even when there is no pending Asio I/O. </para> <para> But when <ulink url="path_to_url"><code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">io_service</phrase><phrase role="special">::</phrase><phrase role="identifier">service</phrase><phrase role="special">::</phrase><phrase role="identifier">shutdown_service</phrase><phrase role="special">()</phrase></code></ulink> is called, we discard the <code><phrase role="identifier">io_service</phrase><phrase role="special">::</phrase><phrase role="identifier">work</phrase></code> instance so the <code><phrase role="identifier">io_service</phrase></code> can shut down properly. </para> <para> Its other purpose is to <ulink url="path_to_url"><code><phrase role="identifier">post</phrase><phrase role="special">()</phrase></code></ulink> a lambda (not yet shown). Let&#8217;s walk further through the example program before coming back to explain that lambda. </para> <para> The <code><phrase role="identifier">service</phrase></code> constructor returns to <code><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">round_robin</phrase></code>&#8217;s constructor, which returns to <code><phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">()</phrase></code>, which returns to the application code. </para> <para> Once it has called <code><phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">()</phrase></code>, the application may now launch some number of fibers: </para> <para> <programlisting><phrase role="comment">// server</phrase> <phrase role="identifier">tcp</phrase><phrase role="special">::</phrase><phrase role="identifier">acceptor</phrase> <phrase role="identifier">a</phrase><phrase role="special">(</phrase> <phrase role="special">*</phrase> <phrase role="identifier">io_svc</phrase><phrase role="special">,</phrase> <phrase role="identifier">tcp</phrase><phrase role="special">::</phrase><phrase role="identifier">endpoint</phrase><phrase role="special">(</phrase> <phrase role="identifier">tcp</phrase><phrase role="special">::</phrase><phrase role="identifier">v4</phrase><phrase role="special">(),</phrase> <phrase role="number">9999</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <phrase role="identifier">server</phrase><phrase role="special">,</phrase> <phrase role="identifier">io_svc</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="identifier">a</phrase><phrase role="special">)</phrase> <phrase role="special">).</phrase><phrase role="identifier">detach</phrase><phrase role="special">();</phrase> <phrase role="comment">// client</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">unsigned</phrase> <phrase role="identifier">iterations</phrase> <phrase role="special">=</phrase> <phrase role="number">2</phrase><phrase role="special">;</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">unsigned</phrase> <phrase role="identifier">clients</phrase> <phrase role="special">=</phrase> <phrase role="number">3</phrase><phrase role="special">;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">barrier</phrase> <phrase role="identifier">b</phrase><phrase role="special">(</phrase> <phrase role="identifier">clients</phrase><phrase role="special">);</phrase> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">unsigned</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">clients</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <phrase role="identifier">client</phrase><phrase role="special">,</phrase> <phrase role="identifier">io_svc</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="identifier">a</phrase><phrase role="special">),</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">ref</phrase><phrase role="special">(</phrase> <phrase role="identifier">b</phrase><phrase role="special">),</phrase> <phrase role="identifier">iterations</phrase><phrase role="special">).</phrase><phrase role="identifier">detach</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> Since we don&#8217;t specify a <link linkend="class_launch"><code>launch</code></link>, these fibers are ready to run, but have not yet been entered. </para> <para> Having set everything up, the application calls <ulink url="path_to_url"><code><phrase role="identifier">io_service</phrase><phrase role="special">::</phrase><phrase role="identifier">run</phrase><phrase role="special">()</phrase></code></ulink>: </para> <para> <programlisting><phrase role="identifier">io_svc</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">run</phrase><phrase role="special">();</phrase> </programlisting> </para> <para> Now what? </para> <para> Because this <code><phrase role="identifier">io_service</phrase></code> instance owns an <code><phrase role="identifier">io_service</phrase><phrase role="special">::</phrase><phrase role="identifier">work</phrase></code> instance, <code><phrase role="identifier">run</phrase><phrase role="special">()</phrase></code> does not immediately return. But &mdash; none of the fibers that will perform actual work has even been entered yet! </para> <para> Without that initial <code><phrase role="identifier">post</phrase><phrase role="special">()</phrase></code> call in <code><phrase role="identifier">service</phrase></code>&#8217;s constructor, <emphasis>nothing</emphasis> would happen. The application would hang right here. </para> <para> So, what should the <code><phrase role="identifier">post</phrase><phrase role="special">()</phrase></code> handler execute? Simply <link linkend="this_fiber_yield"><code>this_fiber::yield()</code></link>? </para> <para> That would be a promising start. But we have no guarantee that any of the other fibers will initiate any Asio operations to keep the ball rolling. For all we know, every other fiber could reach a similar <code><phrase role="identifier">this_fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">yield</phrase><phrase role="special">()</phrase></code> call first. Control would return to the <code><phrase role="identifier">post</phrase><phrase role="special">()</phrase></code> handler, which would return to Asio, and... the application would hang. </para> <para> The <code><phrase role="identifier">post</phrase><phrase role="special">()</phrase></code> handler could <code><phrase role="identifier">post</phrase><phrase role="special">()</phrase></code> itself again. But as discussed in <link linkend="embedded_main_loop">the previous section</link>, once there are actual I/O operations in flight &mdash; once we reach a state in which no fiber is ready &mdash; that would cause the thread to spin. </para> <para> We could, of course, set an Asio timer &mdash; again as <link linkend="embedded_main_loop">previously discussed</link>. But in this <quote>deeper dive,</quote> we&#8217;re trying to do a little better. </para> <para> The key to doing better is that since we&#8217;re in a fiber, we can run an actual loop &mdash; not just a chain of callbacks. We can wait for <quote>something to happen</quote> by calling <ulink url="path_to_url"><code><phrase role="identifier">io_service</phrase><phrase role="special">::</phrase><phrase role="identifier">run_one</phrase><phrase role="special">()</phrase></code></ulink> &mdash; or we can execute already-queued Asio handlers by calling <ulink url="path_to_url"><code><phrase role="identifier">io_service</phrase><phrase role="special">::</phrase><phrase role="identifier">poll</phrase><phrase role="special">()</phrase></code></ulink>. </para> <para> Here&#8217;s the body of the lambda passed to the <code><phrase role="identifier">post</phrase><phrase role="special">()</phrase></code> call. </para> <para> <programlisting> <phrase role="keyword">while</phrase> <phrase role="special">(</phrase> <phrase role="special">!</phrase> <phrase role="identifier">io_svc_</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">stopped</phrase><phrase role="special">()</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">has_ready_fibers</phrase><phrase role="special">()</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// run all pending handlers in round_robin</phrase> <phrase role="keyword">while</phrase> <phrase role="special">(</phrase> <phrase role="identifier">io_svc_</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">poll</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase> <phrase role="comment">// block this fiber till all pending (ready) fibers are processed</phrase> <phrase role="comment">// == round_robin::suspend_until() has been called</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">unique_lock</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">mutex</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">lk</phrase><phrase role="special">(</phrase> <phrase role="identifier">mtx_</phrase><phrase role="special">);</phrase> <phrase role="identifier">cnd_</phrase><phrase role="special">.</phrase><phrase role="identifier">wait</phrase><phrase role="special">(</phrase> <phrase role="identifier">lk</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="keyword">else</phrase> <phrase role="special">{</phrase> <phrase role="comment">// run one handler inside io_service</phrase> <phrase role="comment">// if no handler available, block this thread</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="special">!</phrase> <phrase role="identifier">io_svc_</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">run_one</phrase><phrase role="special">()</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">break</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> We want this loop to exit once the <code><phrase role="identifier">io_service</phrase></code> instance has been <ulink url="path_to_url"><code><phrase role="identifier">stopped</phrase><phrase role="special">()</phrase></code></ulink>. </para> <para> As long as there are ready fibers, we interleave running ready Asio handlers with running ready fibers. </para> <para> If there are no ready fibers, we wait by calling <code><phrase role="identifier">run_one</phrase><phrase role="special">()</phrase></code>. Once any Asio handler has been called &mdash; no matter which &mdash; <code><phrase role="identifier">run_one</phrase><phrase role="special">()</phrase></code> returns. That handler may have transitioned some fiber to ready state, so we loop back to check again. </para> <para> (We won&#8217;t describe <code><phrase role="identifier">awakened</phrase><phrase role="special">()</phrase></code>, <code><phrase role="identifier">pick_next</phrase><phrase role="special">()</phrase></code> or <code><phrase role="identifier">has_ready_fibers</phrase><phrase role="special">()</phrase></code>, as these are just like <link linkend="round_robin_awakened"><code>round_robin::awakened()</code></link>, <link linkend="round_robin_pick_next"><code>round_robin::pick_next()</code></link> and <link linkend="round_robin_has_ready_fibers"><code>round_robin::has_ready_fibers()</code></link>.) </para> <para> That leaves <code><phrase role="identifier">suspend_until</phrase><phrase role="special">()</phrase></code> and <code><phrase role="identifier">notify</phrase><phrase role="special">()</phrase></code>. </para> <para> Doubtless you have been asking yourself: why are we calling <code><phrase role="identifier">io_service</phrase><phrase role="special">::</phrase><phrase role="identifier">run_one</phrase><phrase role="special">()</phrase></code> in the lambda loop? Why not call it in <code><phrase role="identifier">suspend_until</phrase><phrase role="special">()</phrase></code>, whose very API was designed for just such a purpose? </para> <para> Under normal circumstances, when the fiber manager finds no ready fibers, it calls <link linkend="algorithm_suspend_until"><code>algorithm::suspend_until()</code></link>. Why test <code><phrase role="identifier">has_ready_fibers</phrase><phrase role="special">()</phrase></code> in the lambda loop? Why not leverage the normal mechanism? </para> <para> The answer is: it matters who&#8217;s asking. </para> <para> Consider the lambda loop shown above. The only <emphasis role="bold">Boost.Fiber</emphasis> APIs it engages are <code><phrase role="identifier">has_ready_fibers</phrase><phrase role="special">()</phrase></code> and <link linkend="this_fiber_yield"><code>this_fiber::yield()</code></link>. <code><phrase role="identifier">yield</phrase><phrase role="special">()</phrase></code> does not <emphasis>block</emphasis> the calling fiber: the calling fiber does not become unready. It is immediately passed back to <link linkend="algorithm_awakened"><code>algorithm::awakened()</code></link>, to be resumed in its turn when all other ready fibers have had a chance to run. In other words: during a <code><phrase role="identifier">yield</phrase><phrase role="special">()</phrase></code> call, <emphasis>there is always at least one ready fiber.</emphasis> </para> <para> As long as this lambda loop is still running, the fiber manager does not call <code><phrase role="identifier">suspend_until</phrase><phrase role="special">()</phrase></code> because it always has a fiber ready to run. </para> <para> However, the lambda loop <emphasis>itself</emphasis> can detect the case when no <emphasis>other</emphasis> fibers are ready to run: the running fiber is not <emphasis>ready</emphasis> but <emphasis>running.</emphasis> </para> <para> That said, <code><phrase role="identifier">suspend_until</phrase><phrase role="special">()</phrase></code> and <code><phrase role="identifier">notify</phrase><phrase role="special">()</phrase></code> are in fact called during orderly shutdown processing, so let&#8217;s try a plausible implementation. </para> <para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">suspend_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">steady_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">abs_time</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Set a timer so at least one handler will eventually fire, causing</phrase> <phrase role="comment">// run_one() to eventually return.</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">steady_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">::</phrase><phrase role="identifier">max</phrase><phrase role="special">)()</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">abs_time</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Each expires_at(time_point) call cancels any previous pending</phrase> <phrase role="comment">// call. We could inadvertently spin like this:</phrase> <phrase role="comment">// dispatcher calls suspend_until() with earliest wake time</phrase> <phrase role="comment">// suspend_until() sets suspend_timer_</phrase> <phrase role="comment">// lambda loop calls run_one()</phrase> <phrase role="comment">// some other asio handler runs before timer expires</phrase> <phrase role="comment">// run_one() returns to lambda loop</phrase> <phrase role="comment">// lambda loop yields to dispatcher</phrase> <phrase role="comment">// dispatcher finds no ready fibers</phrase> <phrase role="comment">// dispatcher calls suspend_until() with SAME wake time</phrase> <phrase role="comment">// suspend_until() sets suspend_timer_ to same time, canceling</phrase> <phrase role="comment">// previous async_wait()</phrase> <phrase role="comment">// lambda loop calls run_one()</phrase> <phrase role="comment">// asio calls suspend_timer_ handler with operation_aborted</phrase> <phrase role="comment">// run_one() returns to lambda loop... etc. etc.</phrase> <phrase role="comment">// So only actually set the timer when we're passed a DIFFERENT</phrase> <phrase role="comment">// abs_time value.</phrase> <phrase role="identifier">suspend_timer_</phrase><phrase role="special">.</phrase><phrase role="identifier">expires_at</phrase><phrase role="special">(</phrase> <phrase role="identifier">abs_time</phrase><phrase role="special">);</phrase> <phrase role="identifier">suspend_timer_</phrase><phrase role="special">.</phrase><phrase role="identifier">async_wait</phrase><phrase role="special">([](</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">system</phrase><phrase role="special">::</phrase><phrase role="identifier">error_code</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;){</phrase> <phrase role="identifier">this_fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">yield</phrase><phrase role="special">();</phrase> <phrase role="special">});</phrase> <phrase role="special">}</phrase> <phrase role="identifier">cnd_</phrase><phrase role="special">.</phrase><phrase role="identifier">notify_one</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> As you might expect, <code><phrase role="identifier">suspend_until</phrase><phrase role="special">()</phrase></code> sets an <ulink url="path_to_url"><code><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">steady_timer</phrase></code></ulink> to <ulink url="path_to_url"><code><phrase role="identifier">expires_at</phrase><phrase role="special">()</phrase></code></ulink> the passed <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">steady_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase></code></ulink>. Usually. </para> <para> As indicated in comments, we avoid setting <code><phrase role="identifier">suspend_timer_</phrase></code> multiple times to the <emphasis>same</emphasis> <code><phrase role="identifier">time_point</phrase></code> value since every <code><phrase role="identifier">expires_at</phrase><phrase role="special">()</phrase></code> call cancels any previous <ulink url="path_to_url"><code><phrase role="identifier">async_wait</phrase><phrase role="special">()</phrase></code></ulink> call. There is a chance that we could spin. Reaching <code><phrase role="identifier">suspend_until</phrase><phrase role="special">()</phrase></code> means the fiber manager intends to yield the processor to Asio. Cancelling the previous <code><phrase role="identifier">async_wait</phrase><phrase role="special">()</phrase></code> call would fire its handler, causing <code><phrase role="identifier">run_one</phrase><phrase role="special">()</phrase></code> to return, potentially causing the fiber manager to call <code><phrase role="identifier">suspend_until</phrase><phrase role="special">()</phrase></code> again with the same <code><phrase role="identifier">time_point</phrase></code> value... </para> <para> Given that we suspend the thread by calling <code><phrase role="identifier">io_service</phrase><phrase role="special">::</phrase><phrase role="identifier">run_one</phrase><phrase role="special">()</phrase></code>, what&#8217;s important is that our <code><phrase role="identifier">async_wait</phrase><phrase role="special">()</phrase></code> call will cause a handler to run, which will cause <code><phrase role="identifier">run_one</phrase><phrase role="special">()</phrase></code> to return. It&#8217;s not so important specifically what that handler does. </para> <para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">notify</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Something has happened that should wake one or more fibers BEFORE</phrase> <phrase role="comment">// suspend_timer_ expires. Reset the timer to cause it to fire</phrase> <phrase role="comment">// immediately, causing the run_one() call to return. In theory we</phrase> <phrase role="comment">// could use cancel() because we don't care whether suspend_timer_'s</phrase> <phrase role="comment">// handler is called with operation_aborted or success. However --</phrase> <phrase role="comment">// cancel() doesn't change the expiration time, and we use</phrase> <phrase role="comment">// suspend_timer_'s expiration time to decide whether it's already</phrase> <phrase role="comment">// set. If suspend_until() set some specific wake time, then notify()</phrase> <phrase role="comment">// canceled it, then suspend_until() was called again with the same</phrase> <phrase role="comment">// wake time, it would match suspend_timer_'s expiration time and we'd</phrase> <phrase role="comment">// refrain from setting the timer. So instead of simply calling</phrase> <phrase role="comment">// cancel(), reset the timer, which cancels the pending sleep AND sets</phrase> <phrase role="comment">// a new expiration time. This will cause us to spin the loop twice --</phrase> <phrase role="comment">// once for the operation_aborted handler, once for timer expiration</phrase> <phrase role="comment">// -- but that shouldn't be a big problem.</phrase> <phrase role="identifier">suspend_timer_</phrase><phrase role="special">.</phrase><phrase role="identifier">async_wait</phrase><phrase role="special">([](</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">system</phrase><phrase role="special">::</phrase><phrase role="identifier">error_code</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;){</phrase> <phrase role="identifier">this_fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">yield</phrase><phrase role="special">();</phrase> <phrase role="special">});</phrase> <phrase role="identifier">suspend_timer_</phrase><phrase role="special">.</phrase><phrase role="identifier">expires_at</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">steady_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">now</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> Since an <code><phrase role="identifier">expires_at</phrase><phrase role="special">()</phrase></code> call cancels any previous <code><phrase role="identifier">async_wait</phrase><phrase role="special">()</phrase></code> call, we can make <code><phrase role="identifier">notify</phrase><phrase role="special">()</phrase></code> simply call <code><phrase role="identifier">steady_timer</phrase><phrase role="special">::</phrase><phrase role="identifier">expires_at</phrase><phrase role="special">()</phrase></code>. That should cause the <code><phrase role="identifier">io_service</phrase></code> to call the <code><phrase role="identifier">async_wait</phrase><phrase role="special">()</phrase></code> handler with <code><phrase role="identifier">operation_aborted</phrase></code>. </para> <para> The comments in <code><phrase role="identifier">notify</phrase><phrase role="special">()</phrase></code> explain why we call <code><phrase role="identifier">expires_at</phrase><phrase role="special">()</phrase></code> rather than <ulink url="path_to_url"><code><phrase role="identifier">cancel</phrase><phrase role="special">()</phrase></code></ulink>. </para> <para> This <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">round_robin</phrase></code> implementation is used in <ulink url="../../examples/asio/autoecho.cpp"><code><phrase role="identifier">examples</phrase><phrase role="special">/</phrase><phrase role="identifier">asio</phrase><phrase role="special">/</phrase><phrase role="identifier">autoecho</phrase><phrase role="special">.</phrase><phrase role="identifier">cpp</phrase></code></ulink>. </para> <para> It seems possible that you could put together a more elegant Fiber / Asio integration. But as noted at the outset: it&#8217;s tricky. </para> </section> </section> <section id="fiber.speculation"> <title><anchor id="speculation"/><link linkend="fiber.speculation">Specualtive execution</link></title> <bridgehead renderas="sect3" id="fiber.speculation.h0"> <phrase id="fiber.speculation.hardware_transactional_memory"/><link linkend="fiber.speculation.hardware_transactional_memory">Hardware transactional memory</link> </bridgehead> <para> With help of hardware transactional memory multiple logical processors execute a critical region speculatively, e.g. without explicit synchronization.<sbr/> If the transactional execution completes successfully, then all memory operations performed within the transactional region are commited without any inter-thread serialization.<sbr/> When the optimistic execution fails, the processor aborts the transaction and discards all performed modifications.<sbr/> In non-transactional code a single lock serializes the access to a critical region. With a transactional memory, multiple logical processor start a transaction and update the memory (the data) inside the ciritical region. Unless some logical processors try to update the same data, the transactions would always succeed. </para> <bridgehead renderas="sect3" id="fiber.speculation.h1"> <phrase id="fiber.speculation.intel_transactional_synchronisation_extensions__tsx_"/><link linkend="fiber.speculation.intel_transactional_synchronisation_extensions__tsx_">Intel Transactional Synchronisation Extensions (TSX)</link> </bridgehead> <para> TSX is Intel's implementation of hardware transactional memory in modern Intel processors<footnote id="fiber.speculation.f0"> <para> intel.com: <ulink url="path_to_url">Intel Transactional Synchronization Extensions</ulink> </para> </footnote>.<sbr/> In TSX the hardware keeps track of which cachelines have been read from and which have been written to in a transaction. The cache-line size (64-byte) and the n-way set associative cache determine the maximum size of memory in a transaction. For instance if a transaction modifies 9 cache-lines at a processor with a 8-way set associative cache, the transaction will always be aborted. </para> <note> <para> TXS is enabled if property <code><phrase role="identifier">htm</phrase><phrase role="special">=</phrase><phrase role="identifier">tsx</phrase></code> is specified at b2 command-line and <code><phrase role="identifier">BOOST_USE_TSX</phrase></code> is applied to the compiler. </para> </note> <note> <para> A TSX-transaction will be aborted if the floating point state is modified inside a critical region. As a consequence floating point operations, e.g. store/load of floating point related registers during a fiber (context) switch are disabled. </para> </note> <important> <para> TSX can not be used together with MSVC at this time! </para> </important> <para> Boost.Fiber uses TSX-enabled spinlocks to protect critical regions (see section <link linkend="tuning">Tuning</link>). </para> </section> <section id="fiber.numa"> <title><anchor id="numa"/><link linkend="fiber.numa">NUMA</link></title> <para> Modern micro-processors contain integrated memory controllers that are connected via channels to the memory. Accessing the memory can be organized in two kinds:<sbr/> Uniform Memory Access (UMA) and Non-Uniform Memory Access (NUMA). </para> <para> In contrast to UMA, that provides a centralized pool of memory (and thus does not scale after a certain number of processors), a NUMA architecture divides the memory into local and remote memory relative to the micro-processor.<sbr/> Local memory is directly attached to the processor's integrated memory controller. Memory connected to the memory controller of another micro-processor (multi-socket systems) is considered as remote memory. If a memory controller access remote memory it has to traverse the interconnect<footnote id="fiber.numa.f0"> <para> On x86 the interconnection is implemented by Intel's Quick Path Interconnect (QPI) and AMD's HyperTransport. </para> </footnote> and connect to the remote memory controller.<sbr/> Thus accessing remote memory adds additional latency overhead to local memory access. Because of the different memory locations, a NUMA-system experiences <emphasis>non-uniform</emphasis> memory access time.<sbr/> As a consequence the best performance is achieved by keeping the memory access local. </para> <para> <inlinemediaobject><imageobject><imagedata align="center" fileref="../../../../libs/fiber/doc/NUMA.png"></imagedata></imageobject> <textobject> <phrase>NUMA</phrase> </textobject> </inlinemediaobject> </para> <bridgehead renderas="sect3" id="fiber.numa.h0"> <phrase id="fiber.numa.numa_support_in_boost_fiber"/><link linkend="fiber.numa.numa_support_in_boost_fiber">NUMA support in Boost.Fiber</link> </bridgehead> <para> Because only a subset of the NUMA-functionality is exposed by several operating systems, Boost.Fiber provides only a minimalistic NUMA API. </para> <table frame="all" id="fiber.numa.supported_functionality_operating_systems"> <title>Supported functionality/operating systems</title> <tgroup cols="7"> <thead> <row> <entry> </entry> <entry> <para> AIX </para> </entry> <entry> <para> FreeBSD </para> </entry> <entry> <para> HP/UX </para> </entry> <entry> <para> Linux </para> </entry> <entry> <para> Solaris </para> </entry> <entry> <para> Windows </para> </entry> </row> </thead> <tbody> <row> <entry> <para> pin thread </para> </entry> <entry> <para> + </para> </entry> <entry> <para> + </para> </entry> <entry> <para> + </para> </entry> <entry> <para> + </para> </entry> <entry> <para> + </para> </entry> <entry> <para> + </para> </entry> </row> <row> <entry> <para> logical CPUs/NUMA nodes </para> </entry> <entry> <para> + </para> </entry> <entry> <para> + </para> </entry> <entry> <para> + </para> </entry> <entry> <para> + </para> </entry> <entry> <para> + </para> </entry> <entry> <para> +<footnote id="fiber.numa.f1"> <para> Windows organizes logical cpus in groups of 64; boost.fiber maps {group-id,cpud-id} to a scalar equivalent to cpu ID of Linux (64 * group ID + cpu ID). </para> </footnote> </para> </entry> </row> <row> <entry> <para> NUMA node distance </para> </entry> <entry> <para> - </para> </entry> <entry> <para> - </para> </entry> <entry> <para> - </para> </entry> <entry> <para> + </para> </entry> <entry> <para> - </para> </entry> <entry> <para> - </para> </entry> </row> <row> <entry> <para> tested on </para> </entry> <entry> <para> AIX 7.2 </para> </entry> <entry> <para> FreeBSD 11 </para> </entry> <entry> <para> - </para> </entry> <entry> <para> Arch Linux (4.10.13) </para> </entry> <entry> <para> OpenIndiana HIPSTER </para> </entry> <entry> <para> Windows 10 </para> </entry> </row> </tbody> </tgroup> </table> <para> In order to keep the memory access local as possible, the NUMA topology must be evaluated. </para> <programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">numa</phrase><phrase role="special">::</phrase><phrase role="identifier">node</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">topo</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">numa</phrase><phrase role="special">::</phrase><phrase role="identifier">topology</phrase><phrase role="special">();</phrase> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">n</phrase> <phrase role="special">:</phrase> <phrase role="identifier">topo</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;node: &quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">n</phrase><phrase role="special">.</phrase><phrase role="identifier">id</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; | &quot;</phrase><phrase role="special">;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;cpus: &quot;</phrase><phrase role="special">;</phrase> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">cpu_id</phrase> <phrase role="special">:</phrase> <phrase role="identifier">n</phrase><phrase role="special">.</phrase><phrase role="identifier">logical_cpus</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">cpu_id</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; &quot;</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;| distance: &quot;</phrase><phrase role="special">;</phrase> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">d</phrase> <phrase role="special">:</phrase> <phrase role="identifier">n</phrase><phrase role="special">.</phrase><phrase role="identifier">distance</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">d</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot; &quot;</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;done&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="identifier">output</phrase><phrase role="special">:</phrase> <phrase role="identifier">node</phrase><phrase role="special">:</phrase> <phrase role="number">0</phrase> <phrase role="special">|</phrase> <phrase role="identifier">cpus</phrase><phrase role="special">:</phrase> <phrase role="number">0</phrase> <phrase role="number">1</phrase> <phrase role="number">2</phrase> <phrase role="number">3</phrase> <phrase role="number">4</phrase> <phrase role="number">5</phrase> <phrase role="number">6</phrase> <phrase role="number">7</phrase> <phrase role="number">16</phrase> <phrase role="number">17</phrase> <phrase role="number">18</phrase> <phrase role="number">19</phrase> <phrase role="number">20</phrase> <phrase role="number">21</phrase> <phrase role="number">22</phrase> <phrase role="number">23</phrase> <phrase role="special">|</phrase> <phrase role="identifier">distance</phrase><phrase role="special">:</phrase> <phrase role="number">10</phrase> <phrase role="number">21</phrase> <phrase role="identifier">node</phrase><phrase role="special">:</phrase> <phrase role="number">1</phrase> <phrase role="special">|</phrase> <phrase role="identifier">cpus</phrase><phrase role="special">:</phrase> <phrase role="number">8</phrase> <phrase role="number">9</phrase> <phrase role="number">10</phrase> <phrase role="number">11</phrase> <phrase role="number">12</phrase> <phrase role="number">13</phrase> <phrase role="number">14</phrase> <phrase role="number">15</phrase> <phrase role="number">24</phrase> <phrase role="number">25</phrase> <phrase role="number">26</phrase> <phrase role="number">27</phrase> <phrase role="number">28</phrase> <phrase role="number">29</phrase> <phrase role="number">30</phrase> <phrase role="number">31</phrase> <phrase role="special">|</phrase> <phrase role="identifier">distance</phrase><phrase role="special">:</phrase> <phrase role="number">21</phrase> <phrase role="number">10</phrase> <phrase role="identifier">done</phrase> </programlisting> <para> The example shows that the systems consits out of 2 NUMA-nodes, to each NUMA-node belong 16 logical cpus. The distance measures the costs to access the memory of another NUMA-node. A NUMA-node has always a distance <code><phrase role="number">10</phrase></code> to itself (lowest possible value).<sbr/> The position in the array corresponds with the NUMA-node ID. </para> <para> Some work-loads benefit from pinning threads to a logical cpus. For instance scheduling algorithm <link linkend="class_numa_work_stealing"><code>numa::work_stealing</code></link> pins the thread that runs the fiber scheduler to a logical cpu. This prevents the operating system scheduler to move the thread to another logical cpu that might run other fiber scheduler(s) or migrating the thread to a logical cpu part of another NUMA-node. </para> <programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">thread</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase> <phrase role="identifier">cpu_id</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase> <phrase role="identifier">node_id</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">numa</phrase><phrase role="special">::</phrase><phrase role="identifier">node</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">topo</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// thread registers itself at work-stealing scheduler</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">algo</phrase><phrase role="special">::</phrase><phrase role="identifier">numa</phrase><phrase role="special">::</phrase><phrase role="identifier">work_stealing</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">cpu_id</phrase><phrase role="special">,</phrase> <phrase role="identifier">node_id</phrase><phrase role="special">,</phrase> <phrase role="identifier">topo</phrase><phrase role="special">);</phrase> <phrase role="special">...</phrase> <phrase role="special">}</phrase> <phrase role="comment">// evaluate the NUMA topology</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">numa</phrase><phrase role="special">::</phrase><phrase role="identifier">node</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">topo</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">numa</phrase><phrase role="special">::</phrase><phrase role="identifier">topology</phrase><phrase role="special">();</phrase> <phrase role="comment">// start-thread runs on NUMA-node `0`</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">node</phrase> <phrase role="special">=</phrase> <phrase role="identifier">topo</phrase><phrase role="special">[</phrase><phrase role="number">0</phrase><phrase role="special">];</phrase> <phrase role="comment">// start-thread is pinnded to first cpu ID in the list of logical cpus of NUMA-node `0`</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">start_cpu_id</phrase> <phrase role="special">=</phrase> <phrase role="special">*</phrase> <phrase role="identifier">node</phrase><phrase role="special">.</phrase><phrase role="identifier">logical_cpus</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">();</phrase> <phrase role="comment">// start-thread registers itself on work-stealing scheduler</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">algo</phrase><phrase role="special">::</phrase><phrase role="identifier">numa</phrase><phrase role="special">::</phrase><phrase role="identifier">work_stealing</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">start_cpu_id</phrase><phrase role="special">,</phrase> <phrase role="identifier">node</phrase><phrase role="special">.</phrase><phrase role="identifier">id</phrase><phrase role="special">,</phrase> <phrase role="identifier">topo</phrase><phrase role="special">);</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">thread</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">threads</phrase><phrase role="special">;</phrase> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">auto</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">node</phrase> <phrase role="special">:</phrase> <phrase role="identifier">topo</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase> <phrase role="identifier">cpu_id</phrase> <phrase role="special">:</phrase> <phrase role="identifier">node</phrase><phrase role="special">.</phrase><phrase role="identifier">logical_cpus</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// exclude start-thread</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">start_cpu_id</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">cpu_id</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="comment">// spawn thread</phrase> <phrase role="identifier">threads</phrase><phrase role="special">.</phrase><phrase role="identifier">emplace_back</phrase><phrase role="special">(</phrase> <phrase role="identifier">thread</phrase><phrase role="special">,</phrase> <phrase role="identifier">cpu_id</phrase><phrase role="special">,</phrase> <phrase role="identifier">node</phrase><phrase role="special">.</phrase><phrase role="identifier">id</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cref</phrase><phrase role="special">(</phrase> <phrase role="identifier">topo</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> <phrase role="special">...</phrase> </programlisting> <para> The example evaluates the NUMA topology with <code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">numa</phrase><phrase role="special">::</phrase><phrase role="identifier">topology</phrase><phrase role="special">()</phrase></code> and spawns for each logical cpu a thread. Each spawned thread installs the NUMA-aware work-stealing scheduler. The scheduler pins the thread to the logical cpu that was specified at construction.<sbr/> If the local queue of one thread runs out of ready fibers, the thread tries to steal a ready fiber from another thread running at logical cpu that belong to the same NUMA-node (local memory access). If no fiber could be stolen, the thread tries to steal fibers from logical cpus part of other NUMA-nodes (remote memory access). </para> <bridgehead renderas="sect3" id="fiber.numa.h1"> <phrase id="fiber.numa.synopsis"/><link linkend="fiber.numa.synopsis">Synopsis</link> </bridgehead> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">numa</phrase><phrase role="special">/</phrase><phrase role="identifier">pin_thread</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">numa</phrase><phrase role="special">/</phrase><phrase role="identifier">topology</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">numa</phrase> <phrase role="special">{</phrase> <phrase role="keyword">struct</phrase> <phrase role="identifier">node</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase> <phrase role="identifier">id</phrase><phrase role="special">;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">set</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">logical_cpus</phrase><phrase role="special">;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">distance</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> <phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">&lt;(</phrase> <phrase role="identifier">node</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;,</phrase> <phrase role="identifier">node</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">node</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">topology</phrase><phrase role="special">();</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">pin_thread</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase><phrase role="special">);</phrase> <phrase role="special">}}}</phrase> <phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">algo</phrase><phrase role="special">/</phrase><phrase role="identifier">numa</phrase><phrase role="special">/</phrase><phrase role="identifier">work_stealing</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">algo</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">numa</phrase> <phrase role="special">{</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">work_stealing</phrase><phrase role="special">;</phrase> <phrase role="special">}}}</phrase> </programlisting> <para> <bridgehead renderas="sect4" id="class_numa_node_bridgehead"> <phrase id="class_numa_node"/> <link linkend="class_numa_node">Class <code>numa::node</code></link> </bridgehead> </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">numa</phrase><phrase role="special">/</phrase><phrase role="identifier">topology</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">numa</phrase> <phrase role="special">{</phrase> <phrase role="keyword">struct</phrase> <phrase role="identifier">node</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase> <phrase role="identifier">id</phrase><phrase role="special">;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">set</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">logical_cpus</phrase><phrase role="special">;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">distance</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> <phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">&lt;(</phrase> <phrase role="identifier">node</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;,</phrase> <phrase role="identifier">node</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="special">}}}</phrase> </programlisting> <para> <bridgehead renderas="sect4" id="numa_node_id_bridgehead"> <phrase id="numa_node_id"/> <link linkend="numa_node_id">Data member <code>id</code></link> </bridgehead> </para> <programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase> <phrase role="identifier">id</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> ID of the NUMA-node </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="numa_node_logical_cpus_bridgehead"> <phrase id="numa_node_logical_cpus"/> <link linkend="numa_node_logical_cpus">Data member <code>logical_cpus</code></link> </bridgehead> </para> <programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">set</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">logical_cpus</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> set of logical cpu IDs belonging to the NUMA-node </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="numa_node_distance_bridgehead"> <phrase id="numa_node_distance"/> <link linkend="numa_node_distance">Data member <code>distance</code></link> </bridgehead> </para> <programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">distance</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> The distance between NUMA-nodes describe the cots of accessing the remote memory. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> A NUMA-node has a distance of <code><phrase role="number">10</phrase></code> to itself, remote NUMA-nodes have a distance &gt; <code><phrase role="number">10</phrase></code>. The index in the array corresponds to the ID <code><phrase role="identifier">id</phrase></code> of the NUMA-node. At the moment only Linux returns the correct distances, for all other operating systems remote NUMA-nodes get a default value of <code><phrase role="number">20</phrase></code>. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="numa_node_operator_less_bridgehead"> <phrase id="numa_node_operator_less"/> <link linkend="numa_node_operator_less">Member function <code>operator&lt;</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">bool</phrase> <phrase role="keyword">operator</phrase><phrase role="special">&lt;(</phrase> <phrase role="identifier">node</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">lhs</phrase><phrase role="special">,</phrase> <phrase role="identifier">node</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">rhs</phrase><phrase role="special">)</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if <code><phrase role="identifier">lhs</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">rhs</phrase></code> is true and the implementation-defined total order of <code><phrase role="identifier">node</phrase><phrase role="special">::</phrase><phrase role="identifier">id</phrase></code> values places <code><phrase role="identifier">lhs</phrase></code> before <code><phrase role="identifier">rhs</phrase></code>, false otherwise. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="numa_topology_bridgehead"> <phrase id="numa_topology"/> <link linkend="numa_topology">Non-member function <code>numa::topology()</code></link> </bridgehead> </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">numa</phrase><phrase role="special">/</phrase><phrase role="identifier">topology</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">numa</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">node</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">topology</phrase><phrase role="special">();</phrase> <phrase role="special">}}}</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Evaluates the NUMA topology. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> a vector of NUMA-nodes describing the NUMA architecture of the system (each element represents a NUMA-node). </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">system_error</phrase></code> </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="numa_pin_thread_bridgehead"> <phrase id="numa_pin_thread"/> <link linkend="numa_pin_thread">Non-member function <code>numa::pin_thread()</code></link> </bridgehead> </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">numa</phrase><phrase role="special">/</phrase><phrase role="identifier">pin_thread</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">numa</phrase> <phrase role="special">{</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">pin_thread</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase><phrase role="special">);</phrase> <phrase role="special">}}}</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Pins <code><phrase role="keyword">this</phrase> <phrase role="identifier">thread</phrase></code> to the logical cpu with ID <code><phrase role="identifier">cpu_id</phrase></code>, e.g. the operating system scheduler will not migrate the thread to another logical cpu. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">system_error</phrase></code> </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="class_numa_work_stealing_bridgehead"> <phrase id="class_numa_work_stealing"/> <link linkend="class_numa_work_stealing">Class <code>numa::work_stealing</code></link> </bridgehead> </para> <para> This class implements <link linkend="class_algorithm"><code>algorithm</code></link>; the thread running this scheduler is pinned to the given logical cpu. If the local ready-queue runs out of ready fibers, ready fibers are stolen from other schedulers that run on logical cpus that belong to the same NUMA-node (local memory access).<sbr/> If no ready fibers can be stolen from the local NUMA-node, the algorithm selects schedulers running on other NUMA-nodes (remote memory access).<sbr/> The victim scheduler (from which a ready fiber is stolen) is selected at random. </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">algo</phrase><phrase role="special">/</phrase><phrase role="identifier">numa</phrase><phrase role="special">/</phrase><phrase role="identifier">work_stealing</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">algo</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">numa</phrase> <phrase role="special">{</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">work_stealing</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">algorithm</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="identifier">work_stealing</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase> <phrase role="identifier">cpu_id</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase> <phrase role="identifier">node_id</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">numa</phrase><phrase role="special">::</phrase><phrase role="identifier">node</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">topo</phrase><phrase role="special">,</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">suspend</phrase> <phrase role="special">=</phrase> <phrase role="keyword">false</phrase><phrase role="special">);</phrase> <phrase role="identifier">work_stealing</phrase><phrase role="special">(</phrase> <phrase role="identifier">work_stealing</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">work_stealing</phrase><phrase role="special">(</phrase> <phrase role="identifier">work_stealing</phrase> <phrase role="special">&amp;&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">work_stealing</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">work_stealing</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="identifier">work_stealing</phrase> <phrase role="special">&amp;</phrase> <phrase role="keyword">operator</phrase><phrase role="special">=(</phrase> <phrase role="identifier">work_stealing</phrase> <phrase role="special">&amp;&amp;)</phrase> <phrase role="special">=</phrase> <phrase role="keyword">delete</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">awakened</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">pick_next</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">has_ready_fibers</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">suspend_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">steady_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">notify</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> <phrase role="special">}}}}</phrase> </programlisting> <bridgehead renderas="sect3" id="fiber.numa.h2"> <phrase id="fiber.numa.constructor"/><link linkend="fiber.numa.constructor">Constructor</link> </bridgehead> <programlisting><phrase role="identifier">work_stealing</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase> <phrase role="identifier">cpu_id</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uint32_t</phrase> <phrase role="identifier">node_id</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">numa</phrase><phrase role="special">::</phrase><phrase role="identifier">node</phrase> <phrase role="special">&gt;</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">topo</phrase><phrase role="special">,</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">suspend</phrase> <phrase role="special">=</phrase> <phrase role="keyword">false</phrase><phrase role="special">);</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Constructs work-stealing scheduling algorithm. The thread is pinned to logical cpu with ID <code><phrase role="identifier">cpu_id</phrase></code>. If local ready-queue runs out of ready fibers, ready fibers are stolen from other schedulers using <code><phrase role="identifier">topology</phrase></code> (represents the NUMA-topology of the system). </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> <code><phrase role="identifier">system_error</phrase></code> </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> If <code><phrase role="identifier">suspend</phrase></code> is set to <code><phrase role="keyword">true</phrase></code>, then the scheduler suspends if no ready fiber could be stolen. The scheduler will by woken up if a sleeping fiber times out or it was notified from remote (other thread or fiber scheduler). </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="numa_work_stealing_awakened_bridgehead"> <phrase id="numa_work_stealing_awakened"/> <link linkend="numa_work_stealing_awakened">Member function <code>awakened</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">awakened</phrase><phrase role="special">(</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">f</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Enqueues fiber <code><phrase role="identifier">f</phrase></code> onto the shared ready queue. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="numa_work_stealing_pick_next_bridgehead"> <phrase id="numa_work_stealing_pick_next"/> <link linkend="numa_work_stealing_pick_next">Member function <code>pick_next</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">pick_next</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> the fiber at the head of the ready queue, or <code><phrase role="keyword">nullptr</phrase></code> if the queue is empty. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> <varlistentry> <term>Note:</term> <listitem> <para> Placing ready fibers onto the tail of the sahred queue, and returning them from the head of that queue, shares the thread between ready fibers in round-robin fashion. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="numa_work_stealing_has_ready_fibers_bridgehead"> <phrase id="numa_work_stealing_has_ready_fibers"/> <link linkend="numa_work_stealing_has_ready_fibers">Member function <code>has_ready_fibers</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">has_ready_fibers</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Returns:</term> <listitem> <para> <code><phrase role="keyword">true</phrase></code> if scheduler has fibers ready to run. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="numa_work_stealing_suspend_until_bridgehead"> <phrase id="numa_work_stealing_suspend_until"/> <link linkend="numa_work_stealing_suspend_until">Member function <code>suspend_until</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">suspend_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">steady_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">abs_time</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Informs <code><phrase role="identifier">work_stealing</phrase></code> that no ready fiber will be available until time-point <code><phrase role="identifier">abs_time</phrase></code>. This implementation blocks in <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_variable</phrase><phrase role="special">::</phrase><phrase role="identifier">wait_until</phrase><phrase role="special">()</phrase></code></ulink>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> <para> <bridgehead renderas="sect4" id="numa_work_stealing_notify_bridgehead"> <phrase id="numa_work_stealing_notify"/> <link linkend="numa_work_stealing_notify">Member function <code>notify</code>()</link> </bridgehead> </para> <programlisting><phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">notify</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Wake up a pending call to <link linkend="work_stealing_suspend_until"><code>work_stealing::suspend_until()</code></link>, some fibers might be ready. This implementation wakes <code><phrase role="identifier">suspend_until</phrase><phrase role="special">()</phrase></code> via <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_variable</phrase><phrase role="special">::</phrase><phrase role="identifier">notify_all</phrase><phrase role="special">()</phrase></code></ulink>. </para> </listitem> </varlistentry> <varlistentry> <term>Throws:</term> <listitem> <para> Nothing. </para> </listitem> </varlistentry> </variablelist> </section> <section id="fiber.gpu_computing"> <title><link linkend="fiber.gpu_computing">GPU computing</link></title> <section id="fiber.gpu_computing.cuda"> <title><anchor id="cuda"/><link linkend="fiber.gpu_computing.cuda">CUDA</link></title> <para> <ulink url="path_to_url">CUDA (Compute Unified Device Architecture)</ulink> is a platform for parallel computing on NVIDIA GPUs. The application programming interface of CUDA gives access to GPU's instruction set and computation resources (Execution of compute kernels). </para> <bridgehead renderas="sect4" id="fiber.gpu_computing.cuda.h0"> <phrase id="fiber.gpu_computing.cuda.waiting_for_cuda_streams"/><link linkend="fiber.gpu_computing.cuda.waiting_for_cuda_streams">Waiting for CUDA streams</link> </bridgehead> <para> CUDA operation such as compute kernels or memory transfer (between host and device) can be grouped/queued by CUDA streams. are executed on the GPUs. Boost.Fiber enables a fiber to sleep (suspend) till a CUDA stream has completed its operations. This enables applications to run other fibers on the CPU without the need to spawn an additional OS-threads. And resume the fiber when the CUDA streams has finished. </para> <programlisting><phrase role="identifier">__global__</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">kernel</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">size</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase> <phrase role="special">*</phrase> <phrase role="identifier">a</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase> <phrase role="special">*</phrase> <phrase role="identifier">b</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase> <phrase role="special">*</phrase> <phrase role="identifier">c</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">idx</phrase> <phrase role="special">=</phrase> <phrase role="identifier">threadIdx</phrase><phrase role="special">.</phrase><phrase role="identifier">x</phrase> <phrase role="special">+</phrase> <phrase role="identifier">blockIdx</phrase><phrase role="special">.</phrase><phrase role="identifier">x</phrase> <phrase role="special">*</phrase> <phrase role="identifier">blockDim</phrase><phrase role="special">.</phrase><phrase role="identifier">x</phrase><phrase role="special">;</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">idx</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">size</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">idx1</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">idx</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase> <phrase role="special">%</phrase> <phrase role="number">256</phrase><phrase role="special">;</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">idx2</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">idx</phrase> <phrase role="special">+</phrase> <phrase role="number">2</phrase><phrase role="special">)</phrase> <phrase role="special">%</phrase> <phrase role="number">256</phrase><phrase role="special">;</phrase> <phrase role="keyword">float</phrase> <phrase role="identifier">as</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">a</phrase><phrase role="special">[</phrase><phrase role="identifier">idx</phrase><phrase role="special">]</phrase> <phrase role="special">+</phrase> <phrase role="identifier">a</phrase><phrase role="special">[</phrase><phrase role="identifier">idx1</phrase><phrase role="special">]</phrase> <phrase role="special">+</phrase> <phrase role="identifier">a</phrase><phrase role="special">[</phrase><phrase role="identifier">idx2</phrase><phrase role="special">])</phrase> <phrase role="special">/</phrase> <phrase role="number">3.0f</phrase><phrase role="special">;</phrase> <phrase role="keyword">float</phrase> <phrase role="identifier">bs</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">b</phrase><phrase role="special">[</phrase><phrase role="identifier">idx</phrase><phrase role="special">]</phrase> <phrase role="special">+</phrase> <phrase role="identifier">b</phrase><phrase role="special">[</phrase><phrase role="identifier">idx1</phrase><phrase role="special">]</phrase> <phrase role="special">+</phrase> <phrase role="identifier">b</phrase><phrase role="special">[</phrase><phrase role="identifier">idx2</phrase><phrase role="special">])</phrase> <phrase role="special">/</phrase> <phrase role="number">3.0f</phrase><phrase role="special">;</phrase> <phrase role="identifier">c</phrase><phrase role="special">[</phrase><phrase role="identifier">idx</phrase><phrase role="special">]</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">as</phrase> <phrase role="special">+</phrase> <phrase role="identifier">bs</phrase><phrase role="special">)</phrase> <phrase role="special">/</phrase> <phrase role="number">2</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase> <phrase role="identifier">f</phrase><phrase role="special">([&amp;</phrase><phrase role="identifier">done</phrase><phrase role="special">]{</phrase> <phrase role="identifier">cudaStream_t</phrase> <phrase role="identifier">stream</phrase><phrase role="special">;</phrase> <phrase role="identifier">cudaStreamCreate</phrase><phrase role="special">(</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">stream</phrase><phrase role="special">);</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">size</phrase> <phrase role="special">=</phrase> <phrase role="number">1024</phrase> <phrase role="special">*</phrase> <phrase role="number">1024</phrase><phrase role="special">;</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">full_size</phrase> <phrase role="special">=</phrase> <phrase role="number">20</phrase> <phrase role="special">*</phrase> <phrase role="identifier">size</phrase><phrase role="special">;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">*</phrase> <phrase role="identifier">host_a</phrase><phrase role="special">,</phrase> <phrase role="special">*</phrase> <phrase role="identifier">host_b</phrase><phrase role="special">,</phrase> <phrase role="special">*</phrase> <phrase role="identifier">host_c</phrase><phrase role="special">;</phrase> <phrase role="identifier">cudaHostAlloc</phrase><phrase role="special">(</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">host_a</phrase><phrase role="special">,</phrase> <phrase role="identifier">full_size</phrase> <phrase role="special">*</phrase> <phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase><phrase role="special">),</phrase> <phrase role="identifier">cudaHostAllocDefault</phrase><phrase role="special">);</phrase> <phrase role="identifier">cudaHostAlloc</phrase><phrase role="special">(</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">host_b</phrase><phrase role="special">,</phrase> <phrase role="identifier">full_size</phrase> <phrase role="special">*</phrase> <phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase><phrase role="special">),</phrase> <phrase role="identifier">cudaHostAllocDefault</phrase><phrase role="special">);</phrase> <phrase role="identifier">cudaHostAlloc</phrase><phrase role="special">(</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">host_c</phrase><phrase role="special">,</phrase> <phrase role="identifier">full_size</phrase> <phrase role="special">*</phrase> <phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase><phrase role="special">),</phrase> <phrase role="identifier">cudaHostAllocDefault</phrase><phrase role="special">);</phrase> <phrase role="keyword">int</phrase> <phrase role="special">*</phrase> <phrase role="identifier">dev_a</phrase><phrase role="special">,</phrase> <phrase role="special">*</phrase> <phrase role="identifier">dev_b</phrase><phrase role="special">,</phrase> <phrase role="special">*</phrase> <phrase role="identifier">dev_c</phrase><phrase role="special">;</phrase> <phrase role="identifier">cudaMalloc</phrase><phrase role="special">(</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">dev_a</phrase><phrase role="special">,</phrase> <phrase role="identifier">size</phrase> <phrase role="special">*</phrase> <phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="identifier">cudaMalloc</phrase><phrase role="special">(</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">dev_b</phrase><phrase role="special">,</phrase> <phrase role="identifier">size</phrase> <phrase role="special">*</phrase> <phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="identifier">cudaMalloc</phrase><phrase role="special">(</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">dev_c</phrase><phrase role="special">,</phrase> <phrase role="identifier">size</phrase> <phrase role="special">*</phrase> <phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">minstd_rand</phrase> <phrase role="identifier">generator</phrase><phrase role="special">;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int_distribution</phrase><phrase role="special">&lt;&gt;</phrase> <phrase role="identifier">distribution</phrase><phrase role="special">(</phrase><phrase role="number">1</phrase><phrase role="special">,</phrase> <phrase role="number">6</phrase><phrase role="special">);</phrase> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">full_size</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">host_a</phrase><phrase role="special">[</phrase><phrase role="identifier">i</phrase><phrase role="special">]</phrase> <phrase role="special">=</phrase> <phrase role="identifier">distribution</phrase><phrase role="special">(</phrase> <phrase role="identifier">generator</phrase><phrase role="special">);</phrase> <phrase role="identifier">host_b</phrase><phrase role="special">[</phrase><phrase role="identifier">i</phrase><phrase role="special">]</phrase> <phrase role="special">=</phrase> <phrase role="identifier">distribution</phrase><phrase role="special">(</phrase> <phrase role="identifier">generator</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">full_size</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">+=</phrase> <phrase role="identifier">size</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">cudaMemcpyAsync</phrase><phrase role="special">(</phrase> <phrase role="identifier">dev_a</phrase><phrase role="special">,</phrase> <phrase role="identifier">host_a</phrase> <phrase role="special">+</phrase> <phrase role="identifier">i</phrase><phrase role="special">,</phrase> <phrase role="identifier">size</phrase> <phrase role="special">*</phrase> <phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase><phrase role="special">),</phrase> <phrase role="identifier">cudaMemcpyHostToDevice</phrase><phrase role="special">,</phrase> <phrase role="identifier">stream</phrase><phrase role="special">);</phrase> <phrase role="identifier">cudaMemcpyAsync</phrase><phrase role="special">(</phrase> <phrase role="identifier">dev_b</phrase><phrase role="special">,</phrase> <phrase role="identifier">host_b</phrase> <phrase role="special">+</phrase> <phrase role="identifier">i</phrase><phrase role="special">,</phrase> <phrase role="identifier">size</phrase> <phrase role="special">*</phrase> <phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase><phrase role="special">),</phrase> <phrase role="identifier">cudaMemcpyHostToDevice</phrase><phrase role="special">,</phrase> <phrase role="identifier">stream</phrase><phrase role="special">);</phrase> <phrase role="identifier">kernel</phrase><phrase role="special">&lt;&lt;&lt;</phrase> <phrase role="identifier">size</phrase> <phrase role="special">/</phrase> <phrase role="number">256</phrase><phrase role="special">,</phrase> <phrase role="number">256</phrase><phrase role="special">,</phrase> <phrase role="number">0</phrase><phrase role="special">,</phrase> <phrase role="identifier">stream</phrase> <phrase role="special">&gt;&gt;&gt;(</phrase> <phrase role="identifier">size</phrase><phrase role="special">,</phrase> <phrase role="identifier">dev_a</phrase><phrase role="special">,</phrase> <phrase role="identifier">dev_b</phrase><phrase role="special">,</phrase> <phrase role="identifier">dev_c</phrase><phrase role="special">);</phrase> <phrase role="identifier">cudaMemcpyAsync</phrase><phrase role="special">(</phrase> <phrase role="identifier">host_c</phrase> <phrase role="special">+</phrase> <phrase role="identifier">i</phrase><phrase role="special">,</phrase> <phrase role="identifier">dev_c</phrase><phrase role="special">,</phrase> <phrase role="identifier">size</phrase> <phrase role="special">*</phrase> <phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase><phrase role="special">),</phrase> <phrase role="identifier">cudaMemcpyDeviceToHost</phrase><phrase role="special">,</phrase> <phrase role="identifier">stream</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">cuda</phrase><phrase role="special">::</phrase><phrase role="identifier">waitfor_all</phrase><phrase role="special">(</phrase> <phrase role="identifier">stream</phrase><phrase role="special">);</phrase> <phrase role="comment">// suspend fiber till CUDA stream has finished</phrase> <phrase role="identifier">BOOST_ASSERT</phrase><phrase role="special">(</phrase> <phrase role="identifier">stream</phrase> <phrase role="special">==</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">get</phrase><phrase role="special">&lt;</phrase> <phrase role="number">0</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="identifier">BOOST_ASSERT</phrase><phrase role="special">(</phrase> <phrase role="identifier">cudaSuccess</phrase> <phrase role="special">==</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">get</phrase><phrase role="special">&lt;</phrase> <phrase role="number">1</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;f1: GPU computation finished&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="identifier">cudaFreeHost</phrase><phrase role="special">(</phrase> <phrase role="identifier">host_a</phrase><phrase role="special">);</phrase> <phrase role="identifier">cudaFreeHost</phrase><phrase role="special">(</phrase> <phrase role="identifier">host_b</phrase><phrase role="special">);</phrase> <phrase role="identifier">cudaFreeHost</phrase><phrase role="special">(</phrase> <phrase role="identifier">host_c</phrase><phrase role="special">);</phrase> <phrase role="identifier">cudaFree</phrase><phrase role="special">(</phrase> <phrase role="identifier">dev_a</phrase><phrase role="special">);</phrase> <phrase role="identifier">cudaFree</phrase><phrase role="special">(</phrase> <phrase role="identifier">dev_b</phrase><phrase role="special">);</phrase> <phrase role="identifier">cudaFree</phrase><phrase role="special">(</phrase> <phrase role="identifier">dev_c</phrase><phrase role="special">);</phrase> <phrase role="identifier">cudaStreamDestroy</phrase><phrase role="special">(</phrase> <phrase role="identifier">stream</phrase><phrase role="special">);</phrase> <phrase role="special">});</phrase> <phrase role="identifier">f</phrase><phrase role="special">.</phrase><phrase role="identifier">join</phrase><phrase role="special">();</phrase> </programlisting> <bridgehead renderas="sect4" id="fiber.gpu_computing.cuda.h1"> <phrase id="fiber.gpu_computing.cuda.synopsis"/><link linkend="fiber.gpu_computing.cuda.synopsis">Synopsis</link> </bridgehead> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">cuda</phrase><phrase role="special">/</phrase><phrase role="identifier">waitfor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">cuda</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">tuple</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">cudaStream_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">cudaError_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">waitfor_all</phrase><phrase role="special">(</phrase> <phrase role="identifier">cudaStream_t</phrase> <phrase role="identifier">st</phrase><phrase role="special">);</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">tuple</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">cudaStream_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">cudaError_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">waitfor_all</phrase><phrase role="special">(</phrase> <phrase role="identifier">cudaStream_t</phrase> <phrase role="special">...</phrase> <phrase role="identifier">st</phrase><phrase role="special">);</phrase> <phrase role="special">}}}</phrase> </programlisting> <para> <bridgehead renderas="sect4" id="cuda_waitfor_bridgehead"> <phrase id="cuda_waitfor"/> <link linkend="cuda_waitfor">Non-member function <code>cuda::waitfor()</code></link> </bridgehead> </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">cuda</phrase><phrase role="special">/</phrase><phrase role="identifier">waitfor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">cuda</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">tuple</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">cudaStream_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">cudaError_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">waitfor_all</phrase><phrase role="special">(</phrase> <phrase role="identifier">cudaStream_t</phrase> <phrase role="identifier">st</phrase><phrase role="special">);</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">tuple</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">cudaStream_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">cudaError_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">waitfor_all</phrase><phrase role="special">(</phrase> <phrase role="identifier">cudaStream_t</phrase> <phrase role="special">...</phrase> <phrase role="identifier">st</phrase><phrase role="special">);</phrase> <phrase role="special">}}}</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Suspends active fiber till CUDA stream has finished its operations. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> tuple of stream reference and the CUDA stream status </para> </listitem> </varlistentry> </variablelist> </section> <section id="fiber.gpu_computing.hip"> <title><anchor id="hip"/><link linkend="fiber.gpu_computing.hip">HIP</link></title> <para> <ulink url="path_to_url">HIP</ulink> is part of the <ulink url="path_to_url">ROC (Radeon Open Compute)</ulink> platform for parallel computing on AMD and NVIDIA GPUs. The application programming interface of HIP gives access to GPU's instruction set and computation resources (Execution of compute kernels). </para> <bridgehead renderas="sect4" id="fiber.gpu_computing.hip.h0"> <phrase id="fiber.gpu_computing.hip.waiting_for_hip_streams"/><link linkend="fiber.gpu_computing.hip.waiting_for_hip_streams">Waiting for HIP streams</link> </bridgehead> <para> HIP operation such as compute kernels or memory transfer (between host and device) can be grouped/queued by HIP streams. are executed on the GPUs. Boost.Fiber enables a fiber to sleep (suspend) till a HIP stream has completed its operations. This enables applications to run other fibers on the CPU without the need to spawn an additional OS-threads. And resume the fiber when the HIP streams has finished. </para> <programlisting><phrase role="identifier">__global__</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">kernel</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">size</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase> <phrase role="special">*</phrase> <phrase role="identifier">a</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase> <phrase role="special">*</phrase> <phrase role="identifier">b</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase> <phrase role="special">*</phrase> <phrase role="identifier">c</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">idx</phrase> <phrase role="special">=</phrase> <phrase role="identifier">threadIdx</phrase><phrase role="special">.</phrase><phrase role="identifier">x</phrase> <phrase role="special">+</phrase> <phrase role="identifier">blockIdx</phrase><phrase role="special">.</phrase><phrase role="identifier">x</phrase> <phrase role="special">*</phrase> <phrase role="identifier">blockDim</phrase><phrase role="special">.</phrase><phrase role="identifier">x</phrase><phrase role="special">;</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">idx</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">size</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">idx1</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">idx</phrase> <phrase role="special">+</phrase> <phrase role="number">1</phrase><phrase role="special">)</phrase> <phrase role="special">%</phrase> <phrase role="number">256</phrase><phrase role="special">;</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">idx2</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">idx</phrase> <phrase role="special">+</phrase> <phrase role="number">2</phrase><phrase role="special">)</phrase> <phrase role="special">%</phrase> <phrase role="number">256</phrase><phrase role="special">;</phrase> <phrase role="keyword">float</phrase> <phrase role="identifier">as</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">a</phrase><phrase role="special">[</phrase><phrase role="identifier">idx</phrase><phrase role="special">]</phrase> <phrase role="special">+</phrase> <phrase role="identifier">a</phrase><phrase role="special">[</phrase><phrase role="identifier">idx1</phrase><phrase role="special">]</phrase> <phrase role="special">+</phrase> <phrase role="identifier">a</phrase><phrase role="special">[</phrase><phrase role="identifier">idx2</phrase><phrase role="special">])</phrase> <phrase role="special">/</phrase> <phrase role="number">3.0f</phrase><phrase role="special">;</phrase> <phrase role="keyword">float</phrase> <phrase role="identifier">bs</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">b</phrase><phrase role="special">[</phrase><phrase role="identifier">idx</phrase><phrase role="special">]</phrase> <phrase role="special">+</phrase> <phrase role="identifier">b</phrase><phrase role="special">[</phrase><phrase role="identifier">idx1</phrase><phrase role="special">]</phrase> <phrase role="special">+</phrase> <phrase role="identifier">b</phrase><phrase role="special">[</phrase><phrase role="identifier">idx2</phrase><phrase role="special">])</phrase> <phrase role="special">/</phrase> <phrase role="number">3.0f</phrase><phrase role="special">;</phrase> <phrase role="identifier">c</phrase><phrase role="special">[</phrase><phrase role="identifier">idx</phrase><phrase role="special">]</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase><phrase role="identifier">as</phrase> <phrase role="special">+</phrase> <phrase role="identifier">bs</phrase><phrase role="special">)</phrase> <phrase role="special">/</phrase> <phrase role="number">2</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase> <phrase role="identifier">f</phrase><phrase role="special">([&amp;</phrase><phrase role="identifier">done</phrase><phrase role="special">]{</phrase> <phrase role="identifier">hipStream_t</phrase> <phrase role="identifier">stream</phrase><phrase role="special">;</phrase> <phrase role="identifier">hipStreamCreate</phrase><phrase role="special">(</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">stream</phrase><phrase role="special">);</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">size</phrase> <phrase role="special">=</phrase> <phrase role="number">1024</phrase> <phrase role="special">*</phrase> <phrase role="number">1024</phrase><phrase role="special">;</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">full_size</phrase> <phrase role="special">=</phrase> <phrase role="number">20</phrase> <phrase role="special">*</phrase> <phrase role="identifier">size</phrase><phrase role="special">;</phrase> <phrase role="keyword">int</phrase> <phrase role="special">*</phrase> <phrase role="identifier">host_a</phrase><phrase role="special">,</phrase> <phrase role="special">*</phrase> <phrase role="identifier">host_b</phrase><phrase role="special">,</phrase> <phrase role="special">*</phrase> <phrase role="identifier">host_c</phrase><phrase role="special">;</phrase> <phrase role="identifier">hipHostMalloc</phrase><phrase role="special">(</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">host_a</phrase><phrase role="special">,</phrase> <phrase role="identifier">full_size</phrase> <phrase role="special">*</phrase> <phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase><phrase role="special">),</phrase> <phrase role="identifier">hipHostMallocDefault</phrase><phrase role="special">);</phrase> <phrase role="identifier">hipHostMalloc</phrase><phrase role="special">(</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">host_b</phrase><phrase role="special">,</phrase> <phrase role="identifier">full_size</phrase> <phrase role="special">*</phrase> <phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase><phrase role="special">),</phrase> <phrase role="identifier">hipHostMallocDefault</phrase><phrase role="special">);</phrase> <phrase role="identifier">hipHostMalloc</phrase><phrase role="special">(</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">host_c</phrase><phrase role="special">,</phrase> <phrase role="identifier">full_size</phrase> <phrase role="special">*</phrase> <phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase><phrase role="special">),</phrase> <phrase role="identifier">hipHostMallocDefault</phrase><phrase role="special">);</phrase> <phrase role="keyword">int</phrase> <phrase role="special">*</phrase> <phrase role="identifier">dev_a</phrase><phrase role="special">,</phrase> <phrase role="special">*</phrase> <phrase role="identifier">dev_b</phrase><phrase role="special">,</phrase> <phrase role="special">*</phrase> <phrase role="identifier">dev_c</phrase><phrase role="special">;</phrase> <phrase role="identifier">hipMalloc</phrase><phrase role="special">(</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">dev_a</phrase><phrase role="special">,</phrase> <phrase role="identifier">size</phrase> <phrase role="special">*</phrase> <phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="identifier">hipMalloc</phrase><phrase role="special">(</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">dev_b</phrase><phrase role="special">,</phrase> <phrase role="identifier">size</phrase> <phrase role="special">*</phrase> <phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="identifier">hipMalloc</phrase><phrase role="special">(</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">dev_c</phrase><phrase role="special">,</phrase> <phrase role="identifier">size</phrase> <phrase role="special">*</phrase> <phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">minstd_rand</phrase> <phrase role="identifier">generator</phrase><phrase role="special">;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int_distribution</phrase><phrase role="special">&lt;&gt;</phrase> <phrase role="identifier">distribution</phrase><phrase role="special">(</phrase><phrase role="number">1</phrase><phrase role="special">,</phrase> <phrase role="number">6</phrase><phrase role="special">);</phrase> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">full_size</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">host_a</phrase><phrase role="special">[</phrase><phrase role="identifier">i</phrase><phrase role="special">]</phrase> <phrase role="special">=</phrase> <phrase role="identifier">distribution</phrase><phrase role="special">(</phrase> <phrase role="identifier">generator</phrase><phrase role="special">);</phrase> <phrase role="identifier">host_b</phrase><phrase role="special">[</phrase><phrase role="identifier">i</phrase><phrase role="special">]</phrase> <phrase role="special">=</phrase> <phrase role="identifier">distribution</phrase><phrase role="special">(</phrase> <phrase role="identifier">generator</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">full_size</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase> <phrase role="special">+=</phrase> <phrase role="identifier">size</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">hipMemcpyAsync</phrase><phrase role="special">(</phrase> <phrase role="identifier">dev_a</phrase><phrase role="special">,</phrase> <phrase role="identifier">host_a</phrase> <phrase role="special">+</phrase> <phrase role="identifier">i</phrase><phrase role="special">,</phrase> <phrase role="identifier">size</phrase> <phrase role="special">*</phrase> <phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase><phrase role="special">),</phrase> <phrase role="identifier">hipMemcpyHostToDevice</phrase><phrase role="special">,</phrase> <phrase role="identifier">stream</phrase><phrase role="special">);</phrase> <phrase role="identifier">hipMemcpyAsync</phrase><phrase role="special">(</phrase> <phrase role="identifier">dev_b</phrase><phrase role="special">,</phrase> <phrase role="identifier">host_b</phrase> <phrase role="special">+</phrase> <phrase role="identifier">i</phrase><phrase role="special">,</phrase> <phrase role="identifier">size</phrase> <phrase role="special">*</phrase> <phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase><phrase role="special">),</phrase> <phrase role="identifier">hipMemcpyHostToDevice</phrase><phrase role="special">,</phrase> <phrase role="identifier">stream</phrase><phrase role="special">);</phrase> <phrase role="identifier">hipLaunchKernel</phrase><phrase role="special">(</phrase><phrase role="identifier">kernel</phrase><phrase role="special">,</phrase> <phrase role="identifier">dim3</phrase><phrase role="special">(</phrase><phrase role="identifier">size</phrase> <phrase role="special">/</phrase> <phrase role="number">256</phrase><phrase role="special">),</phrase> <phrase role="identifier">dim3</phrase><phrase role="special">(</phrase><phrase role="number">256</phrase><phrase role="special">),</phrase> <phrase role="number">0</phrase><phrase role="special">,</phrase> <phrase role="identifier">stream</phrase><phrase role="special">,</phrase> <phrase role="identifier">size</phrase><phrase role="special">,</phrase> <phrase role="identifier">dev_a</phrase><phrase role="special">,</phrase> <phrase role="identifier">dev_b</phrase><phrase role="special">,</phrase> <phrase role="identifier">dev_c</phrase><phrase role="special">);</phrase> <phrase role="identifier">hipMemcpyAsync</phrase><phrase role="special">(</phrase> <phrase role="identifier">host_c</phrase> <phrase role="special">+</phrase> <phrase role="identifier">i</phrase><phrase role="special">,</phrase> <phrase role="identifier">dev_c</phrase><phrase role="special">,</phrase> <phrase role="identifier">size</phrase> <phrase role="special">*</phrase> <phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase><phrase role="special">),</phrase> <phrase role="identifier">hipMemcpyDeviceToHost</phrase><phrase role="special">,</phrase> <phrase role="identifier">stream</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">result</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">hip</phrase><phrase role="special">::</phrase><phrase role="identifier">waitfor_all</phrase><phrase role="special">(</phrase> <phrase role="identifier">stream</phrase><phrase role="special">);</phrase> <phrase role="comment">// suspend fiber till HIP stream has finished</phrase> <phrase role="identifier">BOOST_ASSERT</phrase><phrase role="special">(</phrase> <phrase role="identifier">stream</phrase> <phrase role="special">==</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">get</phrase><phrase role="special">&lt;</phrase> <phrase role="number">0</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="identifier">BOOST_ASSERT</phrase><phrase role="special">(</phrase> <phrase role="identifier">hipSuccess</phrase> <phrase role="special">==</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">get</phrase><phrase role="special">&lt;</phrase> <phrase role="number">1</phrase> <phrase role="special">&gt;(</phrase> <phrase role="identifier">result</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="string">&quot;f1: GPU computation finished&quot;</phrase> <phrase role="special">&lt;&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase> <phrase role="identifier">hipHostFree</phrase><phrase role="special">(</phrase> <phrase role="identifier">host_a</phrase><phrase role="special">);</phrase> <phrase role="identifier">hipHostFree</phrase><phrase role="special">(</phrase> <phrase role="identifier">host_b</phrase><phrase role="special">);</phrase> <phrase role="identifier">hipHostFree</phrase><phrase role="special">(</phrase> <phrase role="identifier">host_c</phrase><phrase role="special">);</phrase> <phrase role="identifier">hipFree</phrase><phrase role="special">(</phrase> <phrase role="identifier">dev_a</phrase><phrase role="special">);</phrase> <phrase role="identifier">hipFree</phrase><phrase role="special">(</phrase> <phrase role="identifier">dev_b</phrase><phrase role="special">);</phrase> <phrase role="identifier">hipFree</phrase><phrase role="special">(</phrase> <phrase role="identifier">dev_c</phrase><phrase role="special">);</phrase> <phrase role="identifier">hipStreamDestroy</phrase><phrase role="special">(</phrase> <phrase role="identifier">stream</phrase><phrase role="special">);</phrase> <phrase role="special">});</phrase> <phrase role="identifier">f</phrase><phrase role="special">.</phrase><phrase role="identifier">join</phrase><phrase role="special">();</phrase> </programlisting> <bridgehead renderas="sect4" id="fiber.gpu_computing.hip.h1"> <phrase id="fiber.gpu_computing.hip.synopsis"/><link linkend="fiber.gpu_computing.hip.synopsis">Synopsis</link> </bridgehead> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">hip</phrase><phrase role="special">/</phrase><phrase role="identifier">waitfor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">hip</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">tuple</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">hipStream_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">hipError_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">waitfor_all</phrase><phrase role="special">(</phrase> <phrase role="identifier">hipStream_t</phrase> <phrase role="identifier">st</phrase><phrase role="special">);</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">tuple</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">hipStream_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">hipError_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">waitfor_all</phrase><phrase role="special">(</phrase> <phrase role="identifier">hipStream_t</phrase> <phrase role="special">...</phrase> <phrase role="identifier">st</phrase><phrase role="special">);</phrase> <phrase role="special">}}}</phrase> </programlisting> <para> <bridgehead renderas="sect4" id="hip_waitfor_bridgehead"> <phrase id="hip_waitfor"/> <link linkend="hip_waitfor">Non-member function <code>hip::waitfor()</code></link> </bridgehead> </para> <programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">hip</phrase><phrase role="special">/</phrase><phrase role="identifier">waitfor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">&gt;</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">fibers</phrase> <phrase role="special">{</phrase> <phrase role="keyword">namespace</phrase> <phrase role="identifier">hip</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">tuple</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">hipStream_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">hipError_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">waitfor_all</phrase><phrase role="special">(</phrase> <phrase role="identifier">hipStream_t</phrase> <phrase role="identifier">st</phrase><phrase role="special">);</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">vector</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">tuple</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">hipStream_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">hipError_t</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">waitfor_all</phrase><phrase role="special">(</phrase> <phrase role="identifier">hipStream_t</phrase> <phrase role="special">...</phrase> <phrase role="identifier">st</phrase><phrase role="special">);</phrase> <phrase role="special">}}}</phrase> </programlisting> <variablelist> <title></title> <varlistentry> <term>Effects:</term> <listitem> <para> Suspends active fiber till HIP stream has finished its operations. </para> </listitem> </varlistentry> <varlistentry> <term>Returns:</term> <listitem> <para> tuple of stream reference and the HIP stream status </para> </listitem> </varlistentry> </variablelist> </section> </section> <section id="fiber.worker"> <title><anchor id="worker"/><link linkend="fiber.worker">Running with worker threads</link></title> <bridgehead renderas="sect3" id="fiber.worker.h0"> <phrase id="fiber.worker.keep_workers_running"/><link linkend="fiber.worker.keep_workers_running">Keep workers running</link> </bridgehead> <para> If a worker thread is used but no fiber is created or parts of the framework (like <link linkend="this_fiber_yield"><code>this_fiber::yield()</code></link>) are touched, then no fiber scheduler is instantiated. </para> <programlisting><phrase role="keyword">auto</phrase> <phrase role="identifier">worker</phrase> <phrase role="special">=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">thread</phrase><phrase role="special">(</phrase> <phrase role="special">[]{</phrase> <phrase role="comment">// fiber scheduler not instantiated</phrase> <phrase role="special">});</phrase> <phrase role="identifier">worker</phrase><phrase role="special">.</phrase><phrase role="identifier">join</phrase><phrase role="special">();</phrase> </programlisting> <para> If <emphasis>use_scheduling_algorithm&lt;&gt;()</emphasis> is invoked, the fiber scheduler is created. If the worker thread simply returns, destroys the scheduler and terminates. </para> <programlisting><phrase role="keyword">auto</phrase> <phrase role="identifier">worker</phrase> <phrase role="special">=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">thread</phrase><phrase role="special">(</phrase> <phrase role="special">[]{</phrase> <phrase role="comment">// fiber scheduler created</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">my_fiber_scheduler</phrase><phrase role="special">&gt;();</phrase> <phrase role="special">});</phrase> <phrase role="identifier">worker</phrase><phrase role="special">.</phrase><phrase role="identifier">join</phrase><phrase role="special">();</phrase> </programlisting> <para> In order to keep the worker thread running, the fiber associated with the thread stack (which is called <quote>main</quote> fiber) is blocked. For instance the <quote>main</quote> fiber might wait on a <link linkend="class_condition_variable"><code>condition_variable</code></link>. For a gracefully shutdown <link linkend="class_condition_variable"><code>condition_variable</code></link> is signalled and the <quote>main</quote> fiber returns. The scheduler gets destructed if all fibers of the worker thread have been terminated. </para> <programlisting><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">mutex</phrase> <phrase role="identifier">mtx</phrase><phrase role="special">;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_variable_any</phrase> <phrase role="identifier">cv</phrase><phrase role="special">;</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">worker</phrase> <phrase role="special">=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">thread</phrase><phrase role="special">(</phrase> <phrase role="special">[&amp;</phrase><phrase role="identifier">mtx</phrase><phrase role="special">,&amp;</phrase><phrase role="identifier">cv</phrase><phrase role="special">]{</phrase> <phrase role="identifier">mtx</phrase><phrase role="special">.</phrase><phrase role="identifier">lock</phrase><phrase role="special">();</phrase> <phrase role="comment">// suspend till signalled</phrase> <phrase role="identifier">cv</phrase><phrase role="special">.</phrase><phrase role="identifier">wait</phrase><phrase role="special">(</phrase><phrase role="identifier">mtx</phrase><phrase role="special">);</phrase> <phrase role="identifier">mtx</phrase><phrase role="special">.</phrase><phrase role="identifier">unlock</phrase><phrase role="special">();</phrase> <phrase role="special">});</phrase> <phrase role="comment">// signal termination</phrase> <phrase role="identifier">cv</phrase><phrase role="special">.</phrase><phrase role="identifier">notify_all</phrase><phrase role="special">();</phrase> <phrase role="identifier">worker</phrase><phrase role="special">.</phrase><phrase role="identifier">join</phrase><phrase role="special">();</phrase> </programlisting> <bridgehead renderas="sect3" id="fiber.worker.h1"> <phrase id="fiber.worker.processing_tasks"/><link linkend="fiber.worker.processing_tasks">Processing tasks</link> </bridgehead> <para> Tasks can be transferred via channels. The worker thread runs a pool of fibers that dequeue and executed tasks from the channel. The termination is signalled via closing the channel. </para> <programlisting><phrase role="keyword">using</phrase> <phrase role="identifier">task</phrase> <phrase role="special">=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">function</phrase><phrase role="special">&lt;</phrase><phrase role="keyword">void</phrase><phrase role="special">()&gt;;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">buffered_channel</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">task</phrase><phrase role="special">&gt;</phrase> <phrase role="identifier">ch</phrase><phrase role="special">{</phrase><phrase role="number">1024</phrase><phrase role="special">};</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">worker</phrase> <phrase role="special">=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">thread</phrase><phrase role="special">(</phrase> <phrase role="special">[&amp;</phrase><phrase role="identifier">ch</phrase><phrase role="special">]{</phrase> <phrase role="comment">// create pool of fibers</phrase> <phrase role="keyword">for</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase><phrase role="special">=</phrase><phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="identifier">i</phrase><phrase role="special">&lt;</phrase><phrase role="number">10</phrase><phrase role="special">;</phrase> <phrase role="special">++</phrase><phrase role="identifier">i</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase><phrase role="special">{</phrase> <phrase role="special">[&amp;</phrase><phrase role="identifier">ch</phrase><phrase role="special">]{</phrase> <phrase role="identifier">task</phrase> <phrase role="identifier">tsk</phrase><phrase role="special">;</phrase> <phrase role="comment">// dequeue and process tasks</phrase> <phrase role="keyword">while</phrase> <phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">channel_op_status</phrase><phrase role="special">::</phrase><phrase role="identifier">closed</phrase><phrase role="special">!=</phrase><phrase role="identifier">ch</phrase><phrase role="special">.</phrase><phrase role="identifier">pop</phrase><phrase role="special">(</phrase><phrase role="identifier">tsk</phrase><phrase role="special">)){</phrase> <phrase role="identifier">tsk</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="special">}}.</phrase><phrase role="identifier">detach</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="identifier">task</phrase> <phrase role="identifier">tsk</phrase><phrase role="special">;</phrase> <phrase role="comment">// dequeue and process tasks</phrase> <phrase role="keyword">while</phrase> <phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">channel_op_status</phrase><phrase role="special">::</phrase><phrase role="identifier">closed</phrase><phrase role="special">!=</phrase><phrase role="identifier">ch</phrase><phrase role="special">.</phrase><phrase role="identifier">pop</phrase><phrase role="special">(</phrase><phrase role="identifier">tsk</phrase><phrase role="special">)){</phrase> <phrase role="identifier">tsk</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="special">});</phrase> <phrase role="comment">// feed channel with tasks</phrase> <phrase role="identifier">ch</phrase><phrase role="special">.</phrase><phrase role="identifier">push</phrase><phrase role="special">([]{</phrase> <phrase role="special">...</phrase> <phrase role="special">});</phrase> <phrase role="special">...</phrase> <phrase role="comment">// signal termination</phrase> <phrase role="identifier">ch</phrase><phrase role="special">.</phrase><phrase role="identifier">close</phrase><phrase role="special">();</phrase> <phrase role="identifier">worker</phrase><phrase role="special">.</phrase><phrase role="identifier">join</phrase><phrase role="special">();</phrase> </programlisting> <para> An alternative is to use a work-stealing scheduler. This kind of scheduling algorithm a worker thread steals fibers from the ready-queue of other worker threads if its own ready-queue is empty. </para> <note> <para> Wait till all worker threads have registered the work-stealing scheduling algorithm. </para> </note> <programlisting><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">barrier</phrase> <phrase role="identifier">b</phrase><phrase role="special">{</phrase><phrase role="number">2</phrase><phrase role="special">};</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">algo</phrase><phrase role="special">::</phrase><phrase role="identifier">work_stealing</phrase><phrase role="special">&gt;(</phrase><phrase role="number">2</phrase><phrase role="special">);</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">mutex</phrase> <phrase role="identifier">mtx</phrase><phrase role="special">;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_variable_any</phrase> <phrase role="identifier">cv</phrase><phrase role="special">;</phrase> <phrase role="keyword">auto</phrase> <phrase role="identifier">worker</phrase> <phrase role="special">=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">thread</phrase><phrase role="special">(</phrase> <phrase role="special">[&amp;</phrase><phrase role="identifier">mtx</phrase><phrase role="special">,&amp;</phrase><phrase role="identifier">cv</phrase><phrase role="special">,&amp;</phrase><phrase role="identifier">b</phrase><phrase role="special">]{</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">algo</phrase><phrase role="special">::</phrase><phrase role="identifier">work_stealing</phrase><phrase role="special">&gt;(</phrase><phrase role="number">2</phrase><phrase role="special">);</phrase> <phrase role="comment">// wait till all threads joining the work stealing have been registered</phrase> <phrase role="identifier">b</phrase><phrase role="special">.</phrase><phrase role="identifier">wait</phrase><phrase role="special">();</phrase> <phrase role="identifier">mtx</phrase><phrase role="special">.</phrase><phrase role="identifier">lock</phrase><phrase role="special">();</phrase> <phrase role="comment">// suspend main-fiber from the worker thread</phrase> <phrase role="identifier">cv</phrase><phrase role="special">.</phrase><phrase role="identifier">wait</phrase><phrase role="special">(</phrase><phrase role="identifier">mtx</phrase><phrase role="special">);</phrase> <phrase role="identifier">mtx</phrase><phrase role="special">.</phrase><phrase role="identifier">unlock</phrase><phrase role="special">();</phrase> <phrase role="special">});</phrase> <phrase role="comment">// wait till all threads have been registered the scheduling algorithm</phrase> <phrase role="identifier">b</phrase><phrase role="special">.</phrase><phrase role="identifier">wait</phrase><phrase role="special">();</phrase> <phrase role="comment">// create fibers with tasks</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase> <phrase role="identifier">f</phrase><phrase role="special">{[]{</phrase> <phrase role="special">...</phrase> <phrase role="special">}};</phrase> <phrase role="special">...</phrase> <phrase role="comment">// signal termination</phrase> <phrase role="identifier">cv</phrase><phrase role="special">.</phrase><phrase role="identifier">notify_all</phrase><phrase role="special">();</phrase> <phrase role="identifier">worker</phrase><phrase role="special">.</phrase><phrase role="identifier">join</phrase><phrase role="special">();</phrase> </programlisting> <important> <para> Because the TIB (thread information block on Windows) is not fully described in the MSDN, it might be possible that not all required TIB-parts are swapped. Using WinFiber implementation might be an alternative (see documentation about <ulink url="path_to_url"><emphasis>implementations fcontext_t, ucontext_t and WinFiber of boost.context</emphasis></ulink>). </para> </important> </section> <section id="fiber.performance"> <title><link linkend="fiber.performance">Performance</link></title> <para> Performance measurements were taken using <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">highresolution_clock</phrase></code>, with overhead corrections. The code was compiled with gcc-6.3.1, using build options: variant = release, optimization = speed. Tests were executed on dual Intel XEON E5 2620v4 2.2GHz, 16C/32T, 64GB RAM, running Linux (x86_64). </para> <para> Measurements headed 1C/1T were run in a single-threaded process. </para> <para> The <ulink url="path_to_url">microbenchmark <emphasis>syknet</emphasis></ulink> from Alexander Temerev was ported and used for performance measurements. At the root the test spawns 10 threads-of-execution (ToE), e.g. actor/goroutine/fiber etc.. Each spawned ToE spawns additional 10 ToEs ... until <emphasis role="bold">1,000,000</emphasis> ToEs are created. ToEs return back their ordinal numbers (0 ... 999,999), which are summed on the previous level and sent back upstream, until reaching the root. The test was run 10-20 times, producing a range of values for each measurement. </para> <table frame="all" id="fiber.performance.your_sha256_hashge_over_1_000_000_"> <title>time per actor/erlang process/goroutine (other languages) (average over 1,000,000)</title> <tgroup cols="3"> <thead> <row> <entry> <para> Haskell | stack-1.4.0/ghc-8.0.1 </para> </entry> <entry> <para> Go | go1.8.1 </para> </entry> <entry> <para> Erlang | erts-8.3 </para> </entry> </row> </thead> <tbody> <row> <entry> <para> 0.05 &#xb5;s - 0.06 &#xb5;s </para> </entry> <entry> <para> 0.42 &#xb5;s - 0.49 &#xb5;s </para> </entry> <entry> <para> 0.63 &#xb5;s - 0.73 &#xb5;s </para> </entry> </row> </tbody> </tgroup> </table> <para> Pthreads are created with a stack size of 8kB while <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">thread</phrase></code>'s use the system default (1MB - 2MB). The microbenchmark could <emphasis role="bold">not</emphasis> be <emphasis role="bold">run</emphasis> with 1,000,000 threads because of <emphasis role="bold">resource exhaustion</emphasis> (pthread and std::thread). Instead the test runs only at <emphasis role="bold">10,000</emphasis> threads. </para> <table frame="all" id="fiber.performance.your_sha256_hash_threads_"> <title>time per thread (average over 10,000 - unable to spawn 1,000,000 threads)</title> <tgroup cols="3"> <thead> <row> <entry> <para> pthread </para> </entry> <entry> <para> <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">thread</phrase></code> </para> </entry> <entry> <para> <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">async</phrase></code> </para> </entry> </row> </thead> <tbody> <row> <entry> <para> 54 &#xb5;s - 73 &#xb5;s </para> </entry> <entry> <para> 52 &#xb5;s - 73 &#xb5;s </para> </entry> <entry> <para> 106 &#xb5;s - 122 &#xb5;s </para> </entry> </row> </tbody> </tgroup> </table> <para> The test utilizes 16 cores with Symmetric MultiThreading enabled (32 logical CPUs). The fiber stacks are allocated by <link linkend="class_fixedsize_stack"><code>fixedsize_stack</code></link>. </para> <para> As the benchmark shows, the memory allocation algorithm is significant for performance in a multithreaded environment. The tests use glibc&#8217;s memory allocation algorithm (based on ptmalloc2) as well as Google&#8217;s <ulink url="path_to_url">TCmalloc</ulink> (via linkflags=&quot;-ltcmalloc&quot;).<footnote id="fiber.performance.f0"> <para> Tais B. Ferreira, Rivalino Matias, Autran Macedo, Lucio B. Araujo <quote>An Experimental Study on Memory Allocators in Multicore and Multithreaded Applications</quote>, PDCAT &#8217;11 Proceedings of the 2011 12th International Conference on Parallel and Distributed Computing, Applications and Technologies, pages 92-98 </para> </footnote> </para> <para> In the <link linkend="class_work_stealing"><code>work_stealing</code></link> scheduling algorithm, each thread has its own local queue. Fibers that are ready to run are pushed to and popped from the local queue. If the queue runs out of ready fibers, fibers are stolen from the local queues of other participating threads. </para> <table frame="all" id="fiber.performance.time_per_fiber__average_over_1_000_000_"> <title>time per fiber (average over 1.000.000)</title> <tgroup cols="2"> <thead> <row> <entry> <para> fiber (16C/32T, work stealing, tcmalloc) </para> </entry> <entry> <para> fiber (1C/1T, round robin, tcmalloc) </para> </entry> </row> </thead> <tbody> <row> <entry> <para> 0.05 &#xb5;s - 0.09 &#xb5;s </para> </entry> <entry> <para> 1.69 &#xb5;s - 1.79 &#xb5;s </para> </entry> </row> </tbody> </tgroup> </table> </section> <section id="fiber.tuning"> <title><anchor id="tuning"/><link linkend="fiber.tuning">Tuning</link></title> <bridgehead renderas="sect3" id="fiber.tuning.h0"> <phrase id="fiber.tuning.disable_synchronization"/><link linkend="fiber.tuning.disable_synchronization">Disable synchronization</link> </bridgehead> <para> With <link linkend="cross_thread_sync"><code><phrase role="identifier">BOOST_FIBERS_NO_ATOMICS</phrase></code></link> defined at the compiler&#8217;s command line, synchronization between fibers (in different threads) is disabled. This is acceptable if the application is single threaded and/or fibers are not synchronized between threads. </para> <bridgehead renderas="sect3" id="fiber.tuning.h1"> <phrase id="fiber.tuning.memory_allocation"/><link linkend="fiber.tuning.memory_allocation">Memory allocation</link> </bridgehead> <para> Memory allocation algorithm is significant for performance in a multithreaded environment, especially for <emphasis role="bold">Boost.Fiber</emphasis> where fiber stacks are allocated on the heap. The default user-level memory allocator (UMA) of glibc is ptmalloc2 but it can be replaced by another UMA that fit better for the concret work-load For instance Google&#8217;s <ulink url="path_to_url">TCmalloc</ulink> enables a better performance at the <emphasis>skynet</emphasis> microbenchmark than glibc&#8217;s default memory allocator. </para> <bridgehead renderas="sect3" id="fiber.tuning.h2"> <phrase id="fiber.tuning.scheduling_strategies"/><link linkend="fiber.tuning.scheduling_strategies">Scheduling strategies</link> </bridgehead> <para> The fibers in a thread are coordinated by a fiber manager. Fibers trade control cooperatively, rather than preemptively. Depending on the work-load several strategies of scheduling the fibers are possible <footnote id="fiber.tuning.f0"> <para> 1024cores.net: <ulink url="path_to_url">Task Scheduling Strategies</ulink> </para> </footnote> that can be implmented on behalf of <link linkend="class_algorithm"><code>algorithm</code></link>. </para> <itemizedlist> <listitem> <simpara> work-stealing: ready fibers are hold in a local queue, when the fiber-scheduler's local queue runs out of ready fibers, it randomly selects another fiber-scheduler and tries to steal a ready fiber from the victim (implemented in <link linkend="class_work_stealing"><code>work_stealing</code></link> and <link linkend="class_numa_work_stealing"><code>numa::work_stealing</code></link>) </simpara> </listitem> <listitem> <simpara> work-requesting: ready fibers are hold in a local queue, when the fiber-scheduler's local queue runs out of ready fibers, it randomly selects another fiber-scheduler and requests for a ready fibers, the victim fiber-scheduler sends a ready-fiber back </simpara> </listitem> <listitem> <simpara> work-sharing: ready fibers are hold in a global queue, fiber-scheduler concurrently push and pop ready fibers to/from the global queue (implemented in <link linkend="class_shared_work"><code>shared_work</code></link>) </simpara> </listitem> <listitem> <simpara> work-distribution: fibers that became ready are proactivly distributed to idle fiber-schedulers or fiber-schedulers with low load </simpara> </listitem> <listitem> <simpara> work-balancing: a dedicated (helper) fiber-scheduler periodically collects informations about all fiber-scheduler running in other threads and re-distributes ready fibers among them </simpara> </listitem> </itemizedlist> <bridgehead renderas="sect3" id="fiber.tuning.h3"> <phrase id="fiber.tuning.ttas_locks"/><link linkend="fiber.tuning.ttas_locks">TTAS locks</link> </bridgehead> <para> Boost.Fiber uses internally spinlocks to protect critical regions if fibers running on different threads interact. Spinlocks are implemented as TTAS (test-test-and-set) locks, i.e. the spinlock tests the lock before calling an atomic exchange. This strategy helps to reduce the cache line invalidations triggered by acquiring/releasing the lock. </para> <bridgehead renderas="sect3" id="fiber.tuning.h4"> <phrase id="fiber.tuning.spin_wait_loop"/><link linkend="fiber.tuning.spin_wait_loop">Spin-wait loop</link> </bridgehead> <para> A lock is considered under contention, if a thread repeatedly fails to acquire the lock because some other thread was faster. Waiting for a short time lets other threads finish before trying to enter the critical section again. While busy waiting on the lock, relaxing the CPU (via pause/yield mnemonic) gives the CPU a hint that the code is in a spin-wait loop. </para> <itemizedlist> <listitem> <simpara> prevents expensive pipeline flushes (speculatively executed load and compare instructions are not pushed to pipeline) </simpara> </listitem> <listitem> <simpara> another hardware thread (simultaneous multithreading) can get time slice </simpara> </listitem> <listitem> <simpara> it does delay a few CPU cycles, but this is necessary to prevent starvation </simpara> </listitem> </itemizedlist> <para> It is obvious that this strategy is useless on single core systems because the lock can only released if the thread gives up its time slice in order to let other threads run. The macro BOOST_FIBERS_SPIN_SINGLE_CORE replaces the CPU hints (pause/yield mnemonic) by informing the operating system (via <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">this_thread_yield</phrase><phrase role="special">()</phrase></code>) that the thread gives up its time slice and the operating system switches to another thread. </para> <bridgehead renderas="sect3" id="fiber.tuning.h5"> <phrase id="fiber.tuning.exponential_back_off"/><link linkend="fiber.tuning.exponential_back_off">Exponential back-off</link> </bridgehead> <para> The macro BOOST_FIBERS_RETRY_THRESHOLD determines how many times the CPU iterates in the spin-wait loop before yielding the thread or blocking in futex-wait. The spinlock tracks how many times the thread failed to acquire the lock. The higher the contention, the longer the thread should back-off. A <quote>Binary Exponential Backoff</quote> algorithm together with a randomized contention window is utilized for this purpose. BOOST_FIBERS_CONTENTION_WINDOW_THRESHOLD determines the upper limit of the contention window (expressed as the exponent for basis of two). </para> <bridgehead renderas="sect3" id="fiber.tuning.h6"> <phrase id="fiber.tuning.speculative_execution__hardware_transactional_memory_"/><link linkend="fiber.tuning.speculative_execution__hardware_transactional_memory_">Speculative execution (hardware transactional memory)</link> </bridgehead> <para> Boost.Fiber uses spinlocks to protect critical regions that can be used together with transactional memory (see section <link linkend="speculation">Speculative execution</link>). </para> <note> <para> TXS is enabled if property <code><phrase role="identifier">htm</phrase><phrase role="special">=</phrase><phrase role="identifier">tsx</phrase></code> is specified at b2 command-line and <code><phrase role="identifier">BOOST_USE_TSX</phrase></code> is applied to the compiler. </para> </note> <note> <para> A TSX-transaction will be aborted if the floating point state is modified inside a critical region. As a consequence floating point operations, e.g. tore/load of floating point related registers during a fiber (context) switch are disabled. </para> </note> <bridgehead renderas="sect3" id="fiber.tuning.h7"> <phrase id="fiber.tuning.numa_systems"/><link linkend="fiber.tuning.numa_systems">NUMA systems</link> </bridgehead> <para> Modern multi-socket systems are usually designed as <link linkend="numa">NUMA systems</link>. A suitable fiber scheduler like <link linkend="class_numa_work_stealing"><code>numa::work_stealing</code></link> reduces remote memory access (latence). </para> <bridgehead renderas="sect3" id="fiber.tuning.h8"> <phrase id="fiber.tuning.parameters"/><link linkend="fiber.tuning.parameters">Parameters</link> </bridgehead> <table frame="all" id="fiber.tuning.parameters_that_migh_be_defiend_at_compiler_s_command_line"> <title>Parameters that migh be defiend at compiler's command line</title> <tgroup cols="3"> <thead> <row> <entry> <para> Parameter </para> </entry> <entry> <para> Default value </para> </entry> <entry> <para> Effect on Boost.Fiber </para> </entry> </row> </thead> <tbody> <row> <entry> <para> BOOST_FIBERS_NO_ATOMICS </para> </entry> <entry> <para> - </para> </entry> <entry> <para> no multithreading support, all atomics removed, no synchronization between fibers running in different threads </para> </entry> </row> <row> <entry> <para> BOOST_FIBERS_SPINLOCK_STD_MUTEX </para> </entry> <entry> <para> - </para> </entry> <entry> <para> <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">mutex</phrase></code> used inside spinlock </para> </entry> </row> <row> <entry> <para> BOOST_FIBERS_SPINLOCK_TTAS </para> </entry> <entry> <para> + </para> </entry> <entry> <para> spinlock with test-test-and-swap on shared variable </para> </entry> </row> <row> <entry> <para> BOOST_FIBERS_SPINLOCK_TTAS_ADAPTIVE </para> </entry> <entry> <para> - </para> </entry> <entry> <para> spinlock with test-test-and-swap on shared variable, adaptive retries while busy waiting </para> </entry> </row> <row> <entry> <para> BOOST_FIBERS_SPINLOCK_TTAS_FUTEX </para> </entry> <entry> <para> - </para> </entry> <entry> <para> spinlock with test-test-and-swap on shared variable, suspend on futex after certain number of retries </para> </entry> </row> <row> <entry> <para> BOOST_FIBERS_SPINLOCK_TTAS_ADAPTIVE_FUTEX </para> </entry> <entry> <para> - </para> </entry> <entry> <para> spinlock with test-test-and-swap on shared variable, while busy waiting adaptive retries, suspend on futex certain amount of retries </para> </entry> </row> <row> <entry> <para> BOOST_FIBERS_SPINLOCK_TTAS + BOOST_USE_TSX </para> </entry> <entry> <para> - </para> </entry> <entry> <para> spinlock with test-test-and-swap and speculative execution (Intel TSX required) </para> </entry> </row> <row> <entry> <para> BOOST_FIBERS_SPINLOCK_TTAS_ADAPTIVE + BOOST_USE_TSX </para> </entry> <entry> <para> - </para> </entry> <entry> <para> spinlock with test-test-and-swap on shared variable, adaptive retries while busy waiting and speculative execution (Intel TSX required) </para> </entry> </row> <row> <entry> <para> BOOST_FIBERS_SPINLOCK_TTAS_FUTEX + BOOST_USE_TSX </para> </entry> <entry> <para> - </para> </entry> <entry> <para> spinlock with test-test-and-swap on shared variable, suspend on futex after certain number of retries and speculative execution (Intel TSX required) </para> </entry> </row> <row> <entry> <para> BOOST_FIBERS_SPINLOCK_TTAS_ADAPTIVE_FUTEX + BOOST_USE_TSX </para> </entry> <entry> <para> - </para> </entry> <entry> <para> spinlock with test-test-and-swap on shared variable, while busy waiting adaptive retries, suspend on futex certain amount of retries and speculative execution (Intel TSX required) </para> </entry> </row> <row> <entry> <para> BOOST_FIBERS_SPIN_SINGLE_CORE </para> </entry> <entry> <para> - </para> </entry> <entry> <para> on single core machines with multiple threads, yield thread (<code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase role="identifier">yield</phrase><phrase role="special">()</phrase></code>) after collisions </para> </entry> </row> <row> <entry> <para> BOOST_FIBERS_RETRY_THRESHOLD </para> </entry> <entry> <para> 64 </para> </entry> <entry> <para> max number of retries while busy spinning, the use fallback </para> </entry> </row> <row> <entry> <para> BOOST_FIBERS_CONTENTION_WINDOW_THRESHOLD </para> </entry> <entry> <para> 16 </para> </entry> <entry> <para> max size of collisions window, expressed as exponent for the basis of two </para> </entry> </row> <row> <entry> <para> BOOST_FIBERS_SPIN_BEFORE_SLEEP0 </para> </entry> <entry> <para> 32 </para> </entry> <entry> <para> max number of retries that relax the processor before the thread sleeps for 0s </para> </entry> </row> <row> <entry> <para> BOOST_FIBERS_SPIN_BEFORE_YIELD </para> </entry> <entry> <para> 64 </para> </entry> <entry> <para> max number of retries where the thread sleeps for 0s before yield thread (<code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase role="identifier">yield</phrase><phrase role="special">()</phrase></code>) </para> </entry> </row> </tbody> </tgroup> </table> </section> <section id="fiber.custom"> <title><anchor id="custom"/><link linkend="fiber.custom">Customization</link></title> <bridgehead renderas="sect3" id="fiber.custom.h0"> <phrase id="fiber.custom.overview"/><link linkend="fiber.custom.overview">Overview</link> </bridgehead> <para> As noted in the <link linkend="scheduling">Scheduling</link> section, by default <emphasis role="bold">Boost.Fiber</emphasis> uses its own <link linkend="class_round_robin"><code>round_robin</code></link> scheduler for each thread. To control the way <emphasis role="bold">Boost.Fiber</emphasis> schedules ready fibers on a particular thread, in general you must follow several steps. This section discusses those steps, whereas <link linkend="scheduling">Scheduling</link> serves as a reference for the classes involved. </para> <para> The library's fiber manager keeps track of suspended (blocked) fibers. Only when a fiber becomes ready to run is it passed to the scheduler. Of course, if there are fewer than two ready fibers, the scheduler's job is trivial. Only when there are two or more ready fibers does the particular scheduler implementation start to influence the overall sequence of fiber execution. </para> <para> In this section we illustrate a simple custom scheduler that honors an integer fiber priority. We will implement it such that a fiber with higher priority is preferred over a fiber with lower priority. Any fibers with equal priority values are serviced on a round-robin basis. </para> <para> The full source code for the examples below is found in <ulink url="../../examples/priority.cpp">priority.cpp</ulink>. </para> <bridgehead renderas="sect3" id="fiber.custom.h1"> <phrase id="fiber.custom.custom_property_class"/><link linkend="fiber.custom.custom_property_class">Custom Property Class</link> </bridgehead> <para> The first essential point is that we must associate an integer priority with each fiber.<footnote id="fiber.custom.f0"> <para> A previous version of the Fiber library implicitly tracked an int priority for each fiber, even though the default scheduler ignored it. This has been dropped, since the library now supports arbitrary scheduler-specific fiber properties. </para> </footnote> </para> <para> One might suggest deriving a custom <link linkend="class_fiber"><code>fiber</code></link> subclass to store such properties. There are a couple of reasons for the present mechanism. </para> <orderedlist> <listitem> <simpara> <emphasis role="bold">Boost.Fiber</emphasis> provides a number of different ways to launch a fiber. (Consider <link linkend="fibers_async"><code>fibers::async()</code></link>.) Higher-level libraries might introduce additional such wrapper functions. A custom scheduler must associate its custom properties with <emphasis>every</emphasis> fiber in the thread, not only the ones explicitly launched by instantiating a custom <code><phrase role="identifier">fiber</phrase></code> subclass. </simpara> </listitem> <listitem> <simpara> Consider a large existing program that launches fibers in many different places in the code. We discover a need to introduce a custom scheduler for a particular thread. If supporting that scheduler's custom properties required a particular <code><phrase role="identifier">fiber</phrase></code> subclass, we would have to hunt down and modify every place that launches a fiber on that thread. </simpara> </listitem> <listitem> <simpara> The <link linkend="class_fiber"><code>fiber</code></link> class is actually just a handle to internal <link linkend="class_context"><code>context</code></link> data. A subclass of <code><phrase role="identifier">fiber</phrase></code> would not add data to <code><phrase role="identifier">context</phrase></code>. </simpara> </listitem> </orderedlist> <para> The present mechanism allows you to <quote>drop in</quote> a custom scheduler with its attendant custom properties <emphasis>without</emphasis> altering the rest of your application. </para> <para> Instead of deriving a custom scheduler fiber properties subclass from <link linkend="class_fiber"><code>fiber</code></link>, you must instead derive it from <link linkend="class_fiber_properties"><code>fiber_properties</code></link>. </para> <para> <programlisting><phrase role="keyword">class</phrase> <phrase role="identifier">priority_props</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber_properties</phrase> <phrase role="special">{</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="identifier">priority_props</phrase><phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">ctx</phrase><phrase role="special">):</phrase> <phrase role="identifier">fiber_properties</phrase><phrase role="special">(</phrase> <phrase role="identifier">ctx</phrase><phrase role="special">),</phrase> <co id="fiber.custom.c0" linkends="fiber.custom.c1" /> <phrase role="identifier">priority_</phrase><phrase role="special">(</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="special">}</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">get_priority</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">priority_</phrase><phrase role="special">;</phrase> <co id="fiber.custom.c2" linkends="fiber.custom.c3" /> <phrase role="special">}</phrase> <phrase role="comment">// Call this method to alter priority, because we must notify</phrase> <phrase role="comment">// priority_scheduler of any change.</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">set_priority</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">p</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <co id="fiber.custom.c4" linkends="fiber.custom.c5" /> <phrase role="comment">// Of course, it's only worth reshuffling the queue and all if we're</phrase> <phrase role="comment">// actually changing the priority.</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">p</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">priority_</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">priority_</phrase> <phrase role="special">=</phrase> <phrase role="identifier">p</phrase><phrase role="special">;</phrase> <phrase role="identifier">notify</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> <phrase role="comment">// The fiber name of course is solely for purposes of this example</phrase> <phrase role="comment">// program; it has nothing to do with implementing scheduler priority.</phrase> <phrase role="comment">// This is a public data member -- not requiring set/get access methods --</phrase> <phrase role="comment">// because we need not inform the scheduler of any change.</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">name</phrase><phrase role="special">;</phrase> <co id="fiber.custom.c6" linkends="fiber.custom.c7" /> <phrase role="keyword">private</phrase><phrase role="special">:</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">priority_</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> </programlisting> </para> <calloutlist> <callout arearefs="fiber.custom.c0" id="fiber.custom.c1"> <para> Your subclass constructor must accept a <literal><link linkend="class_context"><code>context</code></link>*</literal> and pass it to the <code><phrase role="identifier">fiber_properties</phrase></code> constructor. </para> </callout> <callout arearefs="fiber.custom.c2" id="fiber.custom.c3"> <para> Provide read access methods at your own discretion. </para> </callout> <callout arearefs="fiber.custom.c4" id="fiber.custom.c5"> <para> It's important to call <code><phrase role="identifier">notify</phrase><phrase role="special">()</phrase></code> on any change in a property that can affect the scheduler's behavior. Therefore, such modifications should only be performed through an access method. </para> </callout> <callout arearefs="fiber.custom.c6" id="fiber.custom.c7"> <para> A property that does not affect the scheduler does not need access methods. </para> </callout> </calloutlist> <bridgehead renderas="sect3" id="fiber.custom.h2"> <phrase id="fiber.custom.custom_scheduler_class"/><link linkend="fiber.custom.custom_scheduler_class">Custom Scheduler Class</link> </bridgehead> <para> Now we can derive a custom scheduler from <link linkend="class_algorithm_with_properties"><code>algorithm_with_properties&lt;&gt;</code></link>, specifying our custom property class <code><phrase role="identifier">priority_props</phrase></code> as the template parameter. </para> <para> <programlisting><phrase role="keyword">class</phrase> <phrase role="identifier">priority_scheduler</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">algo</phrase><phrase role="special">::</phrase><phrase role="identifier">algorithm_with_properties</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">priority_props</phrase> <phrase role="special">&gt;</phrase> <phrase role="special">{</phrase> <phrase role="keyword">private</phrase><phrase role="special">:</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">scheduler</phrase><phrase role="special">::</phrase><phrase role="identifier">ready_queue_type</phrase><co id="fiber.custom.c8" linkends="fiber.custom.c9" /> <phrase role="identifier">rqueue_t</phrase><phrase role="special">;</phrase> <phrase role="identifier">rqueue_t</phrase> <phrase role="identifier">rqueue_</phrase><phrase role="special">;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">mutex</phrase> <phrase role="identifier">mtx_</phrase><phrase role="special">{};</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_variable</phrase> <phrase role="identifier">cnd_</phrase><phrase role="special">{};</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">flag_</phrase><phrase role="special">{</phrase> <phrase role="keyword">false</phrase> <phrase role="special">};</phrase> <phrase role="keyword">public</phrase><phrase role="special">:</phrase> <phrase role="identifier">priority_scheduler</phrase><phrase role="special">()</phrase> <phrase role="special">:</phrase> <phrase role="identifier">rqueue_</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase> <phrase role="special">}</phrase> <phrase role="comment">// For a subclass of algorithm_with_properties&lt;&gt;, it's important to</phrase> <phrase role="comment">// override the correct awakened() overload.</phrase> <co id="fiber.custom.c10" linkends="fiber.custom.c11" /><phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">awakened</phrase><phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">ctx</phrase><phrase role="special">,</phrase> <phrase role="identifier">priority_props</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">props</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">{</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">ctx_priority</phrase> <phrase role="special">=</phrase> <phrase role="identifier">props</phrase><phrase role="special">.</phrase><phrase role="identifier">get_priority</phrase><phrase role="special">();</phrase> <co id="fiber.custom.c12" linkends="fiber.custom.c13" /> <phrase role="comment">// With this scheduler, fibers with higher priority values are</phrase> <phrase role="comment">// preferred over fibers with lower priority values. But fibers with</phrase> <phrase role="comment">// equal priority values are processed in round-robin fashion. So when</phrase> <phrase role="comment">// we're handed a new context*, put it at the end of the fibers</phrase> <phrase role="comment">// with that same priority. In other words: search for the first fiber</phrase> <phrase role="comment">// in the queue with LOWER priority, and insert before that one.</phrase> <phrase role="identifier">rqueue_t</phrase><phrase role="special">::</phrase><phrase role="identifier">iterator</phrase> <phrase role="identifier">i</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">find_if</phrase><phrase role="special">(</phrase> <phrase role="identifier">rqueue_</phrase><phrase role="special">.</phrase><phrase role="identifier">begin</phrase><phrase role="special">(),</phrase> <phrase role="identifier">rqueue_</phrase><phrase role="special">.</phrase><phrase role="identifier">end</phrase><phrase role="special">(),</phrase> <phrase role="special">[</phrase><phrase role="identifier">ctx_priority</phrase><phrase role="special">,</phrase><phrase role="keyword">this</phrase><phrase role="special">](</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">context</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">c</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">properties</phrase><phrase role="special">(</phrase> <phrase role="special">&amp;</phrase><phrase role="identifier">c</phrase> <phrase role="special">).</phrase><phrase role="identifier">get_priority</phrase><phrase role="special">()</phrase> <phrase role="special">&lt;</phrase> <phrase role="identifier">ctx_priority</phrase><phrase role="special">;</phrase> <phrase role="special">}));</phrase> <phrase role="comment">// Now, whether or not we found a fiber with lower priority,</phrase> <phrase role="comment">// insert this new fiber here.</phrase> <phrase role="identifier">rqueue_</phrase><phrase role="special">.</phrase><phrase role="identifier">insert</phrase><phrase role="special">(</phrase> <phrase role="identifier">i</phrase><phrase role="special">,</phrase> <phrase role="special">*</phrase> <phrase role="identifier">ctx</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <co id="fiber.custom.c14" linkends="fiber.custom.c15" /><phrase role="keyword">virtual</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">pick_next</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">{</phrase> <phrase role="comment">// if ready queue is empty, just tell caller</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="identifier">rqueue_</phrase><phrase role="special">.</phrase><phrase role="identifier">empty</phrase><phrase role="special">()</phrase> <phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="keyword">nullptr</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">ctx</phrase><phrase role="special">(</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">rqueue_</phrase><phrase role="special">.</phrase><phrase role="identifier">front</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase> <phrase role="identifier">rqueue_</phrase><phrase role="special">.</phrase><phrase role="identifier">pop_front</phrase><phrase role="special">();</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">ctx</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <co id="fiber.custom.c16" linkends="fiber.custom.c17" /><phrase role="keyword">virtual</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">has_ready_fibers</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">{</phrase> <phrase role="keyword">return</phrase> <phrase role="special">!</phrase> <phrase role="identifier">rqueue_</phrase><phrase role="special">.</phrase><phrase role="identifier">empty</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <co id="fiber.custom.c18" linkends="fiber.custom.c19" /><phrase role="keyword">virtual</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">property_change</phrase><phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">context</phrase> <phrase role="special">*</phrase> <phrase role="identifier">ctx</phrase><phrase role="special">,</phrase> <phrase role="identifier">priority_props</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">props</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">{</phrase> <phrase role="comment">// Although our priority_props class defines multiple properties, only</phrase> <phrase role="comment">// one of them (priority) actually calls notify() when changed. The</phrase> <phrase role="comment">// point of a property_change() override is to reshuffle the ready</phrase> <phrase role="comment">// queue according to the updated priority value.</phrase> <phrase role="comment">// 'ctx' might not be in our queue at all, if caller is changing the</phrase> <phrase role="comment">// priority of (say) the running fiber. If it's not there, no need to</phrase> <phrase role="comment">// move it: we'll handle it next time it hits awakened().</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="special">!</phrase> <phrase role="identifier">ctx</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">ready_is_linked</phrase><phrase role="special">())</phrase> <phrase role="special">{</phrase> <co id="fiber.custom.c20" linkends="fiber.custom.c21" /> <phrase role="keyword">return</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="comment">// Found ctx: unlink it</phrase> <phrase role="identifier">ctx</phrase><phrase role="special">-&gt;</phrase><phrase role="identifier">ready_unlink</phrase><phrase role="special">();</phrase> <phrase role="comment">// Here we know that ctx was in our ready queue, but we've unlinked</phrase> <phrase role="comment">// it. We happen to have a method that will (re-)add a context* to the</phrase> <phrase role="comment">// right place in the ready queue.</phrase> <phrase role="identifier">awakened</phrase><phrase role="special">(</phrase> <phrase role="identifier">ctx</phrase><phrase role="special">,</phrase> <phrase role="identifier">props</phrase><phrase role="special">);</phrase> <phrase role="special">}</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">suspend_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">steady_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">time_point</phrase><phrase role="special">)</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">{</phrase> <phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="special">(</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">chrono</phrase><phrase role="special">::</phrase><phrase role="identifier">steady_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">time_point</phrase><phrase role="special">::</phrase><phrase role="identifier">max</phrase><phrase role="special">)()</phrase> <phrase role="special">==</phrase> <phrase role="identifier">time_point</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">unique_lock</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">mutex</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">lk</phrase><phrase role="special">(</phrase> <phrase role="identifier">mtx_</phrase><phrase role="special">);</phrase> <phrase role="identifier">cnd_</phrase><phrase role="special">.</phrase><phrase role="identifier">wait</phrase><phrase role="special">(</phrase> <phrase role="identifier">lk</phrase><phrase role="special">,</phrase> <phrase role="special">[</phrase><phrase role="keyword">this</phrase><phrase role="special">](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">flag_</phrase><phrase role="special">;</phrase> <phrase role="special">});</phrase> <phrase role="identifier">flag_</phrase> <phrase role="special">=</phrase> <phrase role="keyword">false</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="keyword">else</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">unique_lock</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">mutex</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">lk</phrase><phrase role="special">(</phrase> <phrase role="identifier">mtx_</phrase><phrase role="special">);</phrase> <phrase role="identifier">cnd_</phrase><phrase role="special">.</phrase><phrase role="identifier">wait_until</phrase><phrase role="special">(</phrase> <phrase role="identifier">lk</phrase><phrase role="special">,</phrase> <phrase role="identifier">time_point</phrase><phrase role="special">,</phrase> <phrase role="special">[</phrase><phrase role="keyword">this</phrase><phrase role="special">](){</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">flag_</phrase><phrase role="special">;</phrase> <phrase role="special">});</phrase> <phrase role="identifier">flag_</phrase> <phrase role="special">=</phrase> <phrase role="keyword">false</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> <phrase role="special">}</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">notify</phrase><phrase role="special">()</phrase> <phrase role="keyword">noexcept</phrase> <phrase role="special">{</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">unique_lock</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">mutex</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">lk</phrase><phrase role="special">(</phrase> <phrase role="identifier">mtx_</phrase><phrase role="special">);</phrase> <phrase role="identifier">flag_</phrase> <phrase role="special">=</phrase> <phrase role="keyword">true</phrase><phrase role="special">;</phrase> <phrase role="identifier">lk</phrase><phrase role="special">.</phrase><phrase role="identifier">unlock</phrase><phrase role="special">();</phrase> <phrase role="identifier">cnd_</phrase><phrase role="special">.</phrase><phrase role="identifier">notify_all</phrase><phrase role="special">();</phrase> <phrase role="special">}</phrase> <phrase role="special">};</phrase> </programlisting> </para> <calloutlist> <callout arearefs="fiber.custom.c8" id="fiber.custom.c9"> <para> See <link linkend="ready_queue_t">ready_queue_t</link>. </para> </callout> <callout arearefs="fiber.custom.c10" id="fiber.custom.c11"> <para> You must override the <link linkend="algorithm_with_properties_awakened"><code>algorithm_with_properties::awakened()</code></link> method. This is how your scheduler receives notification of a fiber that has become ready to run. </para> </callout> <callout arearefs="fiber.custom.c12" id="fiber.custom.c13"> <para> <code><phrase role="identifier">props</phrase></code> is the instance of priority_props associated with the passed fiber <code><phrase role="identifier">ctx</phrase></code>. </para> </callout> <callout arearefs="fiber.custom.c14" id="fiber.custom.c15"> <para> You must override the <link linkend="algorithm_with_properties_pick_next"><code>algorithm_with_properties::pick_next()</code></link> method. This is how your scheduler actually advises the fiber manager of the next fiber to run. </para> </callout> <callout arearefs="fiber.custom.c16" id="fiber.custom.c17"> <para> You must override <link linkend="algorithm_with_properties_has_ready_fibers"><code>algorithm_with_properties::has_ready_fibers()</code></link> to inform the fiber manager of the state of your ready queue. </para> </callout> <callout arearefs="fiber.custom.c18" id="fiber.custom.c19"> <para> Overriding <link linkend="algorithm_with_properties_property_change"><code>algorithm_with_properties::property_change()</code></link> is optional. This override handles the case in which the running fiber changes the priority of another ready fiber: a fiber already in our queue. In that case, move the updated fiber within the queue. </para> </callout> <callout arearefs="fiber.custom.c20" id="fiber.custom.c21"> <para> Your <code><phrase role="identifier">property_change</phrase><phrase role="special">()</phrase></code> override must be able to handle the case in which the passed <code><phrase role="identifier">ctx</phrase></code> is not in your ready queue. It might be running, or it might be blocked. </para> </callout> </calloutlist> <para> Our example <code><phrase role="identifier">priority_scheduler</phrase></code> doesn't override <link linkend="algorithm_with_properties_new_properties"><code>algorithm_with_properties::new_properties()</code></link>: we're content with allocating <code><phrase role="identifier">priority_props</phrase></code> instances on the heap. </para> <bridgehead renderas="sect3" id="fiber.custom.h3"> <phrase id="fiber.custom.replace_default_scheduler"/><link linkend="fiber.custom.replace_default_scheduler">Replace Default Scheduler</link> </bridgehead> <para> You must call <link linkend="use_scheduling_algorithm"><code>use_scheduling_algorithm()</code></link> at the start of each thread on which you want <emphasis role="bold">Boost.Fiber</emphasis> to use your custom scheduler rather than its own default <link linkend="class_round_robin"><code>round_robin</code></link>. Specifically, you must call <code><phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">()</phrase></code> before performing any other <emphasis role="bold">Boost.Fiber</emphasis> operations on that thread. </para> <para> <programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">argc</phrase><phrase role="special">,</phrase> <phrase role="keyword">char</phrase> <phrase role="special">*</phrase><phrase role="identifier">argv</phrase><phrase role="special">[])</phrase> <phrase role="special">{</phrase> <phrase role="comment">// make sure we use our priority_scheduler rather than default round_robin</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">use_scheduling_algorithm</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">priority_scheduler</phrase> <phrase role="special">&gt;();</phrase> <phrase role="special">...</phrase> <phrase role="special">}</phrase> </programlisting> </para> <bridgehead renderas="sect3" id="fiber.custom.h4"> <phrase id="fiber.custom.use_properties"/><link linkend="fiber.custom.use_properties">Use Properties</link> </bridgehead> <para> The running fiber can access its own <link linkend="class_fiber_properties"><code>fiber_properties</code></link> subclass instance by calling <link linkend="this_fiber_properties"><code>this_fiber::properties()</code></link>. Although <code><phrase role="identifier">properties</phrase><phrase role="special">&lt;&gt;()</phrase></code> is a nullary function, you must pass, as a template parameter, the <code><phrase role="identifier">fiber_properties</phrase></code> subclass. </para> <para> <programlisting><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">this_fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">properties</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">priority_props</phrase> <phrase role="special">&gt;().</phrase><phrase role="identifier">name</phrase> <phrase role="special">=</phrase> <phrase role="string">&quot;main&quot;</phrase><phrase role="special">;</phrase> </programlisting> </para> <para> Given a <link linkend="class_fiber"><code>fiber</code></link> instance still connected with a running fiber (that is, not <link linkend="fiber_detach"><code>fiber::detach()</code></link>ed), you may access that fiber's properties using <link linkend="fiber_properties"><code>fiber::properties()</code></link>. As with <code><phrase role="identifier">this_fiber</phrase><phrase role="special">::</phrase><phrase role="identifier">properties</phrase><phrase role="special">&lt;&gt;()</phrase></code>, you must pass your <code><phrase role="identifier">fiber_properties</phrase></code> subclass as the template parameter. </para> <para> <programlisting><phrase role="keyword">template</phrase><phrase role="special">&lt;</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase> <phrase role="identifier">launch</phrase><phrase role="special">(</phrase> <phrase role="identifier">Fn</phrase> <phrase role="special">&amp;&amp;</phrase> <phrase role="identifier">func</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="keyword">const</phrase><phrase role="special">&amp;</phrase> <phrase role="identifier">name</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">priority</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">fibers</phrase><phrase role="special">::</phrase><phrase role="identifier">fiber</phrase> <phrase role="identifier">fiber</phrase><phrase role="special">(</phrase> <phrase role="identifier">func</phrase><phrase role="special">);</phrase> <phrase role="identifier">priority_props</phrase> <phrase role="special">&amp;</phrase> <phrase role="identifier">props</phrase><phrase role="special">(</phrase> <phrase role="identifier">fiber</phrase><phrase role="special">.</phrase><phrase role="identifier">properties</phrase><phrase role="special">&lt;</phrase> <phrase role="identifier">priority_props</phrase> <phrase role="special">&gt;()</phrase> <phrase role="special">);</phrase> <phrase role="identifier">props</phrase><phrase role="special">.</phrase><phrase role="identifier">name</phrase> <phrase role="special">=</phrase> <phrase role="identifier">name</phrase><phrase role="special">;</phrase> <phrase role="identifier">props</phrase><phrase role="special">.</phrase><phrase role="identifier">set_priority</phrase><phrase role="special">(</phrase> <phrase role="identifier">priority</phrase><phrase role="special">);</phrase> <phrase role="keyword">return</phrase> <phrase role="identifier">fiber</phrase><phrase role="special">;</phrase> <phrase role="special">}</phrase> </programlisting> </para> <para> Launching a new fiber schedules that fiber as ready, but does <emphasis>not</emphasis> immediately enter its <emphasis>fiber-function</emphasis>. The current fiber retains control until it blocks (or yields, or terminates) for some other reason. As shown in the <code><phrase role="identifier">launch</phrase><phrase role="special">()</phrase></code> function above, it is reasonable to launch a fiber and immediately set relevant properties -- such as, for instance, its priority. Your custom scheduler can then make use of this information next time the fiber manager calls <link linkend="algorithm_with_properties_pick_next"><code>algorithm_with_properties::pick_next()</code></link>. </para> </section> <section id="fiber.rationale"> <title><link linkend="fiber.rationale">Rationale</link></title> <bridgehead renderas="sect3" id="fiber.rationale.h0"> <phrase id="fiber.rationale.preprocessor_defines"/><link linkend="fiber.rationale.preprocessor_defines">preprocessor defines</link> </bridgehead> <table frame="all" id="fiber.rationale.preopcessor_defines"> <title>preopcessor defines</title> <tgroup cols="2"> <thead> <row> <entry> </entry> <entry> </entry> </row> </thead> <tbody> <row> <entry> <para> BOOST_FIBERS_NO_ATOMICS </para> </entry> <entry> <para> no <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">atomic</phrase><phrase role="special">&lt;&gt;</phrase></code> used, inter-thread synchronization disabled </para> </entry> </row> <row> <entry> <para> BOOST_FIBERS_SPINLOCK_STD_MUTEX </para> </entry> <entry> <para> use <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">mutex</phrase></code> as spinlock instead of default <code><phrase role="identifier">XCHG</phrase></code>-sinlock with backoff </para> </entry> </row> <row> <entry> <para> BOOST_FIBERS_SPIN_BACKOFF </para> </entry> <entry> <para> limit determines when to used <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase role="identifier">yield</phrase><phrase role="special">()</phrase></code> instead of mnemonic <code><phrase role="identifier">pause</phrase><phrase role="special">/</phrase><phrase role="identifier">yield</phrase></code> during busy wait (apllies on to <code><phrase role="identifier">XCHG</phrase></code>-spinlock) </para> </entry> </row> <row> <entry> <para> BOOST_FIBERS_SINGLE_CORE </para> </entry> <entry> <para> allways call <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">this_thread</phrase><phrase role="special">::</phrase><phrase role="identifier">yield</phrase><phrase role="special">()</phrase></code> without backoff during busy wait (apllies on to <code><phrase role="identifier">XCHG</phrase></code>-spinlock) </para> </entry> </row> </tbody> </tgroup> </table> <bridgehead renderas="sect3" id="fiber.rationale.h1"> <phrase id="fiber.rationale.distinction_between_coroutines_and_fibers"/><link linkend="fiber.rationale.distinction_between_coroutines_and_fibers">distinction between coroutines and fibers</link> </bridgehead> <para> The fiber library extends the coroutine library by adding a scheduler and synchronization mechanisms. </para> <itemizedlist> <listitem> <simpara> a coroutine yields </simpara> </listitem> <listitem> <simpara> a fiber blocks </simpara> </listitem> </itemizedlist> <para> When a coroutine yields, it passes control directly to its caller (or, in the case of symmetric coroutines, a designated other coroutine). When a fiber blocks, it implicitly passes control to the fiber scheduler. Coroutines have no scheduler because they need no scheduler.<footnote id="fiber.rationale.f0"> <para> <ulink url="path_to_url">'N4024: Distinguishing coroutines and fibers'</ulink> </para> </footnote>. </para> <bridgehead renderas="sect3" id="fiber.rationale.h2"> <phrase id="fiber.rationale.what_about_transactional_memory"/><link linkend="fiber.rationale.what_about_transactional_memory">what about transactional memory</link> </bridgehead> <para> GCC supports transactional memory since version 4.7. Unfortunately tests show that transactional memory is slower (ca. 4x) than spinlocks using atomics. Once transactional memory is improved (supporting hybrid tm), spinlocks will be replaced by __transaction_atomic{} statements surrounding the critical sections. </para> <bridgehead renderas="sect3" id="fiber.rationale.h3"> <phrase id="fiber.rationale.synchronization_between_fibers_running_in_different_threads"/><link linkend="fiber.rationale.synchronization_between_fibers_running_in_different_threads">synchronization between fibers running in different threads</link> </bridgehead> <para> Synchronization classes from <ulink url="path_to_url">Boost.Thread</ulink> block the entire thread. In contrast, the synchronization classes from <emphasis role="bold">Boost.Fiber</emphasis> block only specific fibers, so that the scheduler can still keep the thread busy running other fibers in the meantime. The synchronization classes from <emphasis role="bold">Boost.Fiber</emphasis> are designed to be thread-safe, i.e. it is possible to synchronize fibers running in different threads as well as fibers running in the same thread. (However, there is a build option to disable cross-thread fiber synchronization support; see <link linkend="cross_thread_sync">this description</link>.) </para> <anchor id="spurious_wakeup"/> <bridgehead renderas="sect3" id="fiber.rationale.h4"> <phrase id="fiber.rationale.spurious_wakeup"/><link linkend="fiber.rationale.spurious_wakeup">spurious wakeup</link> </bridgehead> <para> Spurious wakeup can happen when using <ulink url="path_to_url"><code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_variable</phrase></code></ulink>: the condition variable appears to be have been signaled while the awaited condition may still be false. Spurious wakeup can happen repeatedly and is caused on some multiprocessor systems where making <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_variable</phrase></code> wakeup completely predictable would slow down all <code><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">condition_variable</phrase></code> operations.<footnote id="fiber.rationale.f1"> <para> David R. Butenhof <quote>Programming with POSIX Threads</quote> </para> </footnote> </para> <para> <link linkend="class_condition_variable"><code>condition_variable</code></link> is not subject to spurious wakeup. Nonetheless it is prudent to test the business-logic condition in a <code><phrase role="identifier">wait</phrase><phrase role="special">()</phrase></code> loop &mdash; or, equivalently, use one of the <code><phrase role="identifier">wait</phrase><phrase role="special">(</phrase> <phrase role="identifier">lock</phrase><phrase role="special">,</phrase> <phrase role="identifier">predicate</phrase> <phrase role="special">)</phrase></code> overloads. </para> <para> See also <link linkend="condition_variable_spurious_wakeups">No Spurious Wakeups</link>. </para> <bridgehead renderas="sect3" id="fiber.rationale.h5"> <phrase id="fiber.rationale.migrating_fibers_between_threads"/><link linkend="fiber.rationale.migrating_fibers_between_threads">migrating fibers between threads</link> </bridgehead> <para> Support for migrating fibers between threads has been integrated. The user-defined scheduler must call <link linkend="context_detach"><code>context::detach()</code></link> on a fiber-context on the source thread and <link linkend="context_attach"><code>context::attach()</code></link> on the destination thread, passing the fiber-context to migrate. (For more information about custom schedulers, see <link linkend="custom">Customization</link>.) Examples <code><phrase role="identifier">work_sharing</phrase></code> and <code><phrase role="identifier">work_stealing</phrase></code> in directory <code><phrase role="identifier">examples</phrase></code> might be used as a blueprint. </para> <para> See also <link linkend="migration">Migrating fibers between threads</link>. </para> <bridgehead renderas="sect3" id="fiber.rationale.h6"> <phrase id="fiber.rationale.support_for_boost_asio"/><link linkend="fiber.rationale.support_for_boost_asio">support for Boost.Asio</link> </bridgehead> <para> Support for <ulink url="path_to_url">Boost.Asio</ulink>&#8217;s <emphasis>async-result</emphasis> is not part of the official API. However, to integrate with a <ulink url="path_to_url"><code><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">asio</phrase><phrase role="special">::</phrase><phrase role="identifier">io_service</phrase></code></ulink>, see <link linkend="integration">Sharing a Thread with Another Main Loop</link>. To interface smoothly with an arbitrary Asio async I/O operation, see <link linkend="callbacks_asio">Then There&#8217;s <ulink url="path_to_url">Boost.Asio</ulink></link>. </para> <bridgehead renderas="sect3" id="fiber.rationale.h7"> <phrase id="fiber.rationale.tested_compilers"/><link linkend="fiber.rationale.tested_compilers">tested compilers</link> </bridgehead> <para> The library was tested with GCC-5.1.1, Clang-3.6.0 and MSVC-14.0 in c++11-mode. </para> <bridgehead renderas="sect3" id="fiber.rationale.h8"> <phrase id="fiber.rationale.supported_architectures"/><link linkend="fiber.rationale.supported_architectures">supported architectures</link> </bridgehead> <para> <emphasis role="bold">Boost.Fiber</emphasis> depends on <ulink url="path_to_url">Boost.Context</ulink> - the list of supported architectures can be found <ulink url="path_to_url">here</ulink>. </para> </section> <section id="fiber.acknowledgements"> <title><link linkend="fiber.acknowledgements">Acknowledgments</link></title> <para> I'd like to thank Agustn Berg, Eugene Yakubovich, Giovanni Piero Deretta and especially Nat Goodspeed. </para> </section> <section id="fiber.installing"> <title><link linkend="fiber.installing">Appendix: Installing and Running Tests</link></title> <bridgehead renderas="sect3" id="fiber.installing.h0"> <phrase id="fiber.installing.installing_the_fiber_library"/><link linkend="fiber.installing.installing_the_fiber_library">Installing the Fiber library</link> </bridgehead> <para> As Fiber is not yet officially part of Boost, it is necessary to embed it in an existing <ulink url="path_to_url">Boost source tree</ulink>. </para> <para> The <ulink url="path_to_url">downloaded Fiber library</ulink> can be placed into an existing Boost source tree by moving the top-level Fiber directory to <code><phrase role="identifier">libs</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase></code> under the top-level Boost directory, then further moving <code><phrase role="identifier">libs</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">include</phrase><phrase role="special">/</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase></code> (in other words, the Fiber library's <code><phrase role="identifier">include</phrase><phrase role="special">/</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase></code> directory) to <code><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase></code> under the top-level Boost directory. </para> <para> On a Posix system such as Linux or OS X, you may use symlinks instead. </para> <para> Create a symlink from the Boost directory's <code><phrase role="identifier">libs</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase></code> to the top-level Fiber directory, e.g.: </para> <programlisting><phrase role="identifier">cd</phrase> <phrase role="special">~/</phrase><phrase role="identifier">boost_1_61_0</phrase> <phrase role="identifier">ln</phrase> <phrase role="special">-</phrase><phrase role="identifier">s</phrase> <phrase role="special">~/</phrase><phrase role="identifier">boost</phrase><phrase role="special">-</phrase><phrase role="identifier">fiber</phrase><phrase role="special">-</phrase><phrase role="identifier">master</phrase> <phrase role="identifier">libs</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase> </programlisting> <para> Then create a symlink from the Boost directory's <code><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase></code> to the Fiber library's <code><phrase role="identifier">include</phrase><phrase role="special">/</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase></code> directory: </para> <programlisting><phrase role="identifier">cd</phrase> <phrase role="identifier">boost</phrase> <phrase role="identifier">ln</phrase> <phrase role="special">-</phrase><phrase role="identifier">s</phrase> <phrase role="special">../</phrase><phrase role="identifier">libs</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">include</phrase><phrase role="special">/</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase> <phrase role="identifier">fiber</phrase> </programlisting> <para> For some versions of the Boost.Build system, it was important to use a relative symlink of that form for <code><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase></code>. </para> <anchor id="tests"/> <bridgehead renderas="sect3" id="fiber.installing.h1"> <phrase id="fiber.installing.running_tests"/><link linkend="fiber.installing.running_tests">Running Tests</link> </bridgehead> <para> Once the Fiber library has been overlaid (or symlinked) into the Boost source tree this way, the Boost.Build system can build it like any other Boost library. In particular: </para> <programlisting><phrase role="identifier">cd</phrase> <phrase role="special">~/</phrase><phrase role="identifier">boost_1_61_0</phrase> <phrase role="special">./</phrase><phrase role="identifier">bootstrap</phrase><phrase role="special">.</phrase><phrase role="identifier">sh</phrase> <phrase role="special">./</phrase><phrase role="identifier">b2</phrase> <phrase role="identifier">libs</phrase><phrase role="special">/</phrase><phrase role="identifier">fiber</phrase><phrase role="special">/</phrase><phrase role="identifier">test</phrase> </programlisting> <para> On Windows, the commands would look more like: </para> <programlisting><phrase role="identifier">cd</phrase> <phrase role="special">/</phrase><phrase role="identifier">D</phrase> <phrase role="special">%</phrase><phrase role="identifier">HOMEDRIVE</phrase><phrase role="special">%%</phrase><phrase role="identifier">HOMEPATH</phrase><phrase role="special">%\</phrase><phrase role="identifier">boost_1_61_0</phrase> <phrase role="identifier">bootstrap</phrase> <phrase role="identifier">b2</phrase> <phrase role="identifier">libs</phrase><phrase role="special">\</phrase><phrase role="identifier">fiber</phrase><phrase role="special">\</phrase><phrase role="identifier">test</phrase> </programlisting> </section> </library> ```
/content/code_sandbox/deps/boost_1_66_0/libs/fiber/doc/fibers.xml
xml
2016-09-05T10:18:44
2024-08-11T13:21:40
LiquidCore
LiquidPlayer/LiquidCore
1,010
307,337
```xml /* * @license Apache-2.0 * * * * path_to_url * * Unless required by applicable law or agreed to in writing, software * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ import ddeg2rad = require( './index' ); // TESTS // // The function returns a Float64Array... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); ddeg2rad( x.length, x, 1, y, 1 ); // $ExpectType Float64Array } // The compiler throws an error if the function is provided a first argument which is not a number... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); ddeg2rad( '10', x, 1, y, 1 ); // $ExpectError ddeg2rad( true, x, 1, y, 1 ); // $ExpectError ddeg2rad( false, x, 1, y, 1 ); // $ExpectError ddeg2rad( null, x, 1, y, 1 ); // $ExpectError ddeg2rad( undefined, x, 1, y, 1 ); // $ExpectError ddeg2rad( [], x, 1, y, 1 ); // $ExpectError ddeg2rad( {}, x, 1, y, 1 ); // $ExpectError ddeg2rad( ( x: number ): number => x, x, 1, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Float64Array... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); ddeg2rad( x.length, 10, 1, y, 1 ); // $ExpectError ddeg2rad( x.length, '10', 1, y, 1 ); // $ExpectError ddeg2rad( x.length, true, 1, y, 1 ); // $ExpectError ddeg2rad( x.length, false, 1, y, 1 ); // $ExpectError ddeg2rad( x.length, null, 1, y, 1 ); // $ExpectError ddeg2rad( x.length, undefined, 1, y, 1 ); // $ExpectError ddeg2rad( x.length, [ '1' ], 1, y, 1 ); // $ExpectError ddeg2rad( x.length, {}, 1, y, 1 ); // $ExpectError ddeg2rad( x.length, ( x: number ): number => x, 1, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); ddeg2rad( x.length, x, '10', y, 1 ); // $ExpectError ddeg2rad( x.length, x, true, y, 1 ); // $ExpectError ddeg2rad( x.length, x, false, y, 1 ); // $ExpectError ddeg2rad( x.length, x, null, y, 1 ); // $ExpectError ddeg2rad( x.length, x, undefined, y, 1 ); // $ExpectError ddeg2rad( x.length, x, [], y, 1 ); // $ExpectError ddeg2rad( x.length, x, {}, y, 1 ); // $ExpectError ddeg2rad( x.length, x, ( x: number ): number => x, y, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... { const x = new Float64Array( 10 ); ddeg2rad( x.length, x, 1, 10, 1 ); // $ExpectError ddeg2rad( x.length, x, 1, '10', 1 ); // $ExpectError ddeg2rad( x.length, x, 1, true, 1 ); // $ExpectError ddeg2rad( x.length, x, 1, false, 1 ); // $ExpectError ddeg2rad( x.length, x, 1, null, 1 ); // $ExpectError ddeg2rad( x.length, x, 1, undefined, 1 ); // $ExpectError ddeg2rad( x.length, x, 1, [ '1' ], 1 ); // $ExpectError ddeg2rad( x.length, x, 1, {}, 1 ); // $ExpectError ddeg2rad( x.length, x, 1, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fifth argument which is not a number... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); ddeg2rad( x.length, x, 1, y, '10' ); // $ExpectError ddeg2rad( x.length, x, 1, y, true ); // $ExpectError ddeg2rad( x.length, x, 1, y, false ); // $ExpectError ddeg2rad( x.length, x, 1, y, null ); // $ExpectError ddeg2rad( x.length, x, 1, y, undefined ); // $ExpectError ddeg2rad( x.length, x, 1, y, [] ); // $ExpectError ddeg2rad( x.length, x, 1, y, {} ); // $ExpectError ddeg2rad( x.length, x, 1, y, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); ddeg2rad(); // $ExpectError ddeg2rad( x.length ); // $ExpectError ddeg2rad( x.length, x ); // $ExpectError ddeg2rad( x.length, x, 1 ); // $ExpectError ddeg2rad( x.length, x, 1, y ); // $ExpectError ddeg2rad( x.length, x, 1, y, 1, 10 ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a Float64Array... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); ddeg2rad.ndarray( x.length, x, 1, 0, y, 1, 0 ); // $ExpectType Float64Array } // The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); ddeg2rad.ndarray( '10', x, 1, 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( true, x, 1, 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( false, x, 1, 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( null, x, 1, 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( undefined, x, 1, 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( [], x, 1, 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( {}, x, 1, 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( ( x: number ): number => x, x, 1, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float64Array... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); ddeg2rad.ndarray( x.length, 10, 1, 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, '10', 1, 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, true, 1, 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, false, 1, 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, null, 1, 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, undefined, 1, 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, [ '1' ], 1, 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, {}, 1, 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, ( x: number ): number => x, 1, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); ddeg2rad.ndarray( x.length, x, '10', 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, true, 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, false, 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, null, 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, undefined, 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, [], 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, {}, 0, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, ( x: number ): number => x, 0, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); ddeg2rad.ndarray( x.length, x, 1, '10', y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, true, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, false, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, null, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, undefined, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, [], y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, {}, y, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, ( x: number ): number => x, y, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a Float64Array... { const x = new Float64Array( 10 ); ddeg2rad.ndarray( x.length, x, 1, 0, 10, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, '10', 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, true, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, false, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, null, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, undefined, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, [ '1' ], 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, {}, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); ddeg2rad.ndarray( x.length, x, 1, 0, y, '10', 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, y, true, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, y, false, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, y, null, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, y, undefined, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, y, [], 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, y, {}, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, y, ( x: number ): number => x, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); ddeg2rad.ndarray( x.length, x, 1, 0, y, 1, '10' ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, y, 1, true ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, y, 1, false ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, y, 1, null ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, y, 1, undefined ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, y, 1, [] ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, y, 1, {} ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, y, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); ddeg2rad.ndarray(); // $ExpectError ddeg2rad.ndarray( x.length ); // $ExpectError ddeg2rad.ndarray( x.length, x ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, y ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, y, 1 ); // $ExpectError ddeg2rad.ndarray( x.length, x, 1, 0, y, 1, 0, 10 ); // $ExpectError } ```
/content/code_sandbox/lib/node_modules/@stdlib/math/strided/special/ddeg2rad/docs/types/test.ts
xml
2016-03-24T04:19:52
2024-08-16T09:03:19
stdlib
stdlib-js/stdlib
4,266
3,837
```xml /** * @license * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ import {setUpFoundationTest} from '../../../testing/helpers/setup'; import {cssClasses} from '../constants'; import {MDCSlidingTabIndicatorFoundation} from '../sliding-foundation'; describe('MDCSlidingTabIndicatorFoundation', () => { const setupTest = () => { const {foundation, mockAdapter} = setUpFoundationTest(MDCSlidingTabIndicatorFoundation); return {foundation, mockAdapter}; }; it(`#activate adds the ${cssClasses.ACTIVE} class`, () => { const {foundation, mockAdapter} = setupTest(); mockAdapter.computeContentClientRect.and.returnValue( // TODO: Wait until b/208710526 is fixed, then remove this autogenerated // error suppression. // @ts-ignore(go/unfork-jasmine-typings): Argument of type '{ width: // number; left: number; }' is not assignable to parameter of type // 'DOMRect'. {width: 100, left: 10}); foundation.activate({width: 90, left: 25} as DOMRect); expect(mockAdapter.addClass).toHaveBeenCalledWith(cssClasses.ACTIVE); }); it('#activate sets the transform property with no transition, then transitions it back', () => { const {foundation, mockAdapter} = setupTest(); mockAdapter.computeContentClientRect.and.returnValue( // TODO: Wait until b/208710526 is fixed, then remove this // autogenerated error suppression. // @ts-ignore(go/unfork-jasmine-typings): Argument of type '{ width: // number; left: number; }' is not assignable to parameter of type // 'DOMRect'. {width: 100, left: 10}); foundation.activate({width: 90, left: 25} as DOMRect); expect(mockAdapter.addClass) .toHaveBeenCalledWith(cssClasses.NO_TRANSITION); expect(mockAdapter.setContentStyleProperty) .toHaveBeenCalledWith('transform', 'translateX(15px) scaleX(0.9)'); expect(mockAdapter.removeClass) .toHaveBeenCalledWith(cssClasses.NO_TRANSITION); expect(mockAdapter.setContentStyleProperty) .toHaveBeenCalledWith('transform', ''); }); it('#activate does not modify transform and does not transition if no client rect is passed', () => { const {foundation, mockAdapter} = setupTest(); foundation.activate(); expect(mockAdapter.setContentStyleProperty) .not.toHaveBeenCalledWith('transform', jasmine.any(String)); }); it(`#deactivate removes the ${cssClasses.ACTIVE} class`, () => { const {foundation, mockAdapter} = setupTest(); foundation.deactivate(); expect(mockAdapter.removeClass).toHaveBeenCalledWith(cssClasses.ACTIVE); }); }); ```
/content/code_sandbox/packages/mdc-tab-indicator/test/sliding-foundation.test.ts
xml
2016-12-05T16:04:09
2024-08-16T15:42:22
material-components-web
material-components/material-components-web
17,119
802
```xml import { describe, expect, it, vi } from 'vitest'; import type { SBType } from '@storybook/core/types'; import { once } from '@storybook/core/client-logger'; import { UNTARGETED, combineArgs, groupArgsByTarget, mapArgsToTypes, validateOptions, } from './args'; const stringType: SBType = { name: 'string' }; const numberType: SBType = { name: 'number' }; const booleanType: SBType = { name: 'boolean' }; const enumType: SBType = { name: 'enum', value: [1, 2, 3] }; const functionType: SBType = { name: 'function' }; const numArrayType: SBType = { name: 'array', value: numberType }; const boolObjectType: SBType = { name: 'object', value: { bool: booleanType } }; vi.mock('@storybook/core/client-logger'); enum ArgsMapTestEnumWithoutInitializer { EnumValue, EnumValue2, } enum ArgsMapTestEnumWithStringInitializer { EnumValue = 'EnumValue', } enum ArgsMapTestEnumWithNumericInitializer { EnumValue = 4, } describe('mapArgsToTypes', () => { it('maps strings', () => { expect(mapArgsToTypes({ a: 'str' }, { a: { type: stringType } })).toStrictEqual({ a: 'str' }); expect(mapArgsToTypes({ a: 42 }, { a: { type: stringType } })).toStrictEqual({ a: '42' }); }); it('maps enums', () => { expect( mapArgsToTypes({ a: ArgsMapTestEnumWithoutInitializer.EnumValue }, { a: { type: enumType } }) ).toEqual({ a: 0 }); expect( mapArgsToTypes({ a: ArgsMapTestEnumWithoutInitializer.EnumValue2 }, { a: { type: enumType } }) ).toEqual({ a: 1 }); expect( mapArgsToTypes( { a: ArgsMapTestEnumWithStringInitializer.EnumValue }, { a: { type: enumType } } ) ).toEqual({ a: 'EnumValue' }); expect( mapArgsToTypes( { a: ArgsMapTestEnumWithNumericInitializer.EnumValue }, { a: { type: enumType } } ) ).toEqual({ a: 4 }); }); it('maps numbers', () => { expect(mapArgsToTypes({ a: '42' }, { a: { type: numberType } })).toStrictEqual({ a: 42 }); expect(mapArgsToTypes({ a: '4.2' }, { a: { type: numberType } })).toStrictEqual({ a: 4.2 }); expect(mapArgsToTypes({ a: 'a' }, { a: { type: numberType } })).toStrictEqual({ a: NaN }); }); it('maps booleans', () => { expect(mapArgsToTypes({ a: true }, { a: { type: booleanType } })).toStrictEqual({ a: true }); expect(mapArgsToTypes({ a: 'true' }, { a: { type: booleanType } })).toStrictEqual({ a: true }); expect(mapArgsToTypes({ a: false }, { a: { type: booleanType } })).toStrictEqual({ a: false, }); expect(mapArgsToTypes({ a: 'yes' }, { a: { type: booleanType } })).toStrictEqual({ a: false }); }); it('maps sparse arrays', () => { expect(mapArgsToTypes({ a: [, '2', undefined] }, { a: { type: numArrayType } })).toStrictEqual({ a: [, 2, undefined], }); }); it('omits functions', () => { expect(mapArgsToTypes({ a: 'something' }, { a: { type: functionType } })).toStrictEqual({}); }); it('includes functions if there is a mapping', () => { expect( mapArgsToTypes( { a: 'something' }, { a: { type: functionType, mapping: { something: () => 'foo' } } } ) ).toStrictEqual({ a: 'something', }); }); it('skips default mapping if there is a user-specified mapping', () => { expect( mapArgsToTypes({ a: 'something' }, { a: { type: numberType, mapping: { something: 10 } } }) ).toStrictEqual({ a: 'something', }); }); it('omits unknown keys', () => { expect(mapArgsToTypes({ a: 'string' }, { b: { type: stringType } })).toStrictEqual({}); }); it('passes through unmodified if no type is specified', () => { expect(mapArgsToTypes({ a: { b: 1 } }, { a: { type: undefined } })).toStrictEqual({ a: { b: 1 }, }); }); it('passes string for object type', () => { expect(mapArgsToTypes({ a: 'A' }, { a: { type: boolObjectType } })).toStrictEqual({ a: 'A' }); }); it('passes number for object type', () => { expect(mapArgsToTypes({ a: 1.2 }, { a: { type: boolObjectType } })).toStrictEqual({ a: 1.2 }); }); it('deeply maps objects', () => { expect( mapArgsToTypes( { key: { arr: ['1', '2'], obj: { bool: true }, }, }, { key: { type: { name: 'object', value: { arr: numArrayType, obj: boolObjectType, }, }, }, } ) ).toStrictEqual({ key: { arr: [1, 2], obj: { bool: true }, }, }); }); it('deeply maps arrays', () => { expect( mapArgsToTypes( { key: [ { arr: ['1', '2'], obj: { bool: true }, }, ], }, { key: { type: { name: 'array', value: { name: 'object', value: { arr: numArrayType, obj: boolObjectType, }, }, }, }, } ) ).toStrictEqual({ key: [ { arr: [1, 2], obj: { bool: true }, }, ], }); }); }); describe('combineArgs', () => { it('merges args', () => { expect(combineArgs({ foo: 1 }, { bar: 2 })).toStrictEqual({ foo: 1, bar: 2 }); }); it('merges sparse arrays', () => { expect(combineArgs({ foo: [1, 2, 3] }, { foo: [, 4, undefined] })).toStrictEqual({ foo: [1, 4], }); }); it('deeply merges args', () => { expect(combineArgs({ foo: { bar: [1, 2], baz: true } }, { foo: { bar: [3] } })).toStrictEqual({ foo: { bar: [3, 2], baz: true }, }); }); it('omits keys with undefined value', () => { expect(combineArgs({ foo: 1 }, { foo: undefined })).toStrictEqual({}); }); }); describe('validateOptions', () => { // path_to_url it('does not set args to `undefined` if they are unset', () => { expect(validateOptions({}, { a: {} })).toStrictEqual({}); }); it('omits arg and warns if value is not one of options', () => { expect(validateOptions({ a: 1 }, { a: { options: [2, 3] } })).toStrictEqual({}); expect(once.warn).toHaveBeenCalledWith( "Received illegal value for 'a'. Supported options: 2, 3" ); }); it('includes arg if value is one of options', () => { expect(validateOptions({ a: 1 }, { a: { options: [1, 2] } })).toStrictEqual({ a: 1 }); }); // path_to_url it('does not set args to `undefined` if they are unset and there are options', () => { expect(validateOptions({}, { a: { options: [2, 3] } })).toStrictEqual({}); }); it('includes arg if value is undefined', () => { expect(validateOptions({ a: undefined }, { a: { options: [1, 2] } })).toStrictEqual({ a: undefined, }); }); it('includes arg if no options are specified', () => { expect(validateOptions({ a: 1 }, { a: {} })).toStrictEqual({ a: 1 }); }); it('ignores options and logs an error if options is not an array', () => { // @ts-expect-error This should give TS error indeed (finally!) expect(validateOptions({ a: 1 }, { a: { options: { 2: 'two' } } })).toStrictEqual({ a: 1 }); expect(once.error).toHaveBeenCalledWith( expect.stringContaining("Invalid argType: 'a.options' should be an array") ); }); it('logs an error if options contains non-primitive values', () => { expect( validateOptions({ a: { one: 1 } }, { a: { options: [{ one: 1 }, { two: 2 }] } }) ).toStrictEqual({ a: { one: 1 } }); expect(once.error).toHaveBeenCalledWith( expect.stringContaining("Invalid argType: 'a.options' should only contain primitives") ); expect(once.warn).not.toHaveBeenCalled(); }); it('supports arrays', () => { expect(validateOptions({ a: [1, 2] }, { a: { options: [1, 2, 3] } })).toStrictEqual({ a: [1, 2], }); expect(validateOptions({ a: [1, 2, 4] }, { a: { options: [2, 3] } })).toStrictEqual({}); expect(once.warn).toHaveBeenCalledWith( "Received illegal value for 'a[0]'. Supported options: 2, 3" ); }); }); describe('groupArgsByTarget', () => { it('groups targeted args', () => { const groups = groupArgsByTarget({ args: { a: 1, b: 2, c: 3 }, argTypes: { a: { name: 'a', target: 'group1' }, b: { name: 'b', target: 'group2' }, c: { name: 'c', target: 'group2' }, }, }); expect(groups).toEqual({ group1: { a: 1, }, group2: { b: 2, c: 3, }, }); }); it('groups non-targetted args into a group with no name', () => { const groups = groupArgsByTarget({ args: { a: 1, b: 2, c: 3 }, argTypes: { a: { name: 'a' }, b: { name: 'b', target: 'group2' }, c: { name: 'c' } }, }); expect(groups).toEqual({ [UNTARGETED]: { a: 1, c: 3, }, group2: { b: 2, }, }); }); }); ```
/content/code_sandbox/code/core/src/preview-api/modules/store/args.test.ts
xml
2016-03-18T04:23:44
2024-08-16T19:22:08
storybook
storybookjs/storybook
83,755
2,569
```xml import { type FC, type PropsWithChildren, createContext, useContext, useMemo } from 'react'; import { useDispatch } from 'react-redux'; import { c } from 'ttag'; import { useBulkSelect } from '@proton/pass/components/Bulk/BulkSelectProvider'; import { VaultSelect, VaultSelectMode, useVaultSelectModalHandles } from '@proton/pass/components/Vault/VaultSelect'; import { useConfirm } from '@proton/pass/hooks/useConfirm'; import { itemBulkDeleteIntent, itemBulkMoveIntent, itemBulkRestoreIntent, itemBulkTrashIntent, itemDeleteIntent, itemMoveIntent, itemRestoreIntent, itemTrashIntent, } from '@proton/pass/store/actions'; import type { BulkSelectionDTO, ItemRevision, MaybeNull } from '@proton/pass/types'; import { uniqueId } from '@proton/pass/utils/string/unique-id'; import { ConfirmMoveItem } from './Actions/ConfirmMoveItem'; import { ConfirmMoveManyItems } from './Actions/ConfirmMoveManyItems'; /** Ongoing: move every item action definition to this * context object. This context should be loosely connected */ type ItemActionsContextType = { delete: (item: ItemRevision) => void; deleteMany: (items: BulkSelectionDTO) => void; move: (item: ItemRevision, mode: VaultSelectMode) => void; moveMany: (items: BulkSelectionDTO) => void; restore: (item: ItemRevision) => void; restoreMany: (items: BulkSelectionDTO) => void; trash: (item: ItemRevision) => void; trashMany: (items: BulkSelectionDTO) => void; }; const ItemActionsContext = createContext<MaybeNull<ItemActionsContextType>>(null); export const ItemActionsProvider: FC<PropsWithChildren> = ({ children }) => { const dispatch = useDispatch(); const bulk = useBulkSelect(); const { closeVaultSelect, openVaultSelect, modalState } = useVaultSelectModalHandles(); const moveItem = useConfirm((options: { item: ItemRevision; shareId: string }) => { const optimisticId = uniqueId(); dispatch(itemMoveIntent({ ...options, optimisticId })); }); const moveManyItems = useConfirm((options: { selected: BulkSelectionDTO; shareId: string }) => { dispatch(itemBulkMoveIntent(options)); bulk.disable(); }); const trashItem = (item: ItemRevision) => { dispatch(itemTrashIntent({ itemId: item.itemId, shareId: item.shareId, item })); }; const trashManyItems = (selected: BulkSelectionDTO) => { dispatch(itemBulkTrashIntent({ selected })); bulk.disable(); }; const deleteItem = (item: ItemRevision) => { dispatch(itemDeleteIntent({ itemId: item.itemId, shareId: item.shareId, item })); }; const deleteManyItems = (selected: BulkSelectionDTO) => { dispatch(itemBulkDeleteIntent({ selected })); bulk.disable(); }; const restoreItem = (item: ItemRevision) => { dispatch(itemRestoreIntent({ itemId: item.itemId, shareId: item.shareId, item })); }; const restoreManyItems = (selected: BulkSelectionDTO) => { dispatch(itemBulkRestoreIntent({ selected })); bulk.disable(); }; const context = useMemo<ItemActionsContextType>(() => { return { move: (item, mode) => openVaultSelect({ mode, shareId: item.shareId, onSubmit: (shareId) => { moveItem.prompt({ item, shareId }); closeVaultSelect(); }, }), moveMany: (selected) => openVaultSelect({ mode: VaultSelectMode.Writable, shareId: '' /* allow all vaults */, onSubmit: (shareId) => { moveManyItems.prompt({ selected, shareId }); closeVaultSelect(); }, }), trash: trashItem, trashMany: trashManyItems, delete: deleteItem, deleteMany: deleteManyItems, restore: restoreItem, restoreMany: restoreManyItems, }; }, []); return ( <ItemActionsContext.Provider value={context}> {children} <VaultSelect downgradeMessage={c('Info') .t`You have exceeded the number of vaults included in your subscription. Items can only be moved to your first two vaults. To move items between all vaults upgrade your subscription.`} onClose={closeVaultSelect} {...modalState} /> {moveItem.pending && ( <ConfirmMoveItem open item={moveItem.param.item} shareId={moveItem.param.shareId} onCancel={moveItem.cancel} onConfirm={moveItem.confirm} /> )} {moveManyItems.pending && ( <ConfirmMoveManyItems open selected={moveManyItems.param.selected} shareId={moveManyItems.param.shareId} onConfirm={moveManyItems.confirm} onCancel={moveManyItems.cancel} /> )} </ItemActionsContext.Provider> ); }; export const useItemsActions = (): ItemActionsContextType => useContext(ItemActionsContext)!; ```
/content/code_sandbox/packages/pass/components/Item/ItemActionsProvider.tsx
xml
2016-06-08T11:16:51
2024-08-16T14:14:27
WebClients
ProtonMail/WebClients
4,300
1,110
```xml // Utilities import { Box } from '@/util/box' /** @see path_to_url */ export function nullifyTransforms (el: HTMLElement): Box { const rect = el.getBoundingClientRect() const style = getComputedStyle(el) const tx = style.transform if (tx) { let ta, sx, sy, dx, dy if (tx.startsWith('matrix3d(')) { ta = tx.slice(9, -1).split(/, /) sx = +ta[0] sy = +ta[5] dx = +ta[12] dy = +ta[13] } else if (tx.startsWith('matrix(')) { ta = tx.slice(7, -1).split(/, /) sx = +ta[0] sy = +ta[3] dx = +ta[4] dy = +ta[5] } else { return new Box(rect) } const to = style.transformOrigin const x = rect.x - dx - (1 - sx) * parseFloat(to) const y = rect.y - dy - (1 - sy) * parseFloat(to.slice(to.indexOf(' ') + 1)) const w = sx ? rect.width / sx : el.offsetWidth + 1 const h = sy ? rect.height / sy : el.offsetHeight + 1 return new Box({ x, y, width: w, height: h }) } else { return new Box(rect) } } export function animate ( el: Element, keyframes: Keyframe[] | PropertyIndexedKeyframes | null, options?: number | KeyframeAnimationOptions ) { if (typeof el.animate === 'undefined') return { finished: Promise.resolve() } let animation: Animation try { animation = el.animate(keyframes, options) } catch (err) { return { finished: Promise.resolve() } } if (typeof animation.finished === 'undefined') { (animation as any).finished = new Promise(resolve => { animation.onfinish = () => { resolve(animation) } }) } return animation } ```
/content/code_sandbox/packages/vuetify/src/util/animation.ts
xml
2016-09-12T00:39:35
2024-08-16T20:06:39
vuetify
vuetifyjs/vuetify
39,539
460
```xml import { createStore } from 'ice'; import counter from './models/counter'; const store = createStore({ counter }); export default store; ```
/content/code_sandbox/examples/with-store/src/pages/store.ts
xml
2016-11-03T06:59:15
2024-08-16T10:11:29
ice
alibaba/ice
17,815
28
```xml export class UserProfile { public transport: string; public name: string; public age: number; } ```
/content/code_sandbox/samples/typescript_nodejs/05.multi-turn-prompt/src/userProfile.ts
xml
2016-09-20T16:17:28
2024-08-16T02:44:00
BotBuilder-Samples
microsoft/BotBuilder-Samples
4,323
25
```xml import * as React from 'react'; import { createSvgIcon } from '@fluentui/react-icons-mdl2'; const SwayLogo16Icon = createSvgIcon({ svg: ({ classes }) => ( <svg xmlns="path_to_url" viewBox="0 0 2048 2048" className={classes.svg}> <path d="M2048 256v1536q0 27-10 50t-27 40-41 28-50 10h-640v128L0 1824V224L1280 0v128h640q27 0 50 10t40 27 28 41 10 50zM912 1256q0-79-26-133t-65-94-85-67-85-54-65-54-26-68q0-25 9-42t26-28 36-15 43-5q32 0 58 5t49 16 45 26 47 34V516q-45-18-89-25t-93-8q-77 0-141 21t-112 62-73 102-26 142q0 78 25 131t62 91 81 66 81 53 62 53 25 67q0 44-28 63t-69 20q-40 0-72-10t-61-29-53-42-50-53v269q24 21 55 35t66 24 70 14 66 4q72 0 130-21t98-61 63-97 22-131zM1920 256h-640v567l113-145q14-18 35-28t44-11q23 0 44 10t35 29l369 474h-640v128h512v128h-512v128h512v128h-512v128h640V256zm-128 128v128h-128V384h128z" /> </svg> ), displayName: 'SwayLogo16Icon', }); export default SwayLogo16Icon; ```
/content/code_sandbox/packages/react-icons-mdl2-branded/src/components/SwayLogo16Icon.tsx
xml
2016-06-06T15:03:44
2024-08-16T18:49:29
fluentui
microsoft/fluentui
18,221
474
```xml <Project Sdk="Microsoft.NET.Sdk"> <Import Project="..\..\..\buildtools\common.props" /> <PropertyGroup> <Description>Amazon.Lambda.AspNetCoreServer makes it easy to run ASP.NET Core Web API applications as AWS Lambda functions.</Description> <TargetFrameworks>net6.0;net8.0</TargetFrameworks> <AssemblyTitle>Amazon.Lambda.AspNetCoreServer</AssemblyTitle> <VersionPrefix>9.0.0</VersionPrefix> <AssemblyName>Amazon.Lambda.AspNetCoreServer</AssemblyName> <PackageId>Amazon.Lambda.AspNetCoreServer</PackageId> <PackageTags>AWS;Amazon;Lambda;aspnetcore</PackageTags> <LangVersion>Latest</LangVersion> <TreatWarningsAsErrors>false</TreatWarningsAsErrors> <PackageReadmeFile>README.md</PackageReadmeFile> <WarningsAsErrorsA>IL2026,IL2067,IL2075,IL2091</WarningsAsErrorsA> <IsTrimmable>true</IsTrimmable> <EnableTrimAnalyzerA>true</EnableTrimAnalyzerA> </PropertyGroup> <ItemGroup> <None Include="README.md" Pack="true" PackagePath="\" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\Amazon.Lambda.ApplicationLoadBalancerEvents\Amazon.Lambda.ApplicationLoadBalancerEvents.csproj" /> <ProjectReference Include="..\Amazon.Lambda.Core\Amazon.Lambda.Core.csproj" /> <ProjectReference Include="..\Amazon.Lambda.Logging.AspNetCore\Amazon.Lambda.Logging.AspNetCore.csproj" /> <ProjectReference Include="..\Amazon.Lambda.APIGatewayEvents\Amazon.Lambda.APIGatewayEvents.csproj" /> </ItemGroup> <ItemGroup> <FrameworkReference Include="Microsoft.AspNetCore.App" /> <ProjectReference Include="..\Amazon.Lambda.Serialization.SystemTextJson\Amazon.Lambda.Serialization.SystemTextJson.csproj" /> </ItemGroup> </Project> ```
/content/code_sandbox/Libraries/src/Amazon.Lambda.AspNetCoreServer/Amazon.Lambda.AspNetCoreServer.csproj
xml
2016-11-11T20:43:34
2024-08-15T16:57:53
aws-lambda-dotnet
aws/aws-lambda-dotnet
1,558
426
```xml import { CALENDAR_SHORT_APP_NAME, DRIVE_SHORT_APP_NAME, MAIL_SHORT_APP_NAME, VPN_APP_NAME, } from '@proton/shared/lib/constants'; import { getPremium } from '@proton/shared/lib/helpers/premium'; describe('getPremium', () => { it('returns expected string when passed one app', () => { expect(getPremium(VPN_APP_NAME)).toEqual('Premium Proton VPN'); }); it('returns expected string when passed one app', () => { expect(getPremium(MAIL_SHORT_APP_NAME, CALENDAR_SHORT_APP_NAME)).toEqual('Premium Mail & Calendar'); }); it('returns expected string when passed one app', () => { expect(getPremium(MAIL_SHORT_APP_NAME, CALENDAR_SHORT_APP_NAME, DRIVE_SHORT_APP_NAME)).toEqual( 'Premium Mail & Calendar & Drive' ); }); }); ```
/content/code_sandbox/packages/shared/test/helpers/premium.spec.ts
xml
2016-06-08T11:16:51
2024-08-16T14:14:27
WebClients
ProtonMail/WebClients
4,300
184
```xml import * as React from 'react'; import { ReactElement, ReactNode, useEffect } from 'react'; import { FormHelperText } from '@mui/material'; import { styled } from '@mui/material/styles'; import { Color } from '@tiptap/extension-color'; import Highlight from '@tiptap/extension-highlight'; import Image from '@tiptap/extension-image'; import Link from '@tiptap/extension-link'; import TextAlign from '@tiptap/extension-text-align'; import TextStyle from '@tiptap/extension-text-style'; import Underline from '@tiptap/extension-underline'; import { Editor, EditorContent, EditorOptions, useEditor } from '@tiptap/react'; import StarterKit from '@tiptap/starter-kit'; import clsx from 'clsx'; import { useInput, useResourceContext } from 'ra-core'; import { CommonInputProps, InputHelperText, Labeled, LabeledProps, } from 'ra-ui-materialui'; import { RichTextInputToolbar } from './RichTextInputToolbar'; import { TiptapEditorProvider } from './TiptapEditorProvider'; /** * A rich text editor for the react-admin that is accessible and supports translations. Based on [Tiptap](path_to_url * @param props The input props. Accept all common react-admin input props. * @param {EditorOptions} props.editorOptions The options to pass to the Tiptap editor. See Tiptap settings [here](path_to_url#settings). * @param {ReactNode} props.toolbar The toolbar containing the editors commands. * * @example <caption>Customizing the editors options</caption> * import { RichTextInput, RichTextInputToolbar } from 'ra-input-rich-text'; * const MyRichTextInput = (props) => ( * <RichTextInput * toolbar={<RichTextInputToolbar size="large" />} * label="Body" * source="body" * {...props} * /> * ); * * @example <caption>Customizing the toolbar size</caption> * import { RichTextInput, RichTextInputToolbar } from 'ra-input-rich-text'; * const MyRichTextInput = (props) => ( * <RichTextInput * toolbar={<RichTextInputToolbar size="large" />} * label="Body" * source="body" * {...props} * /> * ); * * @example <caption>Customizing the toolbar commands</caption> * import { RichTextInput, RichTextInputToolbar } from 'ra-input-rich-text'; * const MyRichTextInput = ({ size, ...props }) => ( * <RichTextInput * toolbar={( * <RichTextInputToolbar> * <LevelSelect size={size} /> * <FormatButtons size={size} /> * <ColorButtons size={size} /> * <ListButtons size={size} /> * <LinkButtons size={size} /> * <ImageButtons size={size} /> * <QuoteButtons size={size} /> * <ClearButtons size={size} /> * </RichTextInputToolbar> * )} * label="Body" * source="body" * {...props} * /> * ); */ export const RichTextInput = (props: RichTextInputProps) => { const { className, defaultValue = '', disabled = false, editorOptions = DefaultEditorOptions, fullWidth, helperText, label, readOnly = false, source, sx, toolbar, } = props; const resource = useResourceContext(props); const { id, field, isRequired, fieldState, formState: { isSubmitted }, } = useInput({ ...props, source, defaultValue }); const editor = useEditor( { ...editorOptions, editable: !disabled && !readOnly, content: field.value, editorProps: { ...editorOptions?.editorProps, attributes: { ...editorOptions?.editorProps?.attributes, id, }, }, }, [disabled, editorOptions, readOnly, id] ); const { error, invalid, isTouched } = fieldState; useEffect(() => { if (!editor) return; const { from, to } = editor.state.selection; editor.commands.setContent(field.value, false, { preserveWhitespace: true, }); editor.commands.setTextSelection({ from, to }); }, [editor, field.value]); useEffect(() => { if (!editor) { return; } const handleEditorUpdate = () => { if (editor.isEmpty) { field.onChange(''); field.onBlur(); return; } const html = editor.getHTML(); field.onChange(html); field.onBlur(); }; editor.on('update', handleEditorUpdate); editor.on('blur', field.onBlur); return () => { editor.off('update', handleEditorUpdate); editor.off('blur', field.onBlur); }; }, [editor, field]); return ( <Root className={clsx( 'ra-input', `ra-input-${source}`, className, fullWidth ? 'fullWidth' : '' )} sx={sx} > <Labeled isRequired={isRequired} label={label} id={`${id}-label`} color={fieldState?.invalid ? 'error' : undefined} source={source} resource={resource} fullWidth={fullWidth} > <RichTextInputContent editor={editor} error={error} helperText={helperText} id={id} isTouched={isTouched} isSubmitted={isSubmitted} invalid={invalid} toolbar={toolbar || <RichTextInputToolbar />} /> </Labeled> </Root> ); }; export const DefaultEditorOptions: Partial<EditorOptions> = { extensions: [ StarterKit, Underline, Link, TextAlign.configure({ types: ['heading', 'paragraph'], }), Image.configure({ inline: true, }), TextStyle, // Required by Color Color, Highlight.configure({ multicolor: true }), ], }; export type RichTextInputProps = CommonInputProps & Omit<LabeledProps, 'children'> & { disabled?: boolean; readOnly?: boolean; editorOptions?: Partial<EditorOptions>; toolbar?: ReactNode; sx?: (typeof Root)['defaultProps']['sx']; }; const PREFIX = 'RaRichTextInput'; const classes = { editorContent: `${PREFIX}-editorContent`, }; const Root = styled('div', { name: PREFIX, overridesResolver: (props, styles) => styles.root, })(({ theme }) => ({ '&.fullWidth': { width: '100%', }, [`& .${classes.editorContent}`]: { width: '100%', '& .ProseMirror': { backgroundColor: theme.palette.background.default, borderColor: theme.palette.mode === 'light' ? 'rgba(0, 0, 0, 0.23)' : 'rgba(255, 255, 255, 0.23)', borderRadius: theme.shape.borderRadius, borderStyle: 'solid', borderWidth: '1px', padding: theme.spacing(1), '&[contenteditable="false"], &[contenteditable="false"]:hover, &[contenteditable="false"]:focus': { backgroundColor: theme.palette.action.disabledBackground, }, '&:hover': { backgroundColor: theme.palette.action.hover, }, '&:focus': { backgroundColor: theme.palette.background.default, }, '& p': { margin: '0 0 1em 0', '&:last-child': { marginBottom: 0, }, }, }, }, })); /** * Extracted in a separate component so that we can remove fullWidth from the props injected by Labeled * and avoid warnings about unknown props on Root. */ const RichTextInputContent = ({ editor, error, helperText, id, invalid, toolbar, }: RichTextInputContentProps) => ( <> <TiptapEditorProvider value={editor}> {toolbar} <EditorContent aria-labelledby={`${id}-label`} className={classes.editorContent} editor={editor} /> </TiptapEditorProvider> <FormHelperText className={invalid ? 'ra-rich-text-input-error' : ''} error={invalid} > <InputHelperText error={error?.message} helperText={helperText} /> </FormHelperText> </> ); export type RichTextInputContentProps = { className?: string; editor?: Editor; error?: any; helperText?: string | ReactElement | false; id: string; isTouched: boolean; isSubmitted: boolean; invalid: boolean; toolbar?: ReactNode; }; ```
/content/code_sandbox/packages/ra-input-rich-text/src/RichTextInput.tsx
xml
2016-07-13T07:58:54
2024-08-16T18:32:27
react-admin
marmelab/react-admin
24,624
1,899
```xml import { useMemo } from 'react'; const useDocumentTitle = (title?: string) => { // This is explicitly happening in render and not in a useEffect to allow children to override parent titles useMemo(() => { if (title === undefined) { return; } document.title = title; }, [title]); }; export default useDocumentTitle; ```
/content/code_sandbox/packages/components/hooks/useDocumentTitle.ts
xml
2016-06-08T11:16:51
2024-08-16T14:14:27
WebClients
ProtonMail/WebClients
4,300
78
```xml angular .module('index') .controller('KeeperContainerListCtl', KeeperContainerListCtl); KeeperContainerListCtl.$inject = ['$rootScope', '$scope', 'KeeperContainerService', 'NgTableParams']; function KeeperContainerListCtl($rootScope, $scope, KeeperContainerService, NgTableParams) { $scope.originData = [] $scope.tableParams = new NgTableParams({}, {}); KeeperContainerService.getAllInfos().then(function (response) { if (Array.isArray(response)) $scope.originData = response $scope.tableParams = new NgTableParams({ page : 1, count : 10, }, { filterDelay: 100, counts: [10, 25, 50], dataset: $scope.originData }); }) } ```
/content/code_sandbox/redis/redis-console/src/main/resources/static/scripts/controllers/KeeperContainerListCtl.ts
xml
2016-03-29T12:22:36
2024-08-12T11:25:42
x-pipe
ctripcorp/x-pipe
1,977
170
```xml import * as React from 'react'; import { Card, ICardTokens, ICardSectionStyles, ICardSectionTokens } from '@fluentui/react-cards'; import { FontWeights, Icon, IIconStyles, Image, Stack, IStackTokens, Text, ITextStyles } from '@fluentui/react'; /* eslint-disable deprecation/deprecation */ const alertClicked = (): void => { alert('Clicked'); }; const siteTextStyles: ITextStyles = { root: { color: '#025F52', fontWeight: FontWeights.semibold, }, }; const descriptionTextStyles: ITextStyles = { root: { color: '#333333', fontWeight: FontWeights.regular, }, }; const helpfulTextStyles: ITextStyles = { root: { color: '#333333', fontWeight: FontWeights.regular, }, }; const iconStyles: IIconStyles = { root: { color: '#0078D4', fontSize: 16, fontWeight: FontWeights.regular, }, }; const footerCardSectionStyles: ICardSectionStyles = { root: { alignSelf: 'stretch', borderLeft: '1px solid #F3F2F1', }, }; const sectionStackTokens: IStackTokens = { childrenGap: 20 }; const cardTokens: ICardTokens = { childrenMargin: 12 }; const footerCardSectionTokens: ICardSectionTokens = { padding: '0px 0px 0px 12px' }; export const CardHorizontalExample: React.FunctionComponent = () => { return ( <Stack tokens={sectionStackTokens}> <Card aria-label="Basic horizontal card" horizontal tokens={cardTokens}> <Card.Item> <Text>Basic horizontal card</Text> </Card.Item> </Card> <Card aria-label="Clickable horizontal card " horizontal onClick={alertClicked} tokens={cardTokens}> <Card.Item fill> <Image src="path_to_url" alt="Placeholder image." height={135} width={180} /> </Card.Item> <Card.Section> <Text variant="small" styles={siteTextStyles}> Contoso </Text> <Text styles={descriptionTextStyles}>Contoso Denver expansion design marketing hero guidelines</Text> <Text variant="small" styles={helpfulTextStyles}> Is this recommendation helpful? </Text> </Card.Section> <Card.Section styles={footerCardSectionStyles} tokens={footerCardSectionTokens}> <Icon iconName="RedEye" styles={iconStyles} /> <Icon iconName="SingleBookmark" styles={iconStyles} /> <Stack.Item grow={1}> <span /> </Stack.Item> <Icon iconName="MoreVertical" styles={iconStyles} /> </Card.Section> </Card> </Stack> ); }; ```
/content/code_sandbox/packages/react-examples/src/react-cards/Card/Card.Horizontal.Example.tsx
xml
2016-06-06T15:03:44
2024-08-16T18:49:29
fluentui
microsoft/fluentui
18,221
620
```xml <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="15.0" xmlns="path_to_url"> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>{C89FA730-6A8F-4BE0-AF52-E352B036952F}</ProjectGuid> <OutputType>Exe</OutputType> <RootNamespace>ObserverPattern</RootNamespace> <AssemblyName>ObserverPattern</AssemblyName> <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PlatformTarget>AnyCPU</PlatformTarget> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PlatformTarget>AnyCPU</PlatformTarget> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> <Reference Include="Microsoft.CSharp" /> <Reference Include="System.Data" /> <Reference Include="System.Net.Http" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="Country.cs" /> <Compile Include="Observer.cs" /> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Spy.cs" /> <Compile Include="Subject.cs" /> </ItemGroup> <ItemGroup> <None Include="App.config" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </Project> ```
/content/code_sandbox/DesignPatterns/ObserverPattern/ObserverPattern/ObserverPattern.csproj
xml
2016-04-25T14:37:08
2024-08-16T09:19:37
Unity3DTraining
XINCGer/Unity3DTraining
7,368
620
```xml import * as Log from "oni-core-logging" export class PromiseQueue { private _currentPromise: Promise<any> = Promise.resolve(null) public enqueuePromise<T>( functionThatReturnsPromiseOrThenable: () => Promise<T> | Thenable<T>, requireConnection: boolean = true, ): Promise<T> { const promiseExecutor = () => { return functionThatReturnsPromiseOrThenable() } const newPromise = this._currentPromise.then( () => promiseExecutor(), err => { Log.error(err) return promiseExecutor() }, ) this._currentPromise = newPromise return newPromise } } ```
/content/code_sandbox/browser/src/Services/Language/PromiseQueue.ts
xml
2016-11-16T14:42:55
2024-08-14T11:48:05
oni
onivim/oni
11,355
142
```xml import { Entity } from "../../../../../../src/decorator/entity/Entity" import { PrimaryGeneratedColumn } from "../../../../../../src/decorator/columns/PrimaryGeneratedColumn" import { Question } from "./Question" import { ManyToOne } from "../../../../../../src/decorator/relations/ManyToOne" @Entity() export class User { @PrimaryGeneratedColumn() id: number @ManyToOne((type) => Question, { cascade: ["insert"], nullable: true, }) question: Question } ```
/content/code_sandbox/test/functional/persistence/cascades/cascades-example2/entity/User.ts
xml
2016-02-29T07:41:14
2024-08-16T18:28:52
typeorm
typeorm/typeorm
33,875
107
```xml <?xml version="1.0" encoding="utf-8"?> <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="path_to_url" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd"> <file datatype="xml" source-language="en" target-language="ja" original="../LocalizableStrings.resx"> <body> <trans-unit id="AdManifestOnlyOptionDescription"> <source>Only update advertising manifests.</source> <target state="translated"></target> <note /> </trans-unit> <trans-unit id="CannotCombineOptions"> <source>Cannot use the {0} and {1} options together.</source> <target state="translated">{0} {1} </target> <note /> </trans-unit> <trans-unit id="CommandDescription"> <source>Update all installed workloads.</source> <target state="translated"></target> <note /> </trans-unit> <trans-unit id="FromHistoryOptionDescription"> <source>Update workloads to a previous version specified by the argument. Use the 'dotnet workload history' to see available workload history records.</source> <target state="new">Update workloads to a previous version specified by the argument. Use the 'dotnet workload history' to see available workload history records.</target> <note /> </trans-unit> <trans-unit id="FromPreviousSdkOptionDescription"> <source>Include workloads installed with earlier SDK versions in update.</source> <target state="translated"> SDK </target> <note /> </trans-unit> <trans-unit id="FromRollbackDefinitionOptionDescription"> <source>Update workloads based on specified rollback definition file.</source> <target state="translated"></target> <note /> </trans-unit> <trans-unit id="HistoryManifestOnlyOptionDescription"> <source>Update to the workload versions specified in the history without changing which workloads are installed. Currently installed workloads will be updated to match the specified history version.</source> <target state="new">Update to the workload versions specified in the history without changing which workloads are installed. Currently installed workloads will be updated to match the specified history version.</target> <note /> </trans-unit> <trans-unit id="NoWorkloadHistoryRecords"> <source>Workload history records are created when when running an operation that modifies workloads like update or install. Cannot update from history until workload history records exist.</source> <target state="new">Workload history records are created when when running an operation that modifies workloads like update or install. Cannot update from history until workload history records exist.</target> <note /> </trans-unit> <trans-unit id="NoWorkloadUpdateFound"> <source>No workload update found.</source> <target state="translated"></target> <note /> </trans-unit> <trans-unit id="NoWorkloadsToUpdate"> <source>No workloads installed for this feature band. To update workloads installed with earlier SDK versions, include the --from-previous-sdk option.</source> <target state="translated"> SDK --from-previous-sdk </target> <note /> </trans-unit> <trans-unit id="RollBackFailedMessage"> <source>Installation rollback failed: {0}</source> <target state="translated">: {0}</target> <note /> </trans-unit> <trans-unit id="RollingBackInstall"> <source>Workload installation failed. Rolling back installed packs...</source> <target state="translated"> ...</target> <note /> </trans-unit> <trans-unit id="UpdateFailed"> <source>Workload '{0}' failed to update due to the following:</source> <target state="translated"> '{0}' :</target> <note /> </trans-unit> <trans-unit id="UpdateFromRollbackSwitchesModeToLooseManifests"> <source>Updating to a rollback file is not compatible with workload sets. Install and Update will now use loose manifests. To update to a specific workload version, use --version.</source> <target state="translated"> --version </target> <note /> </trans-unit> <trans-unit id="UpdateSucceeded"> <source>Successfully updated workload(s): {0}.</source> <target state="translated"> {0} </target> <note /> </trans-unit> <trans-unit id="WorkloadCacheDownloadFailed"> <source>Failed to download workload update packages to cache: {0}</source> <target state="translated">: {0}</target> <note /> </trans-unit> <trans-unit id="WorkloadHistoryRecordInvalidIdValue"> <source>The ID of a workload history record should be between 1 and the number of workload history records, inclusive.</source> <target state="new">The ID of a workload history record should be between 1 and the number of workload history records, inclusive.</target> <note /> </trans-unit> <trans-unit id="WorkloadSetModeTakesWorkloadSetLooseManifestOrAuto"> <source>Invalid argument "{0}" to the --mode argument for dotnet workload update. Only supported modes are "workloadset", "loosemanifest", and "auto".</source> <target state="new">Invalid argument "{0}" to the --mode argument for dotnet workload update. Only supported modes are "workloadset", "loosemanifest", and "auto".</target> <note /> </trans-unit> <trans-unit id="WorkloadUpdateAdManifestsSucceeded"> <source>Successfully updated advertising manifests.</source> <target state="translated"></target> <note /> </trans-unit> <trans-unit id="WorkloadUpdateFailed"> <source>Workload update failed: {0}</source> <target state="translated">: {0}</target> <note /> </trans-unit> <trans-unit id="WorkloadVersionRequestedNotFound"> <source>Workload version {0} not found.</source> <target state="translated"> {0} </target> <note /> </trans-unit> </body> </file> </xliff> ```
/content/code_sandbox/src/Cli/dotnet/commands/dotnet-workload/update/xlf/LocalizableStrings.ja.xlf
xml
2016-07-22T21:26:02
2024-08-16T17:23:58
sdk
dotnet/sdk
2,627
1,405