summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Anthony Giusti <kgiusti@apache.org>2011-02-18 15:05:55 +0000
committerKenneth Anthony Giusti <kgiusti@apache.org>2011-02-18 15:05:55 +0000
commite0f84a182936fb0c1e01db9c9339c864e02525b9 (patch)
tree77c5b1f8dd62d68fde0013f9c147140b7f87a3b1
parent3b096e5e16d683590e6a46799d1c220a7fbd1b04 (diff)
downloadqpid-python-e0f84a182936fb0c1e01db9c9339c864e02525b9.tar.gz
QPID-2935: fix cmake build on linux
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/qpid-2935@1072016 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/src/qpid/broker/IncompleteMessageList.cpp85
-rw-r--r--qpid/cpp/src/qpid/broker/IncompleteMessageList.h58
-rw-r--r--qpid/cpp/src/tests/CMakeLists.txt1
-rw-r--r--qpid/cpp/src/tests/IncompleteMessageList.cpp134
4 files changed, 0 insertions, 278 deletions
diff --git a/qpid/cpp/src/qpid/broker/IncompleteMessageList.cpp b/qpid/cpp/src/qpid/broker/IncompleteMessageList.cpp
deleted file mode 100644
index 34d92fa752..0000000000
--- a/qpid/cpp/src/qpid/broker/IncompleteMessageList.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-#include "qpid/broker/IncompleteMessageList.h"
-
-namespace qpid {
-namespace broker {
-
-IncompleteMessageList::IncompleteMessageList() :
- callback(boost::bind(&IncompleteMessageList::enqueueComplete, this, _1))
-{}
-
-IncompleteMessageList::~IncompleteMessageList()
-{
- // No lock here. We are relying on Messsag::reset*CompleteCallback
- // to ensure no callbacks are in progress before they return.
- for (Messages::iterator i = incomplete.begin(); i != incomplete.end(); ++i) {
- (*i)->resetEnqueueCompleteCallback();
- (*i)->resetDequeueCompleteCallback();
- }
-}
-
-void IncompleteMessageList::add(boost::intrusive_ptr<Message> msg)
-{
- sys::Mutex::ScopedLock l(lock);
- msg->setEnqueueCompleteCallback(callback);
- incomplete.push_back(msg);
-}
-
-void IncompleteMessageList::enqueueComplete(const boost::intrusive_ptr<Message>& ) {
- sys::Mutex::ScopedLock l(lock);
- lock.notify();
-}
-
-void IncompleteMessageList::process(const CompletionListener& listen, bool sync)
-{
- sys::Mutex::ScopedLock l(lock);
- while (!incomplete.empty()) {
- boost::intrusive_ptr<Message>& msg = incomplete.front();
- if (!msg->isEnqueueComplete()) {
- if (sync){
- {
- sys::Mutex::ScopedUnlock u(lock);
- msg->flush(); // Can re-enter IncompleteMessageList::enqueueComplete
- }
- while (!msg->isEnqueueComplete())
- lock.wait();
- } else {
- //leave the message as incomplete for now
- return;
- }
- }
- listen(msg);
- incomplete.pop_front();
- }
-}
-
-void IncompleteMessageList::each(const CompletionListener& listen) {
- Messages snapshot;
- {
- sys::Mutex::ScopedLock l(lock);
- snapshot = incomplete;
- }
- std::for_each(incomplete.begin(), incomplete.end(), listen);
-}
-
-}}
diff --git a/qpid/cpp/src/qpid/broker/IncompleteMessageList.h b/qpid/cpp/src/qpid/broker/IncompleteMessageList.h
deleted file mode 100644
index a4debd1233..0000000000
--- a/qpid/cpp/src/qpid/broker/IncompleteMessageList.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-#ifndef _IncompleteMessageList_
-#define _IncompleteMessageList_
-
-#include "qpid/broker/BrokerImportExport.h"
-#include "qpid/sys/Monitor.h"
-#include "qpid/broker/Message.h"
-#include <boost/intrusive_ptr.hpp>
-#include <boost/function.hpp>
-#include <list>
-
-namespace qpid {
-namespace broker {
-
-class IncompleteMessageList
-{
- typedef std::list< boost::intrusive_ptr<Message> > Messages;
-
- void enqueueComplete(const boost::intrusive_ptr<Message>&);
-
- sys::Monitor lock;
- Messages incomplete;
- Message::MessageCallback callback;
-
-public:
- typedef Message::MessageCallback CompletionListener;
-
- QPID_BROKER_EXTERN IncompleteMessageList();
- QPID_BROKER_EXTERN ~IncompleteMessageList();
-
- QPID_BROKER_EXTERN void add(boost::intrusive_ptr<Message> msg);
- QPID_BROKER_EXTERN void process(const CompletionListener& l, bool sync);
- void each(const CompletionListener& l);
-};
-
-
-}}
-
-#endif
diff --git a/qpid/cpp/src/tests/CMakeLists.txt b/qpid/cpp/src/tests/CMakeLists.txt
index cf065e1ba9..405718f12b 100644
--- a/qpid/cpp/src/tests/CMakeLists.txt
+++ b/qpid/cpp/src/tests/CMakeLists.txt
@@ -107,7 +107,6 @@ set(unit_tests_to_build
MessagingSessionTests
SequenceSet
StringUtils
- IncompleteMessageList
RangeSet
AtomicValue
QueueTest
diff --git a/qpid/cpp/src/tests/IncompleteMessageList.cpp b/qpid/cpp/src/tests/IncompleteMessageList.cpp
deleted file mode 100644
index 10782572e5..0000000000
--- a/qpid/cpp/src/tests/IncompleteMessageList.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-#include <iostream>
-#include <sstream>
-#include "qpid/broker/Message.h"
-#include "qpid/broker/NullMessageStore.h"
-#include "qpid/broker/Queue.h"
-#include "qpid/broker/IncompleteMessageList.h"
-
-#include "unit_test.h"
-
-namespace qpid {
-namespace tests {
-
-QPID_AUTO_TEST_SUITE(IncompleteMessageListTestSuite)
-
-using namespace qpid::broker;
-using namespace qpid::framing;
-
-struct Checker
-{
- std::list<SequenceNumber> ids;
-
- Checker() { }
-
- Checker(uint start, uint end) {
- for (uint i = start; i <= end; i++) {
- ids.push_back(i);
- }
- }
-
- Checker& expect(const SequenceNumber& id) {
- ids.push_back(id);
- return *this;
- }
-
- void operator()(boost::intrusive_ptr<Message> msg) {
- BOOST_CHECK(!ids.empty());
- BOOST_CHECK_EQUAL(msg->getCommandId(), ids.front());
- ids.pop_front();
- }
-};
-
-QPID_AUTO_TEST_CASE(testProcessSimple)
-{
- IncompleteMessageList list;
- SequenceNumber counter(1);
- //fill up list with messages
- for (int i = 0; i < 5; i++) {
- boost::intrusive_ptr<Message> msg(new Message(counter++));
- list.add(msg);
- }
- //process and ensure they are all passed to completion listener
- list.process(Checker(1, 5), false);
- //process again and ensure none are resent to listener
- list.process(Checker(), false);
-}
-
-QPID_AUTO_TEST_CASE(testProcessWithIncomplete)
-{
- Queue::shared_ptr queue;
- IncompleteMessageList list;
- SequenceNumber counter(1);
- boost::intrusive_ptr<Message> middle;
- //fill up list with messages
- for (int i = 0; i < 5; i++) {
- boost::intrusive_ptr<Message> msg(new Message(counter++));
- list.add(msg);
- if (i == 2) {
- //mark a message in the middle as incomplete
- msg->enqueueAsync(queue, 0);
- middle = msg;
- }
- }
- //process and ensure only message upto incomplete message are passed to listener
- list.process(Checker(1, 2), false);
- //mark message complete and re-process to get remaining messages sent to listener
- middle->enqueueComplete();
- list.process(Checker(3, 5), false);
-}
-
-
-struct MockStore : public NullMessageStore
-{
- Queue::shared_ptr queue;
- boost::intrusive_ptr<Message> msg;
-
- void flush(const qpid::broker::PersistableQueue& q) {
- BOOST_CHECK_EQUAL(queue.get(), &q);
- msg->enqueueComplete();
- }
-};
-
-QPID_AUTO_TEST_CASE(testSyncProcessWithIncomplete)
-{
- IncompleteMessageList list;
- SequenceNumber counter(1);
- MockStore store;
- store.queue = Queue::shared_ptr(new Queue("mock-queue", false, &store));
- //fill up list with messages
- for (int i = 0; i < 5; i++) {
- boost::intrusive_ptr<Message> msg(new Message(counter++));
- list.add(msg);
- if (i == 2) {
- //mark a message in the middle as incomplete
- msg->enqueueAsync(store.queue, &store);
- store.msg = msg;
- }
- }
- //process with sync bit specified and ensure that all messages are passed to listener
- list.process(Checker(1, 5), true);
-}
-
-QPID_AUTO_TEST_SUITE_END()
-
-}} // namespace qpid::tests