1 // author : Boris Kolpackov <boris@kolpackov.net>
3 #ifndef ACE_RMCAST_ACKNOWLEDGE_H
4 #define ACE_RMCAST_ACKNOWLEDGE_H
6 #include "ace/Hash_Map_Manager.h"
7 #include "ace/Thread_Manager.h"
12 #include "Parameters.h"
14 #if !defined (ACE_RMCAST_DEFAULT_MAP_SIZE)
15 #define ACE_RMCAST_DEFAULT_MAP_SIZE 10
16 #endif /* ACE_RMCAST_DEFAULT_MAP_SIZE */
18 #if !defined (ACE_RMCAST_DEFAULT_QUEUE_SIZE)
19 #define ACE_RMCAST_DEFAULT_QUEUE_SIZE 10
20 #endif /* ACE_RMCAST_DEFAULT_QUEUE_SIZE */
24 class Acknowledge
: public Element
27 Acknowledge (Parameters
const& params
);
30 in_start (In_Element
* in
);
33 out_start (Out_Element
* out
);
48 //@@ There should be no default c-tor.
51 : nak_count_ (0), timer_ (1)
55 Descr (unsigned long timer
)
56 : nak_count_ (0), timer_ (timer
)
69 return m_
.get () == 0;
93 nak_count (unsigned long v
)
105 timer (unsigned long v
)
113 unsigned long nak_count_
;
114 unsigned long timer_
;
118 struct Queue
: ACE_Hash_Map_Manager
<u64
, Descr
, ACE_Null_Mutex
>
120 typedef ACE_Hash_Map_Manager
<u64
, Descr
, ACE_Null_Mutex
> Base
;
122 // Should never be here but required by ACE_Hash_Blah_Blah.
125 : Base (ACE_RMCAST_DEFAULT_MAP_SIZE
), sn_ (0), max_sn_ (0)
130 : Base (ACE_RMCAST_DEFAULT_MAP_SIZE
), sn_ (sn
), max_sn_ (sn
)
134 Queue (Queue
const& q
)
135 : Base (ACE_RMCAST_DEFAULT_MAP_SIZE
), sn_ (q
.sn_
), max_sn_ (sn_
)
137 for (Queue::const_iterator
i (q
), e (q
, 1); i
!= e
; ++i
)
139 bind ((*i
).ext_id_
, (*i
).int_id_
);
145 bind (u64 sn
, Descr
const& d
)
147 int r (Base::bind (sn
, d
));
149 if (r
== 0 && sn
> max_sn_
) max_sn_
= sn
;
155 rebind (u64 sn
, Descr
const& d
)
157 int r (Base::rebind (sn
, d
));
159 if (r
== 0 && sn
> max_sn_
) max_sn_
= sn
;
167 int r (Base::unbind (sn
));
169 if (r
== 0 && sn
== max_sn_
)
171 for (--max_sn_
; max_sn_
>= sn_
; --max_sn_
)
173 if (find (max_sn_
) == 0) break;
196 if (current_size () == 0) return sn_
;
206 ACE_Hash_Map_Manager_Ex
<Address
,
209 ACE_Equal_To
<Address
>,
221 track_queue (Address
const& addr
, Queue
& q
, Messages
& msgs
);
224 create_nrtm (u32 max_elem
);
226 static ACE_THR_FUNC_RETURN
227 track_thunk (void* obj
);
230 Parameters
const& params_
;
236 unsigned long nrtm_timer_
;
239 ACE_Thread_Manager tracker_mgr_
;
243 #endif // ACE_RMCAST_ACKNOWLEDGE_H