objectbox-c | C and C++ database for objects and structs | Database library
kandi X-RAY | objectbox-c Summary
kandi X-RAY | objectbox-c Summary
ObjectBox Data Persistence and Data Sync follows an offline-first approach and can be used on-premise as well as with a cloud setup. This is the ObjectBox runtime library to run ObjectBox as an embedded database in your C or C++ application.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of objectbox-c
objectbox-c Key Features
objectbox-c Examples and Code Snippets
Community Discussions
Trending Discussions on objectbox-c
QUESTION
Creating a separate thread for a question stated in a comment...
...How does ObjectBox handle concurrent(by different threads/isolates) write requests? example of my use case: FCM "onBackgroundmessage" call runs in a different isolate, the same time multiple write requests might happen. "Hive" is failing in this case completely. Is there any inbuild solution in ObjectBox?
ANSWER
Answered 2021-Jul-25 at 14:05ObjectBox for dart is based on a native ObjectBox core library that handles concurrency using Transactions. Let me pick out few points relevant to the question:
- Transactions manage multi-threading; e.g. a transaction is tied to a thread and vice versa.
- Read(-only) transactions never get blocked or block a write transaction.
- There can only be a single write transaction at any time; they run strictly one after the other (sequential).
As for the isolates in Dart/Flutter - yes, they can safely access the same store, you just need to make sure it really is the same native store instance. To do so, you do the following steps:
- Create a
Store()
instance in your main isolate, as you normally would. - Get
ByteData store.reference
which contains the information about the native store. - Send this reference to another isolate, via a
SendPort
. - In another isolate, receive the reference and open a local
Store
instance, usingStore.fromReference(getObjectBoxModel(), msg as ByteData)
. - Now both isolates have their own Dart
Store
instances which internally use the same underlying native store. Therefore, their transactions are synchronized, they both see the same data and get notifications on data changes. 🎉
You can see the code I've just described this test case: https://github.com/objectbox/objectbox-dart/blob/461a948439dcc42f3956b7d21b232eb9c2bc26e1/objectbox/test/isolates_test.dart#L50
Make sure you don't close the store while another isolate is still using it. Better not close it at all - that's best practice in normal applications without huge amounts of background work.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install objectbox-c
C: [include/objectbox.h](include/objectbox.h)
C++: [include/objectbox.hpp](include/objectbox.hpp) (depends on objectbox.h)
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page