/usr/include/ace/RMCast/Acknowledge.h is in libace-rmcast-dev 6.3.3+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | // author : Boris Kolpackov <boris@kolpackov.net>
#ifndef ACE_RMCAST_ACKNOWLEDGE_H
#define ACE_RMCAST_ACKNOWLEDGE_H
#include "ace/Hash_Map_Manager.h"
#include "ace/Thread_Manager.h"
#include "Stack.h"
#include "Protocol.h"
#include "Bits.h"
#include "Parameters.h"
#if !defined (ACE_RMCAST_DEFAULT_MAP_SIZE)
#define ACE_RMCAST_DEFAULT_MAP_SIZE 10
#endif /* ACE_RMCAST_DEFAULT_MAP_SIZE */
#if !defined (ACE_RMCAST_DEFAULT_QUEUE_SIZE)
#define ACE_RMCAST_DEFAULT_QUEUE_SIZE 10
#endif /* ACE_RMCAST_DEFAULT_QUEUE_SIZE */
namespace ACE_RMCast
{
class Acknowledge : public Element
{
public:
Acknowledge (Parameters const& params);
virtual void
in_start (In_Element* in);
virtual void
out_start (Out_Element* out);
virtual void
out_stop ();
public:
virtual void
recv (Message_ptr m);
virtual void
send (Message_ptr m);
// Sun C++ 5.4 can't handle private here.
//
// private:
public:
struct Descr
{
//@@ There should be no default c-tor.
//
Descr ()
: nak_count_ (0), timer_ (1)
{
}
Descr (unsigned long timer)
: nak_count_ (0), timer_ (timer)
{
}
Descr (Message_ptr m)
: m_ (m)
{
}
public:
bool
lost () const
{
return m_.get () == 0;
}
public:
Message_ptr
msg ()
{
return m_;
}
void
msg (Message_ptr m)
{
m_ = m;
}
public:
unsigned long
nak_count () const
{
return nak_count_;
}
void
nak_count (unsigned long v)
{
nak_count_ = v;
}
unsigned long
timer () const
{
return timer_;
}
void
timer (unsigned long v)
{
timer_ = v;
}
private:
Message_ptr m_;
unsigned long nak_count_;
unsigned long timer_;
};
private:
struct Queue : ACE_Hash_Map_Manager<u64, Descr, ACE_Null_Mutex>
{
typedef ACE_Hash_Map_Manager<u64, Descr, ACE_Null_Mutex> Base;
// Should never be here but required by ACE_Hash_Blah_Blah.
//
Queue ()
: Base (ACE_RMCAST_DEFAULT_MAP_SIZE), sn_ (0), max_sn_ (0)
{
}
Queue (u64 sn)
: Base (ACE_RMCAST_DEFAULT_MAP_SIZE), sn_ (sn), max_sn_ (sn)
{
}
Queue (Queue const& q)
: Base (ACE_RMCAST_DEFAULT_MAP_SIZE), sn_ (q.sn_), max_sn_ (sn_)
{
for (Queue::const_iterator i (q), e (q, 1); i != e; ++i)
{
bind ((*i).ext_id_, (*i).int_id_);
}
}
public:
int
bind (u64 sn, Descr const& d)
{
int r (Base::bind (sn, d));
if (r == 0 && sn > max_sn_) max_sn_ = sn;
return r;
}
int
rebind (u64 sn, Descr const& d)
{
int r (Base::rebind (sn, d));
if (r == 0 && sn > max_sn_) max_sn_ = sn;
return r;
}
int
unbind (u64 sn)
{
int r (Base::unbind (sn));
if (r == 0 && sn == max_sn_)
{
for (--max_sn_; max_sn_ >= sn_; --max_sn_)
{
if (find (max_sn_) == 0) break;
}
}
return r;
}
public:
u64
sn () const
{
return sn_;
}
void
sn (u64 sn)
{
sn_ = sn;
}
u64
max_sn () const
{
if (current_size () == 0) return sn_;
return max_sn_;
}
private:
u64 sn_, max_sn_;
};
typedef
ACE_Hash_Map_Manager_Ex<Address,
Queue,
AddressHasher,
ACE_Equal_To<Address>,
ACE_Null_Mutex>
Map;
private:
void
collapse (Queue& q);
void
track ();
void
track_queue (Address const& addr, Queue& q, Messages& msgs);
Profile_ptr
create_nrtm (u32 max_elem);
static ACE_THR_FUNC_RETURN
track_thunk (void* obj);
private:
Parameters const& params_;
Map hold_;
Mutex mutex_;
Condition cond_;
unsigned long nrtm_timer_;
bool stop_;
ACE_Thread_Manager tracker_mgr_;
};
}
#endif // ACE_RMCAST_ACKNOWLEDGE_H
|