Move all time support to ddsrt
* Move wctime, mtime, etime types to ddsrt * Add ddsrt_time_wallclock * Change ddsrt_time_monontic, elapsed to use mtime, etime types * Remove now, now_mt, now_et * Rename X_to_sec_usec to ddsrt_X_to_sec_usec * add_duration_to_X to ddsrt_X_add_duration (to be in line with the existing ddsrt_time_add_duration) * elimination of ddsrt/timeconv.h, it added more in the way of complications than it did in making things more elegant * rename of q_time.[ch] to ddsi_time.[ch]: that now only deals with DDSI timestamps and durations on the wire Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
1611adc20a
commit
77c3545f5e
65 changed files with 757 additions and 746 deletions
|
@ -32,7 +32,7 @@ void dds__builtin_init (struct dds_domain *dom);
|
|||
void dds__builtin_fini (struct dds_domain *dom);
|
||||
|
||||
struct entity_common;
|
||||
struct ddsi_serdata *dds__builtin_make_sample (const struct entity_common *e, nn_wctime_t timestamp, bool alive);
|
||||
struct ddsi_serdata *dds__builtin_make_sample (const struct entity_common *e, ddsrt_wctime_t timestamp, bool alive);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
|
|
|
@ -26,10 +26,10 @@ struct rhc_sample;
|
|||
DDS_EXPORT struct dds_rhc *dds_rhc_default_new_xchecks (dds_reader *reader, struct ddsi_domaingv *gv, const struct ddsi_sertopic *topic, bool xchecks);
|
||||
DDS_EXPORT struct dds_rhc *dds_rhc_default_new (struct dds_reader *reader, const struct ddsi_sertopic *topic);
|
||||
#ifdef DDSI_INCLUDE_LIFESPAN
|
||||
DDS_EXPORT nn_mtime_t dds_rhc_default_sample_expired_cb(void *hc, nn_mtime_t tnow);
|
||||
DDS_EXPORT ddsrt_mtime_t dds_rhc_default_sample_expired_cb(void *hc, ddsrt_mtime_t tnow);
|
||||
#endif
|
||||
#ifdef DDSI_INCLUDE_DEADLINE_MISSED
|
||||
DDS_EXPORT nn_mtime_t dds_rhc_default_deadline_missed_cb(void *hc, nn_mtime_t tnow);
|
||||
DDS_EXPORT ddsrt_mtime_t dds_rhc_default_deadline_missed_cb(void *hc, ddsrt_mtime_t tnow);
|
||||
#endif
|
||||
|
||||
#if defined (__cplusplus)
|
||||
|
|
|
@ -189,7 +189,7 @@ static struct ddsi_tkmap_instance *dds__builtin_get_tkmap_entry (const struct dd
|
|||
return tk;
|
||||
}
|
||||
|
||||
struct ddsi_serdata *dds__builtin_make_sample (const struct entity_common *e, nn_wctime_t timestamp, bool alive)
|
||||
struct ddsi_serdata *dds__builtin_make_sample (const struct entity_common *e, ddsrt_wctime_t timestamp, bool alive)
|
||||
{
|
||||
/* initialize to avoid gcc warning ultimately caused by C's horrible type system */
|
||||
struct dds_domain *dom = e->gv->builtin_topic_interface->arg;
|
||||
|
@ -219,7 +219,7 @@ struct ddsi_serdata *dds__builtin_make_sample (const struct entity_common *e, nn
|
|||
return serdata;
|
||||
}
|
||||
|
||||
static void dds__builtin_write (const struct entity_common *e, nn_wctime_t timestamp, bool alive, void *vdomain)
|
||||
static void dds__builtin_write (const struct entity_common *e, ddsrt_wctime_t timestamp, bool alive, void *vdomain)
|
||||
{
|
||||
struct dds_domain *dom = vdomain;
|
||||
if (dds__builtin_is_visible (&e->guid, get_entity_vendorid (e), dom))
|
||||
|
|
|
@ -59,7 +59,7 @@ static dds_entity_t dds_domain_init (dds_domain *domain, dds_domainid_t domain_i
|
|||
domain->m_entity.m_domain = domain;
|
||||
domain->m_entity.m_iid = ddsi_iid_gen ();
|
||||
|
||||
domain->gv.tstart = now ();
|
||||
domain->gv.tstart = ddsrt_time_wallclock ();
|
||||
|
||||
/* | domain_id | domain id in config | result
|
||||
+-----------+---------------------+----------
|
||||
|
|
|
@ -274,7 +274,7 @@ struct rhc_instance {
|
|||
uint32_t no_writers_gen; /* __/ */
|
||||
int32_t strength; /* "current" ownership strength */
|
||||
ddsi_guid_t wr_guid; /* guid of last writer (if wr_iid != 0 then wr_guid is the corresponding guid, else undef) */
|
||||
nn_wctime_t tstamp; /* source time stamp of last update */
|
||||
ddsrt_wctime_t tstamp; /* source time stamp of last update */
|
||||
struct ddsrt_circlist_elem nonempty_list; /* links non-empty instances in arbitrary ordering */
|
||||
#ifdef DDSI_INCLUDE_DEADLINE_MISSED
|
||||
struct deadline_elem deadline; /* element in deadline missed administration */
|
||||
|
@ -594,11 +594,11 @@ static void drop_expired_samples (struct dds_rhc_default *rhc, struct rhc_sample
|
|||
TRACE (")\n");
|
||||
}
|
||||
|
||||
nn_mtime_t dds_rhc_default_sample_expired_cb(void *hc, nn_mtime_t tnow)
|
||||
ddsrt_mtime_t dds_rhc_default_sample_expired_cb(void *hc, ddsrt_mtime_t tnow)
|
||||
{
|
||||
struct dds_rhc_default *rhc = hc;
|
||||
struct rhc_sample *sample;
|
||||
nn_mtime_t tnext;
|
||||
ddsrt_mtime_t tnext;
|
||||
ddsrt_mutex_lock (&rhc->lock);
|
||||
while ((tnext = lifespan_next_expired_locked (&rhc->lifespan, tnow, (void **)&sample)).v == 0)
|
||||
drop_expired_samples (rhc, sample);
|
||||
|
@ -608,11 +608,11 @@ nn_mtime_t dds_rhc_default_sample_expired_cb(void *hc, nn_mtime_t tnow)
|
|||
#endif /* DDSI_INCLUDE_LIFESPAN */
|
||||
|
||||
#ifdef DDSI_INCLUDE_DEADLINE_MISSED
|
||||
nn_mtime_t dds_rhc_default_deadline_missed_cb(void *hc, nn_mtime_t tnow)
|
||||
ddsrt_mtime_t dds_rhc_default_deadline_missed_cb(void *hc, ddsrt_mtime_t tnow)
|
||||
{
|
||||
struct dds_rhc_default *rhc = hc;
|
||||
void *vinst;
|
||||
nn_mtime_t tnext;
|
||||
ddsrt_mtime_t tnext;
|
||||
ddsrt_mutex_lock (&rhc->lock);
|
||||
while ((tnext = deadline_next_missed_locked (&rhc->deadline, tnow, &vinst)).v == 0)
|
||||
{
|
||||
|
@ -630,7 +630,7 @@ nn_mtime_t dds_rhc_default_deadline_missed_cb(void *hc, nn_mtime_t tnow)
|
|||
dds_reader_status_cb (&rhc->reader->m_entity, &cb_data);
|
||||
ddsrt_mutex_lock (&rhc->lock);
|
||||
|
||||
tnow = now_mt ();
|
||||
tnow = ddsrt_time_monotonic ();
|
||||
}
|
||||
ddsrt_mutex_unlock (&rhc->lock);
|
||||
return tnext;
|
||||
|
@ -837,7 +837,7 @@ static void free_instance_rhc_free_wrap (void *vnode, void *varg)
|
|||
static void dds_rhc_default_free (struct dds_rhc_default *rhc)
|
||||
{
|
||||
#ifdef DDSI_INCLUDE_LIFESPAN
|
||||
dds_rhc_default_sample_expired_cb (rhc, NN_MTIME_NEVER);
|
||||
dds_rhc_default_sample_expired_cb (rhc, DDSRT_MTIME_NEVER);
|
||||
lifespan_fini (&rhc->lifespan);
|
||||
#endif
|
||||
#ifdef DDSI_INCLUDE_DEADLINE_MISSED
|
||||
|
@ -1067,7 +1067,7 @@ static int inst_accepts_sample (const struct dds_rhc_default *rhc, const struct
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void update_inst (struct rhc_instance *inst, const struct ddsi_writer_info * __restrict wrinfo, bool wr_iid_valid, nn_wctime_t tstamp)
|
||||
static void update_inst (struct rhc_instance *inst, const struct ddsi_writer_info * __restrict wrinfo, bool wr_iid_valid, ddsrt_wctime_t tstamp)
|
||||
{
|
||||
inst->tstamp = tstamp;
|
||||
inst->wr_iid_islive = wr_iid_valid;
|
||||
|
@ -1264,7 +1264,7 @@ static int rhc_unregister_isreg_w_sideeffects (struct dds_rhc_default *rhc, cons
|
|||
}
|
||||
}
|
||||
|
||||
static int rhc_unregister_updateinst (struct dds_rhc_default *rhc, struct rhc_instance *inst, const struct ddsi_writer_info * __restrict wrinfo, nn_wctime_t tstamp, struct trigger_info_qcond *trig_qc, bool *nda)
|
||||
static int rhc_unregister_updateinst (struct dds_rhc_default *rhc, struct rhc_instance *inst, const struct ddsi_writer_info * __restrict wrinfo, ddsrt_wctime_t tstamp, struct trigger_info_qcond *trig_qc, bool *nda)
|
||||
{
|
||||
assert (inst->wrcount > 0);
|
||||
|
||||
|
@ -1327,7 +1327,7 @@ static int rhc_unregister_updateinst (struct dds_rhc_default *rhc, struct rhc_in
|
|||
}
|
||||
}
|
||||
|
||||
static bool dds_rhc_unregister (struct dds_rhc_default *rhc, struct rhc_instance *inst, const struct ddsi_writer_info * __restrict wrinfo, nn_wctime_t tstamp, struct trigger_info_post *post, struct trigger_info_qcond *trig_qc)
|
||||
static bool dds_rhc_unregister (struct dds_rhc_default *rhc, struct rhc_instance *inst, const struct ddsi_writer_info * __restrict wrinfo, ddsrt_wctime_t tstamp, struct trigger_info_post *post, struct trigger_info_qcond *trig_qc)
|
||||
{
|
||||
bool notify_data_available = false;
|
||||
|
||||
|
@ -1384,7 +1384,7 @@ static struct rhc_instance *alloc_new_instance (struct dds_rhc_default *rhc, con
|
|||
|
||||
#ifdef DDSI_INCLUDE_DEADLINE_MISSED
|
||||
if (!inst->isdisposed)
|
||||
deadline_register_instance_locked (&rhc->deadline, &inst->deadline, now_mt ());
|
||||
deadline_register_instance_locked (&rhc->deadline, &inst->deadline, ddsrt_time_monotonic ());
|
||||
#endif
|
||||
|
||||
return inst;
|
||||
|
@ -1598,7 +1598,7 @@ static bool dds_rhc_default_store (struct dds_rhc_default * __restrict rhc, cons
|
|||
inst->disposed_gen++;
|
||||
#ifdef DDSI_INCLUDE_DEADLINE_MISSED
|
||||
if (!is_dispose)
|
||||
deadline_register_instance_locked (&rhc->deadline, &inst->deadline, now_mt ());
|
||||
deadline_register_instance_locked (&rhc->deadline, &inst->deadline, ddsrt_time_monotonic ());
|
||||
#endif
|
||||
}
|
||||
if (is_dispose)
|
||||
|
@ -1639,7 +1639,7 @@ static bool dds_rhc_default_store (struct dds_rhc_default * __restrict rhc, cons
|
|||
{
|
||||
inst->isdisposed = 0;
|
||||
#ifdef DDSI_INCLUDE_DEADLINE_MISSED
|
||||
deadline_register_instance_locked (&rhc->deadline, &inst->deadline, now_mt ());
|
||||
deadline_register_instance_locked (&rhc->deadline, &inst->deadline, ddsrt_time_monotonic ());
|
||||
#endif
|
||||
}
|
||||
goto error_or_nochange;
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "dds/ddsi/q_unused.h"
|
||||
#include "dds/ddsi/q_config.h"
|
||||
#include "dds/ddsi/ddsi_tkmap.h"
|
||||
#include "dds/ddsi/q_time.h"
|
||||
#include "dds/ddsi/q_rtps.h"
|
||||
#include "dds/ddsi/q_freelist.h"
|
||||
#include "dds/ddsi/ddsi_domaingv.h"
|
||||
|
@ -51,7 +50,7 @@ struct whc_node {
|
|||
struct ddsi_plist *plist; /* 0 if nothing special */
|
||||
unsigned unacked: 1; /* counted in whc::unacked_bytes iff 1 */
|
||||
unsigned borrowed: 1; /* at most one can borrow it at any time */
|
||||
nn_mtime_t last_rexmit_ts;
|
||||
ddsrt_mtime_t last_rexmit_ts;
|
||||
uint32_t rexmit_count;
|
||||
#ifdef DDSI_INCLUDE_LIFESPAN
|
||||
struct lifespan_fhnode lifespan; /* fibheap node for lifespan */
|
||||
|
@ -155,7 +154,7 @@ static uint32_t whc_default_remove_acked_messages_full (struct whc_impl *whc, se
|
|||
static uint32_t whc_default_remove_acked_messages (struct whc *whc, seqno_t max_drop_seq, struct whc_state *whcst, struct whc_node **deferred_free_list);
|
||||
static void whc_default_free_deferred_free_list (struct whc *whc, struct whc_node *deferred_free_list);
|
||||
static void whc_default_get_state (const struct whc *whc, struct whc_state *st);
|
||||
static int whc_default_insert (struct whc *whc, seqno_t max_drop_seq, seqno_t seq, nn_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk);
|
||||
static int whc_default_insert (struct whc *whc, seqno_t max_drop_seq, seqno_t seq, ddsrt_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk);
|
||||
static seqno_t whc_default_next_seq (const struct whc *whc, seqno_t seq);
|
||||
static bool whc_default_borrow_sample (const struct whc *whc, seqno_t seq, struct whc_borrowed_sample *sample);
|
||||
static bool whc_default_borrow_sample_key (const struct whc *whc, const struct ddsi_serdata *serdata_key, struct whc_borrowed_sample *sample);
|
||||
|
@ -377,11 +376,11 @@ static struct whc_node *whc_findkey (const struct whc_impl *whc, const struct dd
|
|||
}
|
||||
|
||||
#ifdef DDSI_INCLUDE_LIFESPAN
|
||||
static nn_mtime_t whc_sample_expired_cb(void *hc, nn_mtime_t tnow)
|
||||
static ddsrt_mtime_t whc_sample_expired_cb(void *hc, ddsrt_mtime_t tnow)
|
||||
{
|
||||
struct whc_impl *whc = hc;
|
||||
void *sample;
|
||||
nn_mtime_t tnext;
|
||||
ddsrt_mtime_t tnext;
|
||||
ddsrt_mutex_lock (&whc->lock);
|
||||
while ((tnext = lifespan_next_expired_locked (&whc->lifespan, tnow, &sample)).v == 0)
|
||||
whc_delete_one (whc, sample);
|
||||
|
@ -392,11 +391,11 @@ static nn_mtime_t whc_sample_expired_cb(void *hc, nn_mtime_t tnow)
|
|||
#endif
|
||||
|
||||
#ifdef DDSI_INCLUDE_DEADLINE_MISSED
|
||||
static nn_mtime_t whc_deadline_missed_cb(void *hc, nn_mtime_t tnow)
|
||||
static ddsrt_mtime_t whc_deadline_missed_cb(void *hc, ddsrt_mtime_t tnow)
|
||||
{
|
||||
struct whc_impl *whc = hc;
|
||||
void *vidxnode;
|
||||
nn_mtime_t tnext;
|
||||
ddsrt_mtime_t tnext;
|
||||
ddsrt_mutex_lock (&whc->lock);
|
||||
while ((tnext = deadline_next_missed_locked (&whc->deadline, tnow, &vidxnode)).v == 0)
|
||||
{
|
||||
|
@ -412,7 +411,7 @@ static nn_mtime_t whc_deadline_missed_cb(void *hc, nn_mtime_t tnow)
|
|||
dds_writer_status_cb (&whc->wrinfo.writer->m_entity, &cb_data);
|
||||
ddsrt_mutex_lock (&whc->lock);
|
||||
|
||||
tnow = now_mt ();
|
||||
tnow = ddsrt_time_monotonic ();
|
||||
}
|
||||
ddsrt_mutex_unlock (&whc->lock);
|
||||
return tnext;
|
||||
|
@ -510,7 +509,7 @@ void whc_default_free (struct whc *whc_generic)
|
|||
check_whc (whc);
|
||||
|
||||
#ifdef DDSI_INCLUDE_LIFESPAN
|
||||
whc_sample_expired_cb (whc, NN_MTIME_NEVER);
|
||||
whc_sample_expired_cb (whc, DDSRT_MTIME_NEVER);
|
||||
lifespan_fini (&whc->lifespan);
|
||||
#endif
|
||||
|
||||
|
@ -1156,7 +1155,7 @@ static uint32_t whc_default_remove_acked_messages (struct whc *whc_generic, seqn
|
|||
return cnt;
|
||||
}
|
||||
|
||||
static struct whc_node *whc_default_insert_seq (struct whc_impl *whc, seqno_t max_drop_seq, seqno_t seq, nn_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata)
|
||||
static struct whc_node *whc_default_insert_seq (struct whc_impl *whc, seqno_t max_drop_seq, seqno_t seq, ddsrt_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata)
|
||||
{
|
||||
struct whc_node *newn = NULL;
|
||||
|
||||
|
@ -1228,7 +1227,7 @@ static struct whc_node *whc_default_insert_seq (struct whc_impl *whc, seqno_t ma
|
|||
return newn;
|
||||
}
|
||||
|
||||
static int whc_default_insert (struct whc *whc_generic, seqno_t max_drop_seq, seqno_t seq, nn_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk)
|
||||
static int whc_default_insert (struct whc *whc_generic, seqno_t max_drop_seq, seqno_t seq, ddsrt_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk)
|
||||
{
|
||||
struct whc_impl * const whc = (struct whc_impl *)whc_generic;
|
||||
struct whc_node *newn = NULL;
|
||||
|
@ -1364,7 +1363,7 @@ static int whc_default_insert (struct whc *whc_generic, seqno_t max_drop_seq, se
|
|||
if (!ddsrt_hh_add (whc->idx_hash, idxn))
|
||||
assert (0);
|
||||
#ifdef DDSI_INCLUDE_DEADLINE_MISSED
|
||||
deadline_register_instance_locked (&whc->deadline, &idxn->deadline, now_mt ());
|
||||
deadline_register_instance_locked (&whc->deadline, &idxn->deadline, ddsrt_time_monotonic ());
|
||||
#endif
|
||||
}
|
||||
else
|
||||
|
|
|
@ -143,7 +143,7 @@ static void bwhc_get_state (const struct whc *whc, struct whc_state *st)
|
|||
st->unacked_bytes = 0;
|
||||
}
|
||||
|
||||
static int bwhc_insert (struct whc *whc, seqno_t max_drop_seq, seqno_t seq, nn_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk)
|
||||
static int bwhc_insert (struct whc *whc, seqno_t max_drop_seq, seqno_t seq, ddsrt_mtime_t exp, struct ddsi_plist *plist, struct ddsi_serdata *serdata, struct ddsi_tkmap_instance *tk)
|
||||
{
|
||||
(void)whc;
|
||||
(void)max_drop_seq;
|
||||
|
|
|
@ -90,7 +90,7 @@ struct local_sourceinfo {
|
|||
const struct ddsi_sertopic *src_topic;
|
||||
struct ddsi_serdata *src_payload;
|
||||
struct ddsi_tkmap_instance *src_tk;
|
||||
nn_mtime_t timeout;
|
||||
ddsrt_mtime_t timeout;
|
||||
};
|
||||
|
||||
static struct ddsi_serdata *local_make_sample (struct ddsi_tkmap_instance **tk, struct ddsi_domaingv *gv, struct ddsi_sertopic const * const topic, void *vsourceinfo)
|
||||
|
@ -136,9 +136,9 @@ static dds_return_t local_on_delivery_failure_fastpath (struct entity_common *so
|
|||
assert (source_entity->kind == EK_WRITER);
|
||||
struct writer *wr = (struct writer *) source_entity;
|
||||
struct local_sourceinfo *si = vsourceinfo;
|
||||
nn_mtime_t tnow = now_mt ();
|
||||
ddsrt_mtime_t tnow = ddsrt_time_monotonic ();
|
||||
if (si->timeout.v == 0)
|
||||
si->timeout = add_duration_to_mtime (tnow, wr->xqos->reliability.max_blocking_time);
|
||||
si->timeout = ddsrt_mtime_add_duration (tnow, wr->xqos->reliability.max_blocking_time);
|
||||
if (tnow.v >= si->timeout.v)
|
||||
return DDS_RETCODE_TIMEOUT;
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue