Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 1699

Show
Ignore:
Timestamp:
06/30/10 18:32:04 (14 years ago)
Author:
sean
Message:

Fixed receiveTimeout.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/phobos/std/concurrency.d

    r1696 r1699  
    583583            } 
    584584        } 
    585585         
    586586         
    587587        /* 
    588588         * Matches ops against each message in turn until a match is found. 
    589589         * 
    590590         * Params: 
    591591         *  ops = The operations to match.  Each may return a bool to indicate 
    592592         *        whether a message with a matching type is truly a match. 
     593         * 
     594         * Returns: 
     595         *  true if a message was retrieved and false if not (such as if a 
     596         *  timeout occurred). 
    593597         *  
    594598         * Throws: 
    595599         *  LinkTerminated if a linked thread terminated, or OwnerTerminated 
    596600         * if the owner thread terminates and no existing messages match the 
    597601         * supplied ops. 
    598602         */ 
    599         final void get(T...)( T vals ) 
     603        final bool get(T...)( T vals ) 
    600604        { 
    601605            static assert( T.length ); 
    602606 
    603607            static if( isImplicitlyConvertible!(T[0], long) ) 
    604608            { 
    605609                alias TypeTuple!(T[1 .. $]) Ops; 
    606610                alias vals[1 .. $] ops; 
    607611                assert( vals[0] >= 0 ); 
    608612                enum timedWait = true; 
    609613                long period = vals[0]; 
     
    761765                return false; 
    762766            } 
    763767             
    764768            while( true ) 
    765769            { 
    766770                ListT arrived; 
    767771 
    768772                if( pty( m_localPty ) || 
    769773                    scan( m_localBox ) ) 
    770774                { 
    771                     return
     775                    return true
    772776                } 
    773777                synchronized( m_lock ) 
    774778                { 
    775779                    updateMsgCount(); 
    776780                    while( m_sharedPty.empty && m_sharedBox.empty ) 
    777781                    { 
    778782                        if( ownerDead ) 
    779783                            onOwnerDead(); 
    780784                        // NOTE: We're notifying all waiters here instead of just 
    781785                        //       a few because the onCrowding behavior may have 
    782786                        //       changed and we don't want to block sender threads 
    783787                        //       unnecessarily if the new behavior is not to block. 
    784788                        //       This will admittedly result in spurious wakeups 
    785789                        //       in other situations, but what can you do? 
    786790                        if( m_putQueue && !mboxFull() ) 
    787791                            m_notFull.notifyAll(); 
    788792                        static if( timedWait ) 
    789                             m_putMsg.wait( period ); 
     793                        { 
     794                            if( !m_putMsg.wait( period ) ) 
     795                                return false; 
     796                        } 
    790797                        else 
     798                        { 
    791799                            m_putMsg.wait(); 
     800                        } 
    792801                    } 
    793802                    m_localPty.put( m_sharedPty ); 
    794803                    arrived.put( m_sharedBox ); 
    795804                } 
    796805                if( m_localPty.empty ) 
    797806                { 
    798807                    bool ok = scan( arrived ); 
    799808                    m_localBox.put( arrived ); 
    800                     if( ok ) return
     809                    if( ok ) return true
    801810                    else continue; 
    802811                } 
    803812                m_localBox.put( arrived ); 
    804813                pty( m_localPty ); 
    805                 return
     814                return true
    806815            } 
    807816        } 
    808817         
    809818         
    810819        /* 
    811820         * Called on thread termination.  This routine processes any remaining 
    812821         * control messages, clears out message queues, and sets a flag to 
    813822         * reject any future messages. 
    814823         */ 
    815824        final void close()