~mathiaz/+junk/ceph-new-pkg-review

« back to all changes in this revision

Viewing changes to src/msg/FakeMessenger.h

  • Committer: Mathias Gug
  • Date: 2010-07-29 03:10:42 UTC
  • Revision ID: mathias.gug@canonical.com-20100729031042-n9n8kky962qb4onb
Import ceph_0.21-0ubuntu1 from https://launchpad.net/~clint-fewbar/+archive/ceph/+packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
 
2
// vim: ts=8 sw=2 smarttab
 
3
/*
 
4
 * Ceph - scalable distributed file system
 
5
 *
 
6
 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
 
7
 *
 
8
 * This is free software; you can redistribute it and/or
 
9
 * modify it under the terms of the GNU Lesser General Public
 
10
 * License version 2.1, as published by the Free Software 
 
11
 * Foundation.  See file COPYING.
 
12
 * 
 
13
 */
 
14
 
 
15
 
 
16
 
 
17
#ifndef CEPH_FAKEMESSENGER_H
 
18
#define CEPH_FAKEMESSENGER_H
 
19
 
 
20
#include "Messenger.h"
 
21
#include "Dispatcher.h"
 
22
 
 
23
#include <list>
 
24
#include <map>
 
25
 
 
26
class Timer;
 
27
 
 
28
class FakeMessenger : public Messenger {
 
29
 protected:
 
30
  class Logger *logger;
 
31
 
 
32
  int    qlen;
 
33
  list<Message*>       incoming;        // incoming queue
 
34
 
 
35
 public:
 
36
  bool failed;
 
37
 
 
38
  FakeMessenger(entity_name_t me);
 
39
  ~FakeMessenger();
 
40
 
 
41
  virtual int shutdown();
 
42
 
 
43
  void reset_myname(entity_name_t m);
 
44
 
 
45
  // msg interface
 
46
  int send_message(Message *m, entity_inst_t dest);
 
47
  int forward_message(Message *m, entity_inst_t dest);
 
48
  int submit_message(Message *m, entity_inst_t dest);
 
49
  
 
50
  int get_dispatch_queue_len() { return qlen; }
 
51
 
 
52
  // -- incoming queue --
 
53
  // (that nothing uses)
 
54
  Message *get_message() {
 
55
    if (!incoming.empty()) {
 
56
      Message *m = incoming.front();
 
57
      incoming.pop_front();
 
58
      qlen--;
 
59
      return m;
 
60
    }
 
61
    return NULL;
 
62
  }
 
63
  bool queue_incoming(Message *m) {
 
64
    incoming.push_back(m);
 
65
    qlen++;
 
66
    return true;
 
67
  }
 
68
  int num_incoming() {
 
69
    //return incoming.size();
 
70
    return qlen;
 
71
  }
 
72
 
 
73
  void suicide() {
 
74
    if (!failed) {
 
75
      failed = true;
 
76
    }
 
77
    shutdown();
 
78
  }
 
79
 
 
80
};
 
81
 
 
82
int fakemessenger_do_loop();
 
83
int fakemessenger_do_loop_2();
 
84
void fakemessenger_startthread();
 
85
void fakemessenger_stopthread();
 
86
void fakemessenger_wait();
 
87
 
 
88
#endif