tbb::internal::co_context Class Reference

`#include <co_context.h>`

Collaboration diagram for tbb::internal::co_context:

## Public Member Functions

| co_context (size_t stack_size, void *arg)
| ~co_context ()
void | resume (co_context &target)
void * | get_stack_limit ()

## Private Types

enum | co_state { co_invalid, co_suspended, co_executing, co_destroyed }

## Private Attributes

coroutine_type | my_coroutine
co_state | my_state

## Detailed Description

Definition at line 72 of file co_context.h.

## Member Enumeration Documentation

## co_state

enum tbb::internal::co_context::co_state

private

Enumerator
co_invalid |
co_suspended |
co_executing |
co_destroyed |

Definition at line 73 of file co_context.h.

{
co_invalid,
co_suspended,
co_executing,
co_destroyed
};

## Constructor & Destructor Documentation

## co_context()

tbb::internal::co_context::co_context | ( | size_t | stack_size,
|  | void * | arg
| ) |  |

inline

Definition at line 83 of file co_context.h.

: my_state(arg ? co_suspended : co_executing)
{
if (arg) {
create_coroutine(my_coroutine, stack_size, arg);
} else {
current_coroutine(my_coroutine);
}
}

References tbb::internal::create_coroutine(), tbb::internal::current_coroutine(), and my_coroutine.

Here is the call graph for this function:

## ~co_context()

tbb::internal::co_context::~co_context | ( |  | ) |

inline

Definition at line 93 of file co_context.h.

{
__TBB_ASSERT(1 << my_state & (1 << co_suspended | 1 << co_executing), NULL);
if (my_state == co_suspended)
destroy_coroutine(my_coroutine);
my_state = co_destroyed;
}

References __TBB_ASSERT, co_destroyed, co_executing, co_suspended, tbb::internal::destroy_coroutine(), my_coroutine, and my_state.

Here is the call graph for this function:

## Member Function Documentation

## get_stack_limit()

void* tbb::internal::co_context::get_stack_limit | ( |  | ) |

inline

Definition at line 114 of file co_context.h.

{
return my_coroutine.my_stack;
}

References my_coroutine, and tbb::internal::coroutine_type::my_stack.

## resume()

void tbb::internal::co_context::resume | ( | co_context & | target | ) |

inline

Definition at line 100 of file co_context.h.

{
// Do not create non-trivial objects on the stack of this function. They might never be destroyed.
__TBB_ASSERT(my_state == co_executing, NULL);
__TBB_ASSERT(target.my_state == co_suspended, NULL);
my_state = co_suspended;
target.my_state = co_executing;
// 'target' can reference an invalid object after swap_coroutine. Do not access it.
swap_coroutine(my_coroutine, target.my_coroutine);
__TBB_ASSERT(my_state == co_executing, NULL);
}

References __TBB_ASSERT, co_executing, co_suspended, my_coroutine, my_state, and tbb::internal::swap_coroutine().

Here is the call graph for this function:

## Member Data Documentation

## my_coroutine

coroutine_type tbb::internal::co_context::my_coroutine

private

Definition at line 79 of file co_context.h.

Referenced by co_context(), get_stack_limit(), resume(), and ~co_context().

## my_state

co_state tbb::internal::co_context::my_state

private

Definition at line 80 of file co_context.h.

Referenced by resume(), and ~co_context().

The documentation for this class was generated from the following file:

- co_context.h

tbb::internal::create_coroutine
void create_coroutine(coroutine_type &c, size_t stack_size, void *arg)
Definition: co_context.h:154
tbb::internal::current_coroutine
void current_coroutine(coroutine_type &c)
Definition: co_context.h:184
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::internal::co_context::co_destroyed
Definition: co_context.h:77
tbb::internal::coroutine_type::my_stack
void * my_stack
Definition: co_context.h:57
tbb::internal::swap_coroutine
void swap_coroutine(coroutine_type &prev_coroutine, coroutine_type &new_coroutine)
Definition: co_context.h:189
tbb::internal::co_context::my_state
co_state my_state
Definition: co_context.h:80
tbb::internal::co_context::co_executing
Definition: co_context.h:76
tbb::internal::co_context::co_invalid
Definition: co_context.h:74
tbb::internal::co_context::co_suspended
Definition: co_context.h:75
tbb::internal::destroy_coroutine
void destroy_coroutine(coroutine_type &c)
Definition: co_context.h:194
tbb::internal::co_context::my_coroutine
coroutine_type my_coroutine
Definition: co_context.h:79

Copyright © 2005-2020 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.