reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
WorkerThread.cxx
Go to the documentation of this file.
2
5#include "rutil/Logger.hxx"
6
7#define RESIPROCATE_SUBSYSTEM resip::Subsystem::SIP
8
9namespace resip
10{
11
14 resip::SipStack* stack):
15 mWorker(worker),
16 mFifo(fifo),
17 mStack(stack)
18{}
19
21{
22 shutdown();
23 join();
24 delete mWorker;
25}
26
27void
29{
31 bool queueToStack;
32 if(mWorker && !isShutdown())
33 {
35 while(mWorker && !isShutdown())
36 {
37 if( (msg=mFifo.getNext(100)) != 0 )
38 {
39 queueToStack = mWorker->process(msg);
40
41 if(queueToStack && mStack)
42 {
43 StackLog(<<"async work done, posting to stack");
44 // Post to stack instead of directly to TU, since stack does
45 // some safety checks to ensure the TU still exists before posting
46 mStack->post(std::unique_ptr<resip::ApplicationMessage>(msg));
47 }
48 else
49 {
50 StackLog(<<"discarding a message");
51 if(!mStack)
52 {
53 WarningLog(<<"mStack == 0");
54 }
55 delete msg;
56 }
57 }
58 }
59 }
60}
61
62}//namespace resip
63
64/* ====================================================================
65 * The Vovida Software License, Version 1.0
66 *
67 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
68 *
69 * Redistribution and use in source and binary forms, with or without
70 * modification, are permitted provided that the following conditions
71 * are met:
72 *
73 * 1. Redistributions of source code must retain the above copyright
74 * notice, this list of conditions and the following disclaimer.
75 *
76 * 2. Redistributions in binary form must reproduce the above copyright
77 * notice, this list of conditions and the following disclaimer in
78 * the documentation and/or other materials provided with the
79 * distribution.
80 *
81 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
82 * and "Vovida Open Communication Application Library (VOCAL)" must
83 * not be used to endorse or promote products derived from this
84 * software without prior written permission. For written
85 * permission, please contact vocal@vovida.org.
86 *
87 * 4. Products derived from this software may not be called "VOCAL", nor
88 * may "VOCAL" appear in their name, without prior written
89 * permission of Vovida Networks, Inc.
90 *
91 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
92 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
93 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
94 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
95 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
96 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
97 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
98 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
99 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
100 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
101 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
102 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
103 * DAMAGE.
104 *
105 * ====================================================================
106 *
107 * This software consists of voluntary contributions made by Vovida
108 * Networks, Inc. and many individuals on behalf of Vovida Networks,
109 * Inc. For more information on Vovida Networks, Inc., please see
110 * <http://www.vovida.org/>.
111 *
112 */
#define StackLog(args_)
Definition Logger.hxx:125
#define WarningLog(args_)
Definition Logger.hxx:134
A base-class for messages used by applications.
This is the primary point of interaction between the app-layer and the stack.
Definition SipStack.hxx:160
void post(std::unique_ptr< ApplicationMessage > message, unsigned int secondsLater, TransactionUser *tu=0)
Makes the message available to the TU at some later time, specified in seconds.
virtual void shutdown()
Definition ThreadIf.cxx:190
bool isShutdown() const
Definition ThreadIf.cxx:212
Msg * getNext()
Returns the first message available.
WorkerThread(Worker *impl, resip::TimeLimitFifo< resip::ApplicationMessage > &fifo, resip::SipStack *stack)
resip::TimeLimitFifo< resip::ApplicationMessage > & mFifo
resip::SipStack * mStack
virtual bool process(resip::ApplicationMessage *msg)=0
virtual void onStart()
Definition Worker.hxx:17
dcm! – add UnusedChecking(_enum) below;