so what you want is a post-init event that happens immediately after the init event for that module, but before the init events of other modules?
why not put this second event into the init, especially if you say that creating a a separate post-init event for the module could be too dangerous? if this post-init event is so closely coupled with the init, then why is it a separate event?
that being said, it looks like there might be a bug with how we are keeping the event list sorted -- the secondary key for event priority isn't working the way we would expect it to:
# current implementation in `scheduleEvent` follows this:
set.seed(10)
n <- 20
dt <- data.table(a = sample(1:100, n, replace = TRUE), b = sample(letters, n, replace = TRUE))
dt
setkey(dt, 'a') # pay attention to rows 11, 12, 13 -- note the order of the second column ('b')
dt
set2key(dt, 'b') # note that setting the secondary key isn't sorting on column 'b'
dt
# proposed fix:
set.seed(10)
n <- 20
dt <- data.table(a = sample(1:100, n, replace = TRUE), b = sample(letters, n, replace = TRUE))
dt
setkey(dt, 'a', 'b') # now rows 11, 12, 13 are sorted correctly first by 'a' then by 'b'
dt
However, this fix is not so simple to implement! Basically, an event that schedules another event for the same time but with higher priority will always place that other event at the top of the event list, so when the current event completes, the first item in the list is removed but this no longer corresponds to the current event! The result is an endless loop where event A schedules event B, but event A never gets removed from the list so is always run, scheduling more event B's.
@eliotmcintire and I need to think about how to properly fix this