Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
b5c0dede
Commit
b5c0dede
authored
Dec 28, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clarified threading discussion in intro.
parent
dc9db580
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
intro.xml
docs/docs/intro.xml
+14
-11
No files found.
docs/docs/intro.xml
View file @
b5c0dede
...
...
@@ -391,24 +391,27 @@
<h1>
Thread Safety
</h1>
<p>
In the library there are three kinds of objects with regards to threading. There are objects
that are completely thread safe. Then there are objects that are not thread safe but can be
used if access to them is serialized using a mutex. Lastly, there are objects which share
some kind of global resource or are reference counted. The last kind of object is
extremely thread unfriendly and can only be used in a threaded program with great care.
In the library there are three kinds of objects with regards to threading:
<ul>
<li>
Objects which are completely threadsafe. This means that any pattern of access from
multiple threads is safe.
</li>
<li>
Objects which are safe to use if no threads touch the same instance, but require access
to a particular instance to be serialized via a mutex if it is shared among threads.
</li>
<li>
Objects which share some kind of global resource or are reference counted. This kind of object is
extremely thread unfriendly and can only be used in a threaded program with great care.
</li>
</ul>
</p>
<p>
How do you know which components/objects are thread safe and which aren't? The rule is that if
the specification for the component doesn't mention threading or thread safety then
it is ok to use as long as you serialize access to
it
. If the component might have
it is ok to use as long as you serialize access to
shared instances
. If the component might have
some global resources or be reference counted then the specifications will tell you this.
And lastly if the component is thread safe then the specification will tell you this also.
Lastly if the component is completely thread safe then the specification will tell you this also.
</p>
<p>
Also note that global functions in dlib are always thread safe.
</p>
</body>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment