1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-04 00:05:21 -05:00

remove context in struct

This commit is contained in:
Darien Raymond
2018-02-08 15:39:46 +01:00
parent a1ae4aa515
commit efcb567273
44 changed files with 379 additions and 270 deletions

View File

@@ -1,10 +1,23 @@
package common
// Closable is the interface for objects that can release its resources.
type Closable interface {
// Close release all resources used by this object, including goroutines.
Close() error
}
// Close closes the obj if it is a Closable.
func Close(obj interface{}) error {
if c, ok := obj.(Closable); ok {
return c.Close()
}
return nil
}
// Runnable is the interface for objects that can start to work and stop on demand.
type Runnable interface {
// Start starts the runnable object. Upon the method returning nil, the object begins to function properly.
Start() error
// Close stops the object being working.
Close()
Closable
}