214 lines
36 KiB
XML
214 lines
36 KiB
XML
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
|
|
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.8.6">
|
|
<compounddef id="pthreads_8hpp" kind="file">
|
|
<compoundname>pthreads.hpp</compoundname>
|
|
<innernamespace refid="namespaceGecode">Gecode</innernamespace>
|
|
<innernamespace refid="namespaceGecode_1_1Support">Gecode::Support</innernamespace>
|
|
<briefdescription>
|
|
</briefdescription>
|
|
<detaileddescription>
|
|
</detaileddescription>
|
|
<programlisting>
|
|
<codeline lineno="1"><highlight class="comment">/*<sp/>-*-<sp/>mode:<sp/>C++;<sp/>c-basic-offset:<sp/>2;<sp/>indent-tabs-mode:<sp/>nil<sp/>-*-<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="2"><highlight class="normal"></highlight><highlight class="comment">/*</highlight></codeline>
|
|
<codeline lineno="3"><highlight class="comment"><sp/>*<sp/><sp/>Main<sp/>authors:</highlight></codeline>
|
|
<codeline lineno="4"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/><sp/>Christian<sp/>Schulte<sp/><schulte@gecode.org></highlight></codeline>
|
|
<codeline lineno="5"><highlight class="comment"><sp/>*</highlight></codeline>
|
|
<codeline lineno="6"><highlight class="comment"><sp/>*<sp/><sp/>Copyright:</highlight></codeline>
|
|
<codeline lineno="7"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/><sp/>Christian<sp/>Schulte,<sp/>2009</highlight></codeline>
|
|
<codeline lineno="8"><highlight class="comment"><sp/>*</highlight></codeline>
|
|
<codeline lineno="9"><highlight class="comment"><sp/>*<sp/><sp/>Last<sp/>modified:</highlight></codeline>
|
|
<codeline lineno="10"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/><sp/>$Date:<sp/>2013-07-01<sp/>07:36:45<sp/>+0200<sp/>(Mon,<sp/>01<sp/>Jul<sp/>2013)<sp/>$<sp/>by<sp/>$Author:<sp/>tack<sp/>$</highlight></codeline>
|
|
<codeline lineno="11"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/><sp/>$Revision:<sp/>13741<sp/>$</highlight></codeline>
|
|
<codeline lineno="12"><highlight class="comment"><sp/>*</highlight></codeline>
|
|
<codeline lineno="13"><highlight class="comment"><sp/>*<sp/><sp/>This<sp/>file<sp/>is<sp/>part<sp/>of<sp/>Gecode,<sp/>the<sp/>generic<sp/>constraint</highlight></codeline>
|
|
<codeline lineno="14"><highlight class="comment"><sp/>*<sp/><sp/>development<sp/>environment:</highlight></codeline>
|
|
<codeline lineno="15"><highlight class="comment"><sp/>*<sp/><sp/><sp/><sp/><sp/>http://www.gecode.org</highlight></codeline>
|
|
<codeline lineno="16"><highlight class="comment"><sp/>*</highlight></codeline>
|
|
<codeline lineno="17"><highlight class="comment"><sp/>*<sp/><sp/>Permission<sp/>is<sp/>hereby<sp/>granted,<sp/>free<sp/>of<sp/>charge,<sp/>to<sp/>any<sp/>person<sp/>obtaining</highlight></codeline>
|
|
<codeline lineno="18"><highlight class="comment"><sp/>*<sp/><sp/>a<sp/>copy<sp/>of<sp/>this<sp/>software<sp/>and<sp/>associated<sp/>documentation<sp/>files<sp/>(the</highlight></codeline>
|
|
<codeline lineno="19"><highlight class="comment"><sp/>*<sp/><sp/>"Software"),<sp/>to<sp/>deal<sp/>in<sp/>the<sp/>Software<sp/>without<sp/>restriction,<sp/>including</highlight></codeline>
|
|
<codeline lineno="20"><highlight class="comment"><sp/>*<sp/><sp/>without<sp/>limitation<sp/>the<sp/>rights<sp/>to<sp/>use,<sp/>copy,<sp/>modify,<sp/>merge,<sp/>publish,</highlight></codeline>
|
|
<codeline lineno="21"><highlight class="comment"><sp/>*<sp/><sp/>distribute,<sp/>sublicense,<sp/>and/or<sp/>sell<sp/>copies<sp/>of<sp/>the<sp/>Software,<sp/>and<sp/>to</highlight></codeline>
|
|
<codeline lineno="22"><highlight class="comment"><sp/>*<sp/><sp/>permit<sp/>persons<sp/>to<sp/>whom<sp/>the<sp/>Software<sp/>is<sp/>furnished<sp/>to<sp/>do<sp/>so,<sp/>subject<sp/>to</highlight></codeline>
|
|
<codeline lineno="23"><highlight class="comment"><sp/>*<sp/><sp/>the<sp/>following<sp/>conditions:</highlight></codeline>
|
|
<codeline lineno="24"><highlight class="comment"><sp/>*</highlight></codeline>
|
|
<codeline lineno="25"><highlight class="comment"><sp/>*<sp/><sp/>The<sp/>above<sp/>copyright<sp/>notice<sp/>and<sp/>this<sp/>permission<sp/>notice<sp/>shall<sp/>be</highlight></codeline>
|
|
<codeline lineno="26"><highlight class="comment"><sp/>*<sp/><sp/>included<sp/>in<sp/>all<sp/>copies<sp/>or<sp/>substantial<sp/>portions<sp/>of<sp/>the<sp/>Software.</highlight></codeline>
|
|
<codeline lineno="27"><highlight class="comment"><sp/>*</highlight></codeline>
|
|
<codeline lineno="28"><highlight class="comment"><sp/>*<sp/><sp/>THE<sp/>SOFTWARE<sp/>IS<sp/>PROVIDED<sp/>"AS<sp/>IS",<sp/>WITHOUT<sp/>WARRANTY<sp/>OF<sp/>ANY<sp/>KIND,</highlight></codeline>
|
|
<codeline lineno="29"><highlight class="comment"><sp/>*<sp/><sp/>EXPRESS<sp/>OR<sp/>IMPLIED,<sp/>INCLUDING<sp/>BUT<sp/>NOT<sp/>LIMITED<sp/>TO<sp/>THE<sp/>WARRANTIES<sp/>OF</highlight></codeline>
|
|
<codeline lineno="30"><highlight class="comment"><sp/>*<sp/><sp/>MERCHANTABILITY,<sp/>FITNESS<sp/>FOR<sp/>A<sp/>PARTICULAR<sp/>PURPOSE<sp/>AND</highlight></codeline>
|
|
<codeline lineno="31"><highlight class="comment"><sp/>*<sp/><sp/>NONINFRINGEMENT.<sp/>IN<sp/>NO<sp/>EVENT<sp/>SHALL<sp/>THE<sp/>AUTHORS<sp/>OR<sp/>COPYRIGHT<sp/>HOLDERS<sp/>BE</highlight></codeline>
|
|
<codeline lineno="32"><highlight class="comment"><sp/>*<sp/><sp/>LIABLE<sp/>FOR<sp/>ANY<sp/>CLAIM,<sp/>DAMAGES<sp/>OR<sp/>OTHER<sp/>LIABILITY,<sp/>WHETHER<sp/>IN<sp/>AN<sp/>ACTION</highlight></codeline>
|
|
<codeline lineno="33"><highlight class="comment"><sp/>*<sp/><sp/>OF<sp/>CONTRACT,<sp/>TORT<sp/>OR<sp/>OTHERWISE,<sp/>ARISING<sp/>FROM,<sp/>OUT<sp/>OF<sp/>OR<sp/>IN<sp/>CONNECTION</highlight></codeline>
|
|
<codeline lineno="34"><highlight class="comment"><sp/>*<sp/><sp/>WITH<sp/>THE<sp/>SOFTWARE<sp/>OR<sp/>THE<sp/>USE<sp/>OR<sp/>OTHER<sp/>DEALINGS<sp/>IN<sp/>THE<sp/>SOFTWARE.</highlight></codeline>
|
|
<codeline lineno="35"><highlight class="comment"><sp/>*</highlight></codeline>
|
|
<codeline lineno="36"><highlight class="comment"><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="37"><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="38"><highlight class="normal"></highlight><highlight class="preprocessor">#ifdef<sp/>GECODE_HAS_UNISTD_H</highlight></codeline>
|
|
<codeline lineno="39"><highlight class="preprocessor"></highlight><highlight class="preprocessor">#include<sp/><unistd.h></highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="40"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight></codeline>
|
|
<codeline lineno="41"><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="42"><highlight class="normal"></highlight><highlight class="keyword">namespace<sp/></highlight><highlight class="normal">Gecode<sp/>{<sp/></highlight><highlight class="keyword">namespace<sp/></highlight><highlight class="normal">Support<sp/>{</highlight></codeline>
|
|
<codeline lineno="43"><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="44"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*</highlight></codeline>
|
|
<codeline lineno="45"><highlight class="comment"><sp/><sp/><sp/>*<sp/>Mutex</highlight></codeline>
|
|
<codeline lineno="46"><highlight class="comment"><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="47"><highlight class="normal"><sp/><sp/>forceinline</highlight></codeline>
|
|
<codeline lineno="48"><highlight class="normal"><sp/><sp/><ref refid="classGecode_1_1Support_1_1Mutex_1aaff3f8fc6fca636d7f80ed5cdfb0a3f9" kindref="member">Mutex::Mutex</ref>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)<sp/>{</highlight></codeline>
|
|
<codeline lineno="49"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pthread_mutex_init(&p_m,NULL)<sp/>!=<sp/>0)</highlight></codeline>
|
|
<codeline lineno="50"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">throw</highlight><highlight class="normal"><sp/>OperatingSystemError(</highlight><highlight class="stringliteral">"Mutex::Mutex[pthread_mutex_init]"</highlight><highlight class="normal">);</highlight></codeline>
|
|
<codeline lineno="51"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
|
|
<codeline lineno="52"><highlight class="normal"><sp/><sp/>forceinline<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="53"><highlight class="normal"><sp/><sp/><ref refid="classGecode_1_1Support_1_1Mutex_1ae22b5dc6f88bc5443025a123fb51cd65" kindref="member">Mutex::acquire</ref>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)<sp/>{</highlight></codeline>
|
|
<codeline lineno="54"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pthread_mutex_lock(&p_m)<sp/>!=<sp/>0)</highlight></codeline>
|
|
<codeline lineno="55"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">throw</highlight><highlight class="normal"><sp/>OperatingSystemError(</highlight><highlight class="stringliteral">"Mutex::acquire[pthread_mutex_lock]"</highlight><highlight class="normal">);</highlight></codeline>
|
|
<codeline lineno="56"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
|
|
<codeline lineno="57"><highlight class="normal"><sp/><sp/>forceinline<sp/></highlight><highlight class="keywordtype">bool</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="58"><highlight class="normal"><sp/><sp/><ref refid="classGecode_1_1Support_1_1Mutex_1a92cfac9a089b0b28414f4fc1e19aabde" kindref="member">Mutex::tryacquire</ref>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)<sp/>{</highlight></codeline>
|
|
<codeline lineno="59"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>pthread_mutex_trylock(&p_m)<sp/>==<sp/>0;</highlight></codeline>
|
|
<codeline lineno="60"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
|
|
<codeline lineno="61"><highlight class="normal"><sp/><sp/>forceinline<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="62"><highlight class="normal"><sp/><sp/><ref refid="classGecode_1_1Support_1_1Mutex_1a92125d0bf014be03be0a8d0d879cff8e" kindref="member">Mutex::release</ref>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)<sp/>{</highlight></codeline>
|
|
<codeline lineno="63"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pthread_mutex_unlock(&p_m)<sp/>!=<sp/>0)</highlight></codeline>
|
|
<codeline lineno="64"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">throw</highlight><highlight class="normal"><sp/>OperatingSystemError(</highlight><highlight class="stringliteral">"Mutex::release[pthread_mutex_unlock]"</highlight><highlight class="normal">);</highlight></codeline>
|
|
<codeline lineno="65"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
|
|
<codeline lineno="66"><highlight class="normal"><sp/><sp/>forceinline</highlight></codeline>
|
|
<codeline lineno="67"><highlight class="normal"><sp/><sp/><ref refid="classGecode_1_1Support_1_1Mutex_1a95ac018aae2cbdd9ec557cfb88a7c25c" kindref="member">Mutex::~Mutex</ref>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)<sp/>{</highlight></codeline>
|
|
<codeline lineno="68"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pthread_mutex_destroy(&p_m)<sp/>!=<sp/>0)</highlight></codeline>
|
|
<codeline lineno="69"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">throw</highlight><highlight class="normal"><sp/>OperatingSystemError(</highlight><highlight class="stringliteral">"Mutex::~Mutex[pthread_mutex_destroy]"</highlight><highlight class="normal">);</highlight></codeline>
|
|
<codeline lineno="70"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
|
|
<codeline lineno="71"><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="72"><highlight class="normal"></highlight><highlight class="preprocessor">#ifdef<sp/>GECODE_THREADS_OSX</highlight></codeline>
|
|
<codeline lineno="73"><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="74"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*</highlight></codeline>
|
|
<codeline lineno="75"><highlight class="comment"><sp/><sp/><sp/>*<sp/>FastMutex</highlight></codeline>
|
|
<codeline lineno="76"><highlight class="comment"><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="77"><highlight class="normal"><sp/><sp/>forceinline</highlight></codeline>
|
|
<codeline lineno="78"><highlight class="normal"><sp/><sp/>FastMutex::FastMutex(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)<sp/>:<sp/>lck(OS_SPINLOCK_INIT)<sp/>{}</highlight></codeline>
|
|
<codeline lineno="79"><highlight class="normal"><sp/><sp/>forceinline<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="80"><highlight class="normal"><sp/><sp/><ref refid="classGecode_1_1Support_1_1Mutex_1ae22b5dc6f88bc5443025a123fb51cd65" kindref="member">FastMutex::acquire</ref>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)<sp/>{</highlight></codeline>
|
|
<codeline lineno="81"><highlight class="normal"><sp/><sp/><sp/><sp/>OSSpinLockLock(&lck);</highlight></codeline>
|
|
<codeline lineno="82"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
|
|
<codeline lineno="83"><highlight class="normal"><sp/><sp/>forceinline<sp/></highlight><highlight class="keywordtype">bool</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="84"><highlight class="normal"><sp/><sp/><ref refid="classGecode_1_1Support_1_1Mutex_1a92cfac9a089b0b28414f4fc1e19aabde" kindref="member">FastMutex::tryacquire</ref>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)<sp/>{</highlight></codeline>
|
|
<codeline lineno="85"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>OSSpinLockTry(&lck);</highlight></codeline>
|
|
<codeline lineno="86"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
|
|
<codeline lineno="87"><highlight class="normal"><sp/><sp/>forceinline<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="88"><highlight class="normal"><sp/><sp/><ref refid="classGecode_1_1Support_1_1Mutex_1a92125d0bf014be03be0a8d0d879cff8e" kindref="member">FastMutex::release</ref>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)<sp/>{</highlight></codeline>
|
|
<codeline lineno="89"><highlight class="normal"><sp/><sp/><sp/><sp/>OSSpinLockUnlock(&lck);</highlight></codeline>
|
|
<codeline lineno="90"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
|
|
<codeline lineno="91"><highlight class="normal"><sp/><sp/>forceinline</highlight></codeline>
|
|
<codeline lineno="92"><highlight class="normal"><sp/><sp/>FastMutex::~FastMutex(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)<sp/>{}</highlight></codeline>
|
|
<codeline lineno="93"><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="94"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight></codeline>
|
|
<codeline lineno="95"><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="96"><highlight class="normal"></highlight><highlight class="preprocessor">#ifdef<sp/>GECODE_THREADS_PTHREADS_SPINLOCK</highlight></codeline>
|
|
<codeline lineno="97"><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="98"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*</highlight></codeline>
|
|
<codeline lineno="99"><highlight class="comment"><sp/><sp/><sp/>*<sp/>FastMutex</highlight></codeline>
|
|
<codeline lineno="100"><highlight class="comment"><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="101"><highlight class="normal"><sp/><sp/>forceinline</highlight></codeline>
|
|
<codeline lineno="102"><highlight class="normal"><sp/><sp/>FastMutex::FastMutex(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)<sp/>{</highlight></codeline>
|
|
<codeline lineno="103"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pthread_spin_init(&p_s,PTHREAD_PROCESS_PRIVATE)<sp/>!=<sp/>0)</highlight></codeline>
|
|
<codeline lineno="104"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">throw</highlight><highlight class="normal"><sp/>OperatingSystemError(</highlight><highlight class="stringliteral">"FastMutex::FastMutex[pthread_spin_init]"</highlight><highlight class="normal">);</highlight></codeline>
|
|
<codeline lineno="105"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
|
|
<codeline lineno="106"><highlight class="normal"><sp/><sp/>forceinline<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="107"><highlight class="normal"><sp/><sp/><ref refid="classGecode_1_1Support_1_1Mutex_1ae22b5dc6f88bc5443025a123fb51cd65" kindref="member">FastMutex::acquire</ref>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)<sp/>{</highlight></codeline>
|
|
<codeline lineno="108"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pthread_spin_lock(&p_s)<sp/>!=<sp/>0)</highlight></codeline>
|
|
<codeline lineno="109"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">throw</highlight><highlight class="normal"><sp/>OperatingSystemError(</highlight><highlight class="stringliteral">"FastMutex::acquire[pthread_spin_lock]"</highlight><highlight class="normal">);</highlight></codeline>
|
|
<codeline lineno="110"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
|
|
<codeline lineno="111"><highlight class="normal"><sp/><sp/>forceinline<sp/></highlight><highlight class="keywordtype">bool</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="112"><highlight class="normal"><sp/><sp/><ref refid="classGecode_1_1Support_1_1Mutex_1a92cfac9a089b0b28414f4fc1e19aabde" kindref="member">FastMutex::tryacquire</ref>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)<sp/>{</highlight></codeline>
|
|
<codeline lineno="113"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>pthread_spin_trylock(&p_s)<sp/>==<sp/>0;</highlight></codeline>
|
|
<codeline lineno="114"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
|
|
<codeline lineno="115"><highlight class="normal"><sp/><sp/>forceinline<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="116"><highlight class="normal"><sp/><sp/><ref refid="classGecode_1_1Support_1_1Mutex_1a92125d0bf014be03be0a8d0d879cff8e" kindref="member">FastMutex::release</ref>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)<sp/>{</highlight></codeline>
|
|
<codeline lineno="117"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pthread_spin_unlock(&p_s)<sp/>!=<sp/>0)</highlight></codeline>
|
|
<codeline lineno="118"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">throw</highlight><highlight class="normal"><sp/>OperatingSystemError(</highlight><highlight class="stringliteral">"FastMutex::release[pthread_spin_unlock]"</highlight><highlight class="normal">);</highlight></codeline>
|
|
<codeline lineno="119"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
|
|
<codeline lineno="120"><highlight class="normal"><sp/><sp/>forceinline</highlight></codeline>
|
|
<codeline lineno="121"><highlight class="normal"><sp/><sp/>FastMutex::~FastMutex(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)<sp/>{</highlight></codeline>
|
|
<codeline lineno="122"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pthread_spin_destroy(&p_s)<sp/>!=<sp/>0)</highlight></codeline>
|
|
<codeline lineno="123"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">throw</highlight><highlight class="normal"><sp/>OperatingSystemError(</highlight></codeline>
|
|
<codeline lineno="124"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">"FastMutex::~FastMutex[pthread_spin_destroy]"</highlight><highlight class="normal">);</highlight></codeline>
|
|
<codeline lineno="125"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
|
|
<codeline lineno="126"><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="127"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight></codeline>
|
|
<codeline lineno="128"><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="129"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*</highlight></codeline>
|
|
<codeline lineno="130"><highlight class="comment"><sp/><sp/><sp/>*<sp/>Event</highlight></codeline>
|
|
<codeline lineno="131"><highlight class="comment"><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="132"><highlight class="normal"><sp/><sp/>forceinline</highlight></codeline>
|
|
<codeline lineno="133"><highlight class="normal"><sp/><sp/><ref refid="classGecode_1_1Support_1_1Event_1a6bee44181f2deb231062ca33b79d448a" kindref="member">Event::Event</ref>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)<sp/>:<sp/>p_s(false)<sp/>{</highlight></codeline>
|
|
<codeline lineno="134"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pthread_mutex_init(&p_m,NULL)<sp/>!=<sp/>0)</highlight></codeline>
|
|
<codeline lineno="135"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">throw</highlight><highlight class="normal"><sp/>OperatingSystemError(</highlight><highlight class="stringliteral">"Event::Event[pthread_mutex_init]"</highlight><highlight class="normal">);</highlight></codeline>
|
|
<codeline lineno="136"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pthread_cond_init(&p_c,NULL)<sp/>!=<sp/>0)</highlight></codeline>
|
|
<codeline lineno="137"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">throw</highlight><highlight class="normal"><sp/>OperatingSystemError(</highlight><highlight class="stringliteral">"Event::Event[pthread_cond_init]"</highlight><highlight class="normal">);</highlight></codeline>
|
|
<codeline lineno="138"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
|
|
<codeline lineno="139"><highlight class="normal"><sp/><sp/>forceinline<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="140"><highlight class="normal"><sp/><sp/><ref refid="classGecode_1_1Support_1_1Event_1a3c9d350c4c28239ebe2ff5b3ec240a05" kindref="member">Event::signal</ref>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)<sp/>{</highlight></codeline>
|
|
<codeline lineno="141"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pthread_mutex_lock(&p_m)<sp/>!=<sp/>0)</highlight></codeline>
|
|
<codeline lineno="142"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">throw</highlight><highlight class="normal"><sp/>OperatingSystemError(</highlight><highlight class="stringliteral">"Event::signal[pthread_mutex_lock]"</highlight><highlight class="normal">);</highlight></codeline>
|
|
<codeline lineno="143"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(!p_s)<sp/>{</highlight></codeline>
|
|
<codeline lineno="144"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>p_s<sp/>=<sp/></highlight><highlight class="keyword">true</highlight><highlight class="normal">;</highlight></codeline>
|
|
<codeline lineno="145"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pthread_cond_signal(&p_c)<sp/>!=<sp/>0)</highlight></codeline>
|
|
<codeline lineno="146"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">throw</highlight><highlight class="normal"><sp/>OperatingSystemError(</highlight><highlight class="stringliteral">"Event::signal[pthread_cond_signal]"</highlight><highlight class="normal">);</highlight></codeline>
|
|
<codeline lineno="147"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
|
|
<codeline lineno="148"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pthread_mutex_unlock(&p_m)<sp/>!=<sp/>0)</highlight></codeline>
|
|
<codeline lineno="149"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">throw</highlight><highlight class="normal"><sp/>OperatingSystemError(</highlight><highlight class="stringliteral">"Event::signal[pthread_mutex_unlock]"</highlight><highlight class="normal">);</highlight></codeline>
|
|
<codeline lineno="150"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
|
|
<codeline lineno="151"><highlight class="normal"><sp/><sp/>forceinline<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="152"><highlight class="normal"><sp/><sp/><ref refid="classGecode_1_1Support_1_1Event_1ae0d63ad5ddbbe0677a853bb07028da43" kindref="member">Event::wait</ref>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)<sp/>{</highlight></codeline>
|
|
<codeline lineno="153"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pthread_mutex_lock(&p_m)<sp/>!=<sp/>0)</highlight></codeline>
|
|
<codeline lineno="154"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">throw</highlight><highlight class="normal"><sp/>OperatingSystemError(</highlight><highlight class="stringliteral">"Event::wait[pthread_mutex_lock]"</highlight><highlight class="normal">);</highlight></codeline>
|
|
<codeline lineno="155"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(!p_s)</highlight></codeline>
|
|
<codeline lineno="156"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pthread_cond_wait(&p_c,&p_m)<sp/>!=<sp/>0)</highlight></codeline>
|
|
<codeline lineno="157"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">throw</highlight><highlight class="normal"><sp/>OperatingSystemError(</highlight><highlight class="stringliteral">"Event::wait[pthread_cond_wait]"</highlight><highlight class="normal">);</highlight></codeline>
|
|
<codeline lineno="158"><highlight class="normal"><sp/><sp/><sp/><sp/>p_s<sp/>=<sp/></highlight><highlight class="keyword">false</highlight><highlight class="normal">;</highlight></codeline>
|
|
<codeline lineno="159"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pthread_mutex_unlock(&p_m)<sp/>!=<sp/>0)</highlight></codeline>
|
|
<codeline lineno="160"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">throw</highlight><highlight class="normal"><sp/>OperatingSystemError(</highlight><highlight class="stringliteral">"Event::wait[pthread_mutex_unlock]"</highlight><highlight class="normal">);</highlight></codeline>
|
|
<codeline lineno="161"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
|
|
<codeline lineno="162"><highlight class="normal"><sp/><sp/>forceinline</highlight></codeline>
|
|
<codeline lineno="163"><highlight class="normal"><sp/><sp/><ref refid="classGecode_1_1Support_1_1Event_1a244fc8b05c8a8da34a3bb2f1cb706bfe" kindref="member">Event::~Event</ref>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)<sp/>{</highlight></codeline>
|
|
<codeline lineno="164"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pthread_cond_destroy(&p_c)<sp/>!=<sp/>0)</highlight></codeline>
|
|
<codeline lineno="165"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">throw</highlight><highlight class="normal"><sp/>OperatingSystemError(</highlight><highlight class="stringliteral">"Event::~Event[pthread_cond_destroy]"</highlight><highlight class="normal">);</highlight></codeline>
|
|
<codeline lineno="166"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(pthread_mutex_destroy(&p_m)<sp/>!=<sp/>0)</highlight></codeline>
|
|
<codeline lineno="167"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">throw</highlight><highlight class="normal"><sp/>OperatingSystemError(</highlight><highlight class="stringliteral">"Event::~Event[pthread_mutex_destroy]"</highlight><highlight class="normal">);</highlight></codeline>
|
|
<codeline lineno="168"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
|
|
<codeline lineno="169"><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="170"><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="171"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">/*</highlight></codeline>
|
|
<codeline lineno="172"><highlight class="comment"><sp/><sp/><sp/>*<sp/>Thread</highlight></codeline>
|
|
<codeline lineno="173"><highlight class="comment"><sp/><sp/><sp/>*/</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="174"><highlight class="normal"><sp/><sp/>forceinline<sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="175"><highlight class="normal"><sp/><sp/><ref refid="classGecode_1_1Support_1_1Thread_1af611b4225dd41e10d676174b33a1c20d" kindref="member">Thread::sleep</ref>(</highlight><highlight class="keywordtype">unsigned</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>ms)<sp/>{</highlight></codeline>
|
|
<codeline lineno="176"><highlight class="normal"></highlight><highlight class="preprocessor">#ifdef<sp/>GECODE_HAS_UNISTD_H</highlight></codeline>
|
|
<codeline lineno="177"><highlight class="preprocessor"></highlight><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">unsigned</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>s<sp/>=<sp/>ms<sp/>/<sp/>1000;</highlight></codeline>
|
|
<codeline lineno="178"><highlight class="normal"><sp/><sp/><sp/><sp/>ms<sp/>-=<sp/>1000<sp/>*<sp/>s;</highlight></codeline>
|
|
<codeline lineno="179"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(s<sp/>><sp/>0)<sp/>{</highlight></codeline>
|
|
<codeline lineno="180"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>More<sp/>than<sp/>one<sp/>million<sp/>microseconds,<sp/>use<sp/>sleep</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="181"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classGecode_1_1Support_1_1Thread_1af611b4225dd41e10d676174b33a1c20d" kindref="member">::sleep</ref>(s);</highlight></codeline>
|
|
<codeline lineno="182"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
|
|
<codeline lineno="183"><highlight class="normal"><sp/><sp/><sp/><sp/>usleep(ms<sp/>*<sp/>1000);</highlight></codeline>
|
|
<codeline lineno="184"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight></codeline>
|
|
<codeline lineno="185"><highlight class="preprocessor"></highlight><highlight class="normal"><sp/><sp/>}</highlight></codeline>
|
|
<codeline lineno="186"><highlight class="normal"><sp/><sp/>forceinline<sp/></highlight><highlight class="keywordtype">unsigned</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="187"><highlight class="normal"><sp/><sp/><ref refid="classGecode_1_1Support_1_1Thread_1a0a2cdc9558a3716a243e364ca21f2caf" kindref="member">Thread::npu</ref>(</highlight><highlight class="keywordtype">void</highlight><highlight class="normal">)<sp/>{</highlight></codeline>
|
|
<codeline lineno="188"><highlight class="normal"></highlight><highlight class="preprocessor">#ifdef<sp/>GECODE_HAS_UNISTD_H</highlight></codeline>
|
|
<codeline lineno="189"><highlight class="preprocessor"></highlight><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>n=</highlight><highlight class="keyword">static_cast<</highlight><highlight class="keywordtype">int</highlight><highlight class="keyword">></highlight><highlight class="normal">(sysconf(_SC_NPROCESSORS_ONLN));</highlight></codeline>
|
|
<codeline lineno="190"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>(n>1)<sp/>?<sp/>n<sp/>:<sp/>1;</highlight></codeline>
|
|
<codeline lineno="191"><highlight class="normal"></highlight><highlight class="preprocessor">#else</highlight></codeline>
|
|
<codeline lineno="192"><highlight class="preprocessor"></highlight><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>1;</highlight></codeline>
|
|
<codeline lineno="193"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight></codeline>
|
|
<codeline lineno="194"><highlight class="preprocessor"></highlight><highlight class="normal"><sp/><sp/>}</highlight></codeline>
|
|
<codeline lineno="195"><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="196"><highlight class="normal">}}</highlight></codeline>
|
|
<codeline lineno="197"><highlight class="normal"></highlight></codeline>
|
|
<codeline lineno="198"><highlight class="normal"></highlight><highlight class="comment">//<sp/>STATISTICS:<sp/>support-any</highlight><highlight class="normal"></highlight></codeline>
|
|
</programlisting>
|
|
<location file="/usr/include/gecode/support/thread/pthreads.hpp"/>
|
|
</compounddef>
|
|
</doxygen>
|