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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Class Poco::Mutex</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta name="author" content="Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="publisher" content="Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="copyright" content="Copyright (c) 2009, Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="language" content="en"/>
<meta name="date" content="2009-11-24"/>
<meta name="generator" content="PocoDoc"/>
<link rel="stylesheet" href="css/styles.css" type="text/css"/>
</head>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0">
<div class="header">
<h1 class="namespace"><a href="Poco.html" class="namespace">Poco</a></h1>
<h1 class="symbol">class Mutex</h1>
</div>
<div class="body">
<p>
<b>Library:</b> Foundation<br />
<b>Package:</b> Threading<br />
<b>Header:</b> Poco/Mutex.h</p>
<h2>Description</h2>
<div class="description">
<p>A <a href="Poco.Mutex.html" title="class Poco::Mutex">Mutex</a> (mutual exclusion) is a synchronization mechanism used to control access to a shared resource in a concurrent (multithreaded) scenario. Mutexes are recursive, that is, the same mutex can be locked multiple times by the same thread (but, of course, not by other threads). Using the <a href="Poco.Mutex.html#8537" title="Poco::Mutex::ScopedLock">ScopedLock</a> class is the preferred way to automatically lock and unlock a mutex. </p>
</div>
<h2>Inheritance</h2>
<p><b>Direct Base Classes: </b>MutexImpl</p>
<p><b>All Base Classes: </b>MutexImpl</p>
<h2>Member Summary</h2>
<p><b>Member Functions: </b><a href="Poco.Mutex.html#8540" title="Poco::Mutex::lock()">lock</a>, <a href="Poco.Mutex.html#8543" title="Poco::Mutex::tryLock()">tryLock</a>, <a href="Poco.Mutex.html#8546" title="Poco::Mutex::unlock()">unlock</a></p>
<h2>Types</h2>
<h3><a name="8537">ScopedLock</a></h3>
<p class="decl">typedef <a href="Poco.ScopedLock.html" title="class Poco::ScopedLock">Poco::ScopedLock</a> < <a href="Poco.Mutex.html" title="class Poco::Mutex">Mutex</a> > <a href="Poco.Mutex.html#8537" title="Poco::Mutex::ScopedLock">ScopedLock</a>;</p>
<div class="description">
<p></p>
</div>
<h2>Constructors</h2>
<h3><a name="8538">Mutex</a></h3>
<p class="decl"><a href="Poco.Mutex.html" title="class Poco::Mutex">Mutex</a>();</p>
<div class="description">
<p>creates the <a href="Poco.Mutex.html" title="class Poco::Mutex">Mutex</a>. </p>
</div>
<h2>Destructor</h2>
<h3><a name="8539">~Mutex</a></h3>
<p class="decl">~<a href="Poco.Mutex.html" title="class Poco::Mutex">Mutex</a>();</p>
<div class="description">
<p>destroys the <a href="Poco.Mutex.html" title="class Poco::Mutex">Mutex</a>. </p>
</div>
<h2>Member Functions</h2>
<h3><a name="8540">lock</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">void lock();</p>
<div class="description">
<p>Locks the mutex. Blocks if the mutex is held by another thread. </p>
</div>
<h3><a name="8541">lock</a></h3>
<p class="decl">void lock(<br /> long milliseconds<br />);</p>
<div class="description">
<p>Locks the mutex. Blocks up to the given number of milliseconds if the mutex is held by another thread. Throws a <a href="Poco.TimeoutException.html" title="class Poco::TimeoutException">TimeoutException</a> if the mutex can not be locked within the given timeout. </p>
<p>Performance Note: On most platforms (including Windows), this member function is implemented using a loop calling (the equivalent of) <a href="Poco.Mutex.html#8543" title="Poco::Mutex::tryLock()">tryLock</a>() and <a href="Poco.Thread.html#10853" title="Poco::Thread::sleep()">Thread::sleep</a>(). On POSIX platforms that support pthread_mutex_timedlock(), this is used. </p>
</div>
<h3><a name="8543">tryLock</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">bool tryLock();</p>
<div class="description">
<p>Tries to lock the mutex. Returns false immediately if the mutex is already held by another thread. Returns true if the mutex was successfully locked. </p>
</div>
<h3><a name="8544">tryLock</a></h3>
<p class="decl">bool tryLock(<br /> long milliseconds<br />);</p>
<div class="description">
<p>Locks the mutex. Blocks up to the given number of milliseconds if the mutex is held by another thread. Returns true if the mutex was successfully locked. </p>
<p>Performance Note: On most platforms (including Windows), this member function is implemented using a loop calling (the equivalent of) <a href="Poco.Mutex.html#8543" title="Poco::Mutex::tryLock()">tryLock</a>() and <a href="Poco.Thread.html#10853" title="Poco::Thread::sleep()">Thread::sleep</a>(). On POSIX platforms that support pthread_mutex_timedlock(), this is used. </p>
</div>
<h3><a name="8546">unlock</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">void unlock();</p>
<div class="description">
<p>Unlocks the mutex so that it can be acquired by other threads. </p>
</div>
<p class="footer">POCO C++ Libraries 1.3.6-all<br />
Copyright © 2009, <a href="http://pocoproject.org/" target="_blank">Applied Informatics Software Engineering GmbH and Contributors</a></p>
</div>
</body>
</html>
|