mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
757 B
29 lines
757 B
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 |
|
|
|
Closable |
|
} |
|
|
|
// HasType is the interface for objects that knows its type. |
|
type HasType interface { |
|
// Type returns the type of the object. |
|
Type() interface{} |
|
}
|
|
|