now the watchdog thread knows when the last byte was written by adding in the write_fun callback