summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/BatchRequestQueue.h
blob: c8cb3090e7a1a57848b2b18adcefc8fccf70a994 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// **********************************************************************
//
// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

#ifndef ICE_BATCH_REQUEST_QUEUE_H
#define ICE_BATCH_REQUEST_QUEUE_H

#include <IceUtil/Shared.h>
#include <IceUtil/Mutex.h>
#include <IceUtil/Monitor.h>
#include <IceUtil/UniquePtr.h>

#include <Ice/BatchRequestInterceptor.h>
#include <Ice/BatchRequestQueueF.h>
#include <Ice/InstanceF.h>
#include <Ice/OutputStream.h>

namespace IceInternal
{

class BatchRequestQueue : public IceUtil::Shared, private IceUtil::Monitor<IceUtil::Mutex>
{
public:

    BatchRequestQueue(const InstancePtr&, bool);

    void prepareBatchRequest(Ice::OutputStream*);
    void finishBatchRequest(Ice::OutputStream*, const Ice::ObjectPrxPtr&, const std::string&);
    void abortBatchRequest(Ice::OutputStream*);

    int swap(Ice::OutputStream*);

    void destroy(const Ice::LocalException&);
    bool isEmpty();

    void enqueueBatchRequest();

private:

    void waitStreamInUse(bool);

#ifdef ICE_CPP11_MAPPING
    std::function<void(const Ice::BatchRequest&, int, int)> _interceptor;
#else
    Ice::BatchRequestInterceptorPtr _interceptor;
#endif
    Ice::OutputStream _batchStream;
    bool _batchStreamInUse;
    bool _batchStreamCanFlush;
    int _batchRequestNum;
    size_t _batchMarker;
    IceUtil::UniquePtr<Ice::LocalException> _exception;
    size_t _maxSize;
};

};

#endif