diff options
Diffstat (limited to 'sd_login/type_monitor.go')
-rw-r--r-- | sd_login/type_monitor.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sd_login/type_monitor.go b/sd_login/type_monitor.go index 50f601a..2422f06 100644 --- a/sd_login/type_monitor.go +++ b/sd_login/type_monitor.go @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Luke Shumaker <lukeshu@sbcglobal.net> +// Copyright (C) 2016-2017 Luke Shumaker <lukeshu@sbcglobal.net> // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ import ( "golang.org/x/sys/unix" ) -// Monitor monitors several types of events, so you don't have to do +// A Monitor monitors several types of events, so you don't have to do // busy-polling. // // However, Monitor won't actually give you the event that happened, @@ -84,10 +84,14 @@ func NewMonitor(categories MonitorCategory) (*Monitor, error) { return &Monitor{in: in}, nil } +// Close closes the monitor. After calling Close, further calls to +// the monitor will fail. func (m *Monitor) Close() error { return m.in.Close() } +// Flush discards any events that have happened since the last Flush +// or Wait call. func (m *Monitor) Flush() error { for { ev, err := m.in.ReadNonblock() @@ -100,6 +104,10 @@ func (m *Monitor) Flush() error { } } +// Wait blocks until a watched for event has happened. A single call +// to Wait discards only discards first event; if multiple events +// happen at once, multiple calls to Wait will immediately return +// unless Flush is called. func (m *Monitor) Wait() error { _, err := m.in.ReadBlock() return err |