Add a callback for wakeups

This commit is contained in:
Kovid Goyal 2022-11-15 18:01:21 +05:30
parent 234274c1df
commit 87108a18ef
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
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 {