[
https://issues.apache.org/jira/browse/DISPATCH-1274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16800802#comment-16800802
]
Gordon Sim commented on DISPATCH-1274:
--------------------------------------
Another option might be the following, which I think would keep the
optimisation for the first 256 timers (I suspect it is only one or two of the
fixed ones that actually use 0 timeoutes anyway, the per connection ones
certainly don't).
{noformat}
diff --git a/src/immediate.c b/src/immediate.c
index 5b1cab9e..87402b3f 100644
--- a/src/immediate.c
+++ b/src/immediate.c
@@ -47,7 +47,7 @@ void qd_immediate_finalize(void) {
qd_immediate_t *qd_immediate(qd_dispatch_t *qd, void (*handler)(void*), void*
context) {
sys_mutex_lock(lock);
if (count >= sizeof(immediates)/sizeof(immediates[0])) {
- assert("exceeded max number of qd_immediate_t objects" == 0);
+ sys_mutex_unlock(lock);
return 0;
}
qd_immediate_t *i = &immediates[count++];
diff --git a/src/timer.c b/src/timer.c
index c76f77dd..06d898c1 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -55,7 +55,7 @@ static void timer_cancel_LH(qd_timer_t *timer)
DEQ_INSERT_TAIL(idle_timers, timer);
timer->scheduled = false;
}
- qd_immediate_disarm(timer->immediate);
+ if (timer->immediate) qd_immediate_disarm(timer->immediate);
}
/* Adjust timer's time_base and delays for the current time. */
@@ -112,7 +112,7 @@ void qd_timer_free(qd_timer_t *timer)
sys_mutex_lock(lock);
timer_cancel_LH(timer);
DEQ_REMOVE(idle_timers, timer);
- qd_immediate_free(timer->immediate);
+ if (timer->immediate) qd_immediate_free(timer->immediate);
sys_mutex_unlock(lock);
free_qd_timer_t(timer);
}
@@ -128,7 +128,7 @@ qd_timestamp_t qd_timer_now() {
void qd_timer_schedule(qd_timer_t *timer, qd_duration_t duration)
{
sys_mutex_lock(lock);
- if (duration == 0) {
+ if (duration == 0 && timer->immediate) {
qd_immediate_arm(timer->immediate);
sys_mutex_unlock(lock);
return;
@@ -208,7 +208,7 @@ void qd_timer_visit()
qd_timer_t *timer = DEQ_HEAD(scheduled_timers);
while (timer && timer->delta_time == 0) {
timer_cancel_LH(timer); /* Removes timer from scheduled_timers */
- qd_immediate_disarm(timer->immediate);
+ if (timer->immediate) qd_immediate_disarm(timer->immediate);
sys_mutex_unlock(lock);
timer->handler(timer->context); /* Call the handler outside the lock,
may re-schedule */
sys_mutex_lock(lock);
{noformat}
> Optimize qd_timer_schedule(0)
> ------------------------------
>
> Key: DISPATCH-1274
> URL: https://issues.apache.org/jira/browse/DISPATCH-1274
> Project: Qpid Dispatch
> Issue Type: Improvement
> Components: Container
> Affects Versions: 1.5.0
> Reporter: Alan Conway
> Assignee: Alan Conway
> Priority: Major
> Fix For: 1.6.0
>
>
> qd_timer_schedule() uses the general timeout mechanisms which includes
> checking system time (on schedule and on PN_PROACTOR_TIMEOUT wakeup) and
> adding/removing work items from sorted list. Optimize the schedule(0) case as
> a simple work_list using pn_proactor_interrupt() for wakeups.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]