-
Notifications
You must be signed in to change notification settings - Fork 271
/
env.go
45 lines (37 loc) · 1.17 KB
/
env.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package gorocksdb
// #include "rocksdb/c.h"
import "C"
// Env is a system call environment used by a database.
type Env struct {
c *C.rocksdb_env_t
}
// NewDefaultEnv creates a default environment.
func NewDefaultEnv() *Env {
return NewNativeEnv(C.rocksdb_create_default_env())
}
// NewMemEnv creates MemEnv for in-memory testing.
func NewMemEnv() *Env {
return NewNativeEnv(C.rocksdb_create_mem_env())
}
// NewNativeEnv creates a Environment object.
func NewNativeEnv(c *C.rocksdb_env_t) *Env {
return &Env{c}
}
// SetBackgroundThreads sets the number of background worker threads
// of a specific thread pool for this environment.
// 'LOW' is the default pool.
// Default: 1
func (env *Env) SetBackgroundThreads(n int) {
C.rocksdb_env_set_background_threads(env.c, C.int(n))
}
// SetHighPriorityBackgroundThreads sets the size of the high priority
// thread pool that can be used to prevent compactions from stalling
// memtable flushes.
func (env *Env) SetHighPriorityBackgroundThreads(n int) {
C.rocksdb_env_set_high_priority_background_threads(env.c, C.int(n))
}
// Destroy deallocates the Env object.
func (env *Env) Destroy() {
C.rocksdb_env_destroy(env.c)
env.c = nil
}