Add a callback for wakeups
This commit is contained in:
parent
234274c1df
commit
87108a18ef
2 changed files with 9 additions and 0 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue