File: Response.cpp

package info (click to toggle)
eris 1.3.10-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,592 kB
  • ctags: 1,516
  • sloc: cpp: 9,850; sh: 8,288; perl: 287; ansic: 165; makefile: 162
file content (48 lines) | stat: -rw-r--r-- 1,185 bytes parent folder | download
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
#include <Eris/Response.h>
#include <Atlas/Objects/Operation.h>
#include <Eris/LogStream.h>

using namespace Atlas::Objects::Operation;

namespace Eris
{

ResponseBase::~ResponseBase()
{
}

void ResponseTracker::await(int serialno, ResponseBase* resp)
{
    assert(m_pending.count(serialno) == 0);
    m_pending[serialno] = resp;
}

bool ResponseTracker::handleOp(const RootOperation& op)
{
    if (op->getRefno() == 0) return false; // invalid refno, not a response op
    
    RefnoResponseMap::iterator it = m_pending.find(op->getRefno());
    if (it == m_pending.end()) {
        warning() << "received op with valid refno (" << op->getRefno() << 
            ") but no response is registered";
        debug() << "op=\n" << op;
        return false;
    }

// order here is important, so the responseReceived can re-await the op
    ResponseBase* resp = it->second;
    m_pending.erase(it);

    bool result = resp->responseReceived(op);
    delete resp;

    return result;
}

bool NullResponse::responseReceived(const Atlas::Objects::Operation::RootOperation&)
{
    //debug() << "nullresponse, ignoring op with refno " << op->getRefno();
    return false;
}

} // of namespace