add codes to a queue to be processed by main loop