From fb85adfcec1a8c920b026a8c43b66823b39f3e73 Mon Sep 17 00:00:00 2001 From: Vincent Rischmann Date: Wed, 30 Dec 2020 15:15:30 +0100 Subject: document ThreadingMode and InitOptions --- sqlite.zig | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'sqlite.zig') diff --git a/sqlite.zig b/sqlite.zig index 3f2cd5a..4a65461 100644 --- a/sqlite.zig +++ b/sqlite.zig @@ -12,16 +12,34 @@ usingnamespace @import("query.zig"); const logger = std.log.scoped(.sqlite); +/// ThreadingMode controls the threading mode used by SQLite. +/// +/// See https://sqlite.org/threadsafe.html pub const ThreadingMode = enum { + /// SingleThread makes SQLite unsafe to use with more than a single thread at once. SingleThread, + /// MultiThread makes SQLite safe to use with multiple threads at once provided that + /// a single database connection is not by more than a single thread at once. MultiThread, + /// Serialized makes SQLite safe to use with multiple threads at once with no restriction. Serialized, }; pub const InitOptions = struct { + /// mode controls how the database is opened. + /// + /// Defaults to a in-memory database. mode: Db.Mode = .Memory, + + /// open_flags controls the flags used when opening a database. + /// + /// Defaults to a read only database. open_flags: Db.OpenFlags = .{}, - threading_mode: ThreadingMode = .SingleThread, + + /// threading_mode controls the threading mode used by SQLite. + /// + /// Defaults to Serialized. + threading_mode: ThreadingMode = .Serialized, }; fn isThreadSafe() bool { -- cgit v1.2.3