svn cleanup
[anytun.git] / anyrtpproxy / callIdQueue.cpp
blobbc90f085d99e97a9117e76980563082946dc64ea
1 /*
2 * anytun
4 * The secure anycast tunneling protocol (satp) defines a protocol used
5 * for communication between any combination of unicast and anycast
6 * tunnel endpoints. It has less protocol overhead than IPSec in Tunnel
7 * mode and allows tunneling of every ETHER TYPE protocol (e.g.
8 * ethernet, ip, arp ...). satp directly includes cryptography and
9 * message authentication based on the methodes used by SRTP. It is
10 * intended to deliver a generic, scaleable and secure solution for
11 * tunneling and relaying of packets of any protocol.
14 * Copyright (C) 2007 anytun.org <satp@wirdorange.org>
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License version 2
18 * as published by the Free Software Foundation.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program (see the file COPYING included with this
27 * distribution); if not, write to the Free Software Foundation, Inc.,
28 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #include "callIdQueue.h"
33 CallIdQueue* CallIdQueue::inst = NULL;
34 Mutex CallIdQueue::instMutex;
35 CallIdQueue& gCallIdQueue = CallIdQueue::instance();
37 CallIdQueue& CallIdQueue::instance()
39 Lock lock(instMutex);
40 static instanceCleaner c;
41 if(!inst)
42 inst = new CallIdQueue();
44 return *inst;
47 CallIdQueue::CallIdQueue()
51 CallIdQueue::~CallIdQueue()
53 while(!callids_.empty())
54 pop();
57 std::string& CallIdQueue::front()
59 sem_.down();
60 Lock lock(mutex_);
61 return callids_.front();
64 void CallIdQueue::push(std::string c)
66 Lock lock(mutex_);
67 callids_.push(c);
68 sem_.up();
71 void CallIdQueue::pop()
73 Lock lock(mutex_);
74 callids_.pop();