@@ -1120,9 +1120,11 @@ class ObjectBoxC {
1120
1120
_store_is_open_ptr.asFunction <_dart_store_is_open>();
1121
1121
1122
1122
/// Attach to a previously opened store matching the path of the DB directory, which was used for opening the store.
1123
- /// The returned store is a new instance (e.g. different pointer value) with its own lifetime and must also be closed.
1123
+ /// The returned store is a new instance (e.g. different pointer value) with its own lifetime and must also be closed
1124
+ /// via obx_store_close().
1124
1125
/// The actual underlying store is only closed when the last store OBX_store instance is closed.
1125
1126
/// @returns nullptr if no open store was found (i.e. not opened before or already closed)
1127
+ /// @see obx_store_clone() for "attaching" to a available store instance.
1126
1128
ffi.Pointer <OBX_store > store_attach (
1127
1129
ffi.Pointer <ffi.Int8 > path,
1128
1130
) {
@@ -1160,6 +1162,27 @@ class ObjectBoxC {
1160
1162
late final _dart_store_attach_or_open _store_attach_or_open =
1161
1163
_store_attach_or_open_ptr.asFunction <_dart_store_attach_or_open>();
1162
1164
1165
+ /// Clone a previously opened store; while a store instance is usable from multiple threads, situations may exist
1166
+ /// in which cloning a store simplifies the overall lifecycle.
1167
+ /// E.g. when a store is used for multiple threads and it may only be fully released once the last thread completes.
1168
+ /// The returned store is a new instance (e.g. different pointer value) with its own lifetime and must also be closed
1169
+ /// via obx_store_close().
1170
+ /// The actual underlying store is only closed when the last store OBX_store instance is closed.
1171
+ /// @returns nullptr if the store could not be cloned
1172
+ /// @see obx_store_attach() for "cloning" using the store's path.
1173
+ ffi.Pointer <OBX_store > store_clone (
1174
+ ffi.Pointer <OBX_store > store,
1175
+ ) {
1176
+ return _store_clone (
1177
+ store,
1178
+ );
1179
+ }
1180
+
1181
+ late final _store_clone_ptr =
1182
+ _lookup< ffi.NativeFunction <_c_store_clone>> ('obx_store_clone' );
1183
+ late final _dart_store_clone _store_clone =
1184
+ _store_clone_ptr.asFunction <_dart_store_clone>();
1185
+
1163
1186
/// For stores created outside of this C API, e.g. via C++ or Java, this is how you can use it via C too.
1164
1187
/// Like this, it is OK to use the same store instance (same database) from multiple languages in parallel.
1165
1188
/// Note: the store's life time will still be managed outside of the C API;
@@ -7679,6 +7702,14 @@ typedef _dart_store_attach_or_open = ffi.Pointer<OBX_store> Function(
7679
7702
ffi.Pointer <ffi.Uint8 > out_attached,
7680
7703
);
7681
7704
7705
+ typedef _c_store_clone = ffi.Pointer <OBX_store > Function (
7706
+ ffi.Pointer <OBX_store > store,
7707
+ );
7708
+
7709
+ typedef _dart_store_clone = ffi.Pointer <OBX_store > Function (
7710
+ ffi.Pointer <OBX_store > store,
7711
+ );
7712
+
7682
7713
typedef _c_store_wrap = ffi.Pointer <OBX_store > Function (
7683
7714
ffi.Pointer <ffi.Void > core_store,
7684
7715
);
0 commit comments