1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
<!DOCTYPE html
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns:MSHelp="http://www.microsoft.com/MSHelp/" lang="en-us" xml:lang="en-us"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="DC.Type" content="topic">
<meta name="DC.Title" content="Containers">
<meta name="DC.subject" content="Containers">
<meta name="keywords" content="Containers">
<meta name="DC.Relation" scheme="URI" content="../tbb_userguide/title.htm">
<meta name="DC.Relation" scheme="URI" content="../tbb_userguide/concurrent_hash_map.htm">
<meta name="DC.Relation" scheme="URI" content="../tbb_userguide/concurrent_vector.htm">
<meta name="DC.Relation" scheme="URI" content="../tbb_userguide/Concurrent_Queue_Classes.htm">
<meta name="DC.Relation" scheme="URI" content="../tbb_userguide/Summary_of_Containers.htm">
<meta name="DC.Relation" scheme="URI" content="Task-Based_Programming.htm">
<meta name="DC.Format" content="XHTML">
<meta name="DC.Identifier" content="tutorial_Containers">
<link rel="stylesheet" type="text/css" href="../intel_css_styles.css">
<title>Containers</title>
<xml>
<MSHelp:Attr Name="DocSet" Value="Intel"></MSHelp:Attr>
<MSHelp:Attr Name="Locale" Value="kbEnglish"></MSHelp:Attr>
<MSHelp:Attr Name="TopicType" Value="kbReference"></MSHelp:Attr>
</xml>
</head>
<body id="tutorial_Containers">
<!-- ==============(Start:NavScript)================= -->
<script src="..\NavScript.js" language="JavaScript1.2" type="text/javascript"></script>
<script language="JavaScript1.2" type="text/javascript">WriteNavLink(1);</script>
<!-- ==============(End:NavScript)================= -->
<a name="tutorial_Containers"><!-- --></a>
<h1 class="topictitle1">Containers</h1>
<div>
<p>Intel® Threading Building Blocks (Intel® TBB) provides highly concurrent
container classes. These containers can be used with raw Windows* OS or Linux*
OS threads, or in conjunction with task-based programming.
</p>
<p>A concurrent container allows multiple threads to concurrently access
and update items in the container. Typical C++ STL containers do not permit
concurrent update; attempts to modify them concurrently often result in
corrupting the container. STL containers can be wrapped in a mutex to make them
safe for concurrent access, by letting only one thread operate on the container
at a time, but that approach eliminates concurrency, thus restricting parallel
speedup.
</p>
<p>Containers provided by Intel® TBB offer a much higher level of
concurrency, via one or both of the following methods:
</p>
<ul type="disc">
<li>
<p><strong>Fine-grained locking:</strong> Multiple threads operate on the
container by locking only those portions they really need to lock. As long as
different threads access different portions, they can proceed concurrently.
</p>
</li>
<li>
<p><strong>Lock-free techniques:</strong> Different threads account and correct
for the effects of other interfering threads.
</p>
</li>
</ul>
<p>Notice that highly-concurrent containers come at a cost. They
typically have higher overheads than regular STL containers. Operations on
highly-concurrent containers may take longer than for STL containers.
Therefore, use highly-concurrent containers when the speedup from the
additional concurrency that they enable outweighs their slower sequential
performance.
</p>
<div class="Note"><h3 class="NoteTipHead">
Caution</h3>
<p>As with most objects in C++, the constructor or destructor of a
container object must not be invoked concurrently with another operation on the
same object. Otherwise the resulting race may cause the operation to be
executed on an undefined object.
</p>
</div>
</div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="../tbb_userguide/title.htm">Intel® Threading Building Blocks (Intel® TBB) User Guide</a></div>
</div>
<div class="See Also">
<ul class="ullinks">
<li class="ulchildlink"><a href="../tbb_userguide/concurrent_hash_map.htm">concurrent_hash_map</a><br>
</li>
<li class="ulchildlink"><a href="../tbb_userguide/concurrent_vector.htm">concurrent_vector</a><br>
</li>
<li class="ulchildlink"><a href="../tbb_userguide/Concurrent_Queue_Classes.htm">Concurrent Queue Classes</a><br>
</li>
<li class="ulchildlink"><a href="../tbb_userguide/Summary_of_Containers.htm">Summary of Containers</a><br>
</li>
</ul>
<h2>See Also</h2>
<div class="linklist">
<div><a href="Task-Based_Programming.htm">Task Based Programming
</a></div></div>
</div>
</body>
</html>
|