reSIProcate/stack  9694
StackThread.cxx
Go to the documentation of this file.
00001 #include "resip/stack/StackThread.hxx"
00002 #include "resip/stack/SipStack.hxx"
00003 #include "resip/stack/SipMessage.hxx"
00004 #include "rutil/Logger.hxx"
00005 
00006 #define RESIPROCATE_SUBSYSTEM Subsystem::SIP
00007 
00008 using namespace resip;
00009 
00010 StackThread::StackThread(SipStack& stack)
00011    : mStack(stack)
00012 {}
00013 
00014 StackThread::~StackThread()
00015 {
00016    //InfoLog (<< "StackThread::~StackThread()");
00017 }
00018 
00019 void
00020 StackThread::thread()
00021 {
00022    while (!isShutdown())
00023    {
00024       try
00025       {
00026          resip::FdSet fdset;
00027          buildFdSet(fdset);
00028          mStack.buildFdSet(fdset);
00029                  int ret = fdset.selectMilliSeconds(resipMin(mStack.getTimeTillNextProcessMS(),
00030                                                      getTimeTillNextProcessMS()));
00031          if (ret >= 0)
00032          {
00033             // .dlb. use return value to peek at the message to see if it is a
00034             // shutdown, and call shutdown if it is
00035             beforeProcess();
00036             mStack.process(fdset);
00037             afterProcess();
00038          }
00039       }
00040       catch (BaseException& e)
00041       {
00042          ErrLog (<< "Unhandled exception: " << e);
00043       }
00044    }
00045    WarningLog (<< "Shutting down stack thread");
00046 }
00047 
00048 void
00049 StackThread::buildFdSet(FdSet& fdset)
00050 {}
00051 
00052 unsigned int
00053 StackThread::getTimeTillNextProcessMS() const
00054 {
00055 //   !dcm! moved the 25 ms min logic here
00056 //   return INT_MAX;
00057    return 25;   
00058 }
00059 
00060 /* ====================================================================
00061  * The Vovida Software License, Version 1.0 
00062  * 
00063  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00064  * 
00065  * Redistribution and use in source and binary forms, with or without
00066  * modification, are permitted provided that the following conditions
00067  * are met:
00068  * 
00069  * 1. Redistributions of source code must retain the above copyright
00070  *    notice, this list of conditions and the following disclaimer.
00071  * 
00072  * 2. Redistributions in binary form must reproduce the above copyright
00073  *    notice, this list of conditions and the following disclaimer in
00074  *    the documentation and/or other materials provided with the
00075  *    distribution.
00076  * 
00077  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00078  *    and "Vovida Open Communication Application Library (VOCAL)" must
00079  *    not be used to endorse or promote products derived from this
00080  *    software without prior written permission. For written
00081  *    permission, please contact vocal@vovida.org.
00082  *
00083  * 4. Products derived from this software may not be called "VOCAL", nor
00084  *    may "VOCAL" appear in their name, without prior written
00085  *    permission of Vovida Networks, Inc.
00086  * 
00087  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00088  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00089  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00090  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00091  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00092  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00093  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00094  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00095  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00096  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00097  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00098  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00099  * DAMAGE.
00100  * 
00101  * ====================================================================
00102  * 
00103  * This software consists of voluntary contributions made by Vovida
00104  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00105  * Inc.  For more information on Vovida Networks, Inc., please see
00106  * <http://www.vovida.org/>.
00107  *
00108  */