Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include "sal/config.h"
21 : :
22 : : #include "com/sun/star/uno/RuntimeException.hpp"
23 : : #include "rtl/byteseq.hxx"
24 : : #include "osl/mutex.hxx"
25 : :
26 : : #include "lessoperators.hxx"
27 : : #include "outgoingrequest.hxx"
28 : : #include "outgoingrequests.hxx"
29 : :
30 : : namespace binaryurp {
31 : :
32 : : namespace {
33 : :
34 : : namespace css = com::sun::star;
35 : :
36 : : }
37 : :
38 [ + - ][ + - ]: 102 : OutgoingRequests::OutgoingRequests() {}
39 : :
40 [ + - ]: 96 : OutgoingRequests::~OutgoingRequests() {}
41 : :
42 : 13767 : void OutgoingRequests::push(
43 : : rtl::ByteSequence const & tid, OutgoingRequest const & request)
44 : : {
45 [ + - ]: 13767 : osl::MutexGuard g(mutex_);
46 [ + - ][ + - ]: 13767 : map_[tid].push_back(request);
[ + - ]
47 : 13767 : }
48 : :
49 : 13767 : OutgoingRequest OutgoingRequests::top(rtl::ByteSequence const & tid) {
50 [ + - ]: 13767 : osl::MutexGuard g(mutex_);
51 [ + - ]: 13767 : Map::iterator i(map_.find(tid));
52 [ - + ]: 13767 : if (i == map_.end()) {
53 : : throw css::uno::RuntimeException(
54 : : OUString(
55 : : RTL_CONSTASCII_USTRINGPARAM("URP: reply for unknown TID")),
56 [ # # ][ # # ]: 0 : css::uno::Reference< css::uno::XInterface >());
57 : : }
58 : : OSL_ASSERT(!i->second.empty());
59 [ + - ][ + - ]: 13767 : return i->second.back();
60 : : }
61 : :
62 : 13767 : void OutgoingRequests::pop(rtl::ByteSequence const & tid) throw () {
63 [ + - ]: 13767 : osl::MutexGuard g(mutex_);
64 [ + - ]: 13767 : Map::iterator i(map_.find(tid));
65 : : OSL_ASSERT(i != map_.end());
66 [ + - ]: 13767 : i->second.pop_back();
67 [ + + ]: 13767 : if (i->second.empty()) {
68 [ + - ]: 13765 : map_.erase(i);
69 [ + - ]: 13767 : }
70 : 13767 : }
71 : :
72 : : }
73 : :
74 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|