refactor(vips): remove obvious code

master
Tomas Aparicio 11 years ago
parent b8925f9f30
commit eb933a8c38

@ -18,7 +18,7 @@ import (
var ( var (
m sync.Mutex m sync.Mutex
initialized bool = false initialized bool
) )
type VipsMemoryInfo struct { type VipsMemoryInfo struct {
@ -48,16 +48,16 @@ type vipsWatermarkTextOptions struct {
} }
func init() { func init() {
if C.VIPS_MAJOR_VERSION <= 7 && C.VIPS_MINOR_VERSION < 40 {
panic("unsupported old vips version!")
}
Initialize() Initialize()
} }
// Explicit thread-safe start of libvips. // Explicit thread-safe start of libvips.
// Only call this function if you've previously shutdown libvips // Only call this function if you've previously shutdown libvips
func Initialize() { func Initialize() {
if C.VIPS_MAJOR_VERSION <= 7 && C.VIPS_MINOR_VERSION < 40 {
panic("unsupported libvips version!")
}
m.Lock() m.Lock()
runtime.LockOSThread() runtime.LockOSThread()
defer m.Unlock() defer m.Unlock()
@ -65,7 +65,6 @@ func Initialize() {
err := C.vips_init(C.CString("bimg")) err := C.vips_init(C.CString("bimg"))
if err != 0 { if err != 0 {
Shutdown()
panic("unable to start vips!") panic("unable to start vips!")
} }
@ -85,13 +84,13 @@ func Initialize() {
initialized = true initialized = true
} }
// Explicit thread-safe libvips shutdown. Call this to drop caches. // Thread-safe function to shutdown libvips. You could call this to drop caches as well.
// If libvips was already initialized, the function is no-op // If libvips was already initialized, the function is no-op
func Shutdown() { func Shutdown() {
m.Lock() m.Lock()
defer m.Unlock() defer m.Unlock()
if initialized == true { if initialized {
C.vips_shutdown() C.vips_shutdown()
initialized = false initialized = false
} }

Loading…
Cancel
Save