Add a callback for wakeups

This commit is contained in:
Kovid Goyal
2022-11-15 18:01:21 +05:30
parent 234274c1df
commit 87108a18ef
2 changed files with 9 additions and 0 deletions

View File

@@ -78,6 +78,9 @@ type Loop struct {
// Called when resuming from a SIGTSTP or Ctrl-z
OnResumeFromStop func() error
// Called when main loop is woken up
OnWakeup func() error
}
func New(options ...func(self *Loop)) (*Loop, error) {

View File

@@ -319,6 +319,12 @@ func (self *Loop) run() (err error) {
for len(self.wakeup_channel) > 0 {
<-self.wakeup_channel
}
if self.OnWakeup != nil {
err = self.OnWakeup()
if err != nil {
return err
}
}
case msg_id := <-write_done_channel:
self.flush_pending_writes(tty_write_channel)
if self.OnWriteComplete != nil {