1.. _attach_flow_graph_to_arena: 2 3Attach Flow Graph to an Arbitrary Task Arena 4============================================= 5 6 7|short_name| ``task_arena`` interface provides mechanisms to guide tasks 8execution within the arena by setting the preferred computation units, 9restricting part of computation units, or limiting arena concurrency. In some 10cases, you may want to apply such mechanisms when a flow graph executes. 11 12During its construction, a ``graph`` object attaches to the arena, in which the constructing 13thread occupies a slot. 14 15This example shows how to set the most performant core type as the preferred one 16for a graph execution: 17 18 19.. literalinclude:: ./snippets/flow_graph_examples.cpp 20 :language: c++ 21 :start-after: /*begin_attach_to_arena_1*/ 22 :end-before: /*end_attach_to_arena_1*/ 23 24 25A ``graph`` object can be reattached to a different ``task_arena`` by calling 26the ``graph::reset()`` function. It reinitializes and reattaches the ``graph`` to 27the task arena instance, inside which the ``graph::reset()`` method is executed. 28 29This example shows how to reattach existing graph to an arena with the most performant 30core type as the preferred one for a work execution. Whenever a task is spawned on behalf 31of the graph, it is spawned in the arena of a graph it is attached to, disregarding 32the arena of the thread that the task is spawned from: 33 34 35.. literalinclude:: ./snippets/flow_graph_examples.cpp 36 :language: c++ 37 :start-after: /*begin_attach_to_arena_2*/ 38 :end-before: /*end_attach_to_arena_2*/ 39 40See the following topics to learn more: 41 42.. toctree:: 43 :maxdepth: 4 44 45 ../tbb_userguide/Guiding_Task_Scheduler_Execution 46 ../tbb_userguide/work_isolation 47 48