diff options
| author | 2020-12-30 15:15:30 +0100 | |
|---|---|---|
| committer | 2020-12-30 15:15:30 +0100 | |
| commit | fb85adfcec1a8c920b026a8c43b66823b39f3e73 (patch) | |
| tree | c9497e405daec4f05cf1a515ce36a5808f5bba42 | |
| parent | remove the allocator from Db and Db.init (diff) | |
| download | zig-sqlite-fb85adfcec1a8c920b026a8c43b66823b39f3e73.tar.gz zig-sqlite-fb85adfcec1a8c920b026a8c43b66823b39f3e73.tar.xz zig-sqlite-fb85adfcec1a8c920b026a8c43b66823b39f3e73.zip | |
document ThreadingMode and InitOptions
| -rw-r--r-- | sqlite.zig | 20 |
1 files changed, 19 insertions, 1 deletions
| @@ -12,16 +12,34 @@ usingnamespace @import("query.zig"); | |||
| 12 | 12 | ||
| 13 | const logger = std.log.scoped(.sqlite); | 13 | const logger = std.log.scoped(.sqlite); |
| 14 | 14 | ||
| 15 | /// ThreadingMode controls the threading mode used by SQLite. | ||
| 16 | /// | ||
| 17 | /// See https://sqlite.org/threadsafe.html | ||
| 15 | pub const ThreadingMode = enum { | 18 | pub const ThreadingMode = enum { |
| 19 | /// SingleThread makes SQLite unsafe to use with more than a single thread at once. | ||
| 16 | SingleThread, | 20 | SingleThread, |
| 21 | /// MultiThread makes SQLite safe to use with multiple threads at once provided that | ||
| 22 | /// a single database connection is not by more than a single thread at once. | ||
| 17 | MultiThread, | 23 | MultiThread, |
| 24 | /// Serialized makes SQLite safe to use with multiple threads at once with no restriction. | ||
| 18 | Serialized, | 25 | Serialized, |
| 19 | }; | 26 | }; |
| 20 | 27 | ||
| 21 | pub const InitOptions = struct { | 28 | pub const InitOptions = struct { |
| 29 | /// mode controls how the database is opened. | ||
| 30 | /// | ||
| 31 | /// Defaults to a in-memory database. | ||
| 22 | mode: Db.Mode = .Memory, | 32 | mode: Db.Mode = .Memory, |
| 33 | |||
| 34 | /// open_flags controls the flags used when opening a database. | ||
| 35 | /// | ||
| 36 | /// Defaults to a read only database. | ||
| 23 | open_flags: Db.OpenFlags = .{}, | 37 | open_flags: Db.OpenFlags = .{}, |
| 24 | threading_mode: ThreadingMode = .SingleThread, | 38 | |
| 39 | /// threading_mode controls the threading mode used by SQLite. | ||
| 40 | /// | ||
| 41 | /// Defaults to Serialized. | ||
| 42 | threading_mode: ThreadingMode = .Serialized, | ||
| 25 | }; | 43 | }; |
| 26 | 44 | ||
| 27 | fn isThreadSafe() bool { | 45 | fn isThreadSafe() bool { |