reSIProcate/stack  9359
SelectInterruptor.hxx
Go to the documentation of this file.
00001 #ifndef RESIP_SelectInterruptor_HXX
00002 #define RESIP_SelectInterruptor_HXX
00003 
00004 #include "rutil/AsyncProcessHandler.hxx"
00005 #include "rutil/Socket.hxx"
00006 
00007 #if 0
00008 #if defined(WIN32)
00009 #include <Ws2tcpip.h>
00010 #else
00011 #include <netinet/in.h>
00012 #endif
00013 #endif
00014 
00015 namespace resip
00016 {
00017 
00021 class SelectInterruptor : public AsyncProcessHandler
00022 {
00023    public:
00024       SelectInterruptor();
00025       virtual ~SelectInterruptor();
00026 
00031       virtual void handleProcessNotification();
00032 
00036       void interrupt();
00037 
00043       void buildFdSet(FdSet& fdset);
00044 
00048       void process(FdSet& fdset);
00049    protected:
00050       /* Get fd of read-side, for use within PollInterruptor,
00051        * Declared as Socket for easier cross-platform even though pipe fd
00052        * under linux.
00053        */
00054       Socket getReadSocket() const { return mReadThing; }
00055 
00056       /* Cleanup the read side of the interruptor
00057        * If fdset is provided, it will only try cleaning up if our pipe
00058        * is ready in fdset. If NULL, it will unconditionally try reading.
00059        * This last feature is for use within PollInterruptor.
00060        */
00061       void processCleanup();
00062    private:
00063 #ifndef WIN32
00064       int mPipe[2];
00065 #else
00066       Socket mSocket;
00067       sockaddr mWakeupAddr;
00068 #endif
00069       // either mPipe[0] or mSocket
00070       Socket mReadThing;
00071 };
00072 
00073 }
00074 
00075 #endif
00076 
00077 /* ====================================================================
00078  * The Vovida Software License, Version 1.0
00079  *
00080  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00081  *
00082  * Redistribution and use in source and binary forms, with or without
00083  * modification, are permitted provided that the following conditions
00084  * are met:
00085  *
00086  * 1. Redistributions of source code must retain the above copyright
00087  *    notice, this list of conditions and the following disclaimer.
00088  *
00089  * 2. Redistributions in binary form must reproduce the above copyright
00090  *    notice, this list of conditions and the following disclaimer in
00091  *    the documentation and/or other materials provided with the
00092  *    distribution.
00093  *
00094  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00095  *    and "Vovida Open Communication Application Library (VOCAL)" must
00096  *    not be used to endorse or promote products derived from this
00097  *    software without prior written permission. For written
00098  *    permission, please contact vocal@vovida.org.
00099  *
00100  * 4. Products derived from this software may not be called "VOCAL", nor
00101  *    may "VOCAL" appear in their name, without prior written
00102  *    permission of Vovida Networks, Inc.
00103  *
00104  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00105  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00106  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00107  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00108  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00109  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00110  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00111  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00112  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00113  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00114  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00115  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00116  * DAMAGE.
00117  *
00118  * ====================================================================
00119  *
00120  * This software consists of voluntary contributions made by Vovida
00121  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00122  * Inc.  For more information on Vovida Networks, Inc., please see
00123  * <http://www.vovida.org/>.
00124  *
00125  * vi: set shiftwidth=3 expandtab:
00126  */