Comments (6)
The bitflags
approach is very cool; I'd opened a similar issue but this is more comprehensive, so I'm closing it. There is one issue with the open_ex
options: GDAL_OF_SHARED
that needs to be discussed (see below).
Sharing Issue
GDAL since 2.4 allows Dataset
to be accessed from different threads, as long as only one thread accesses it at any time (ref. discussion). In this crate, we impl Send
on Dataset
to reflect that we can pass it to another thread, but not Sync
so it is not accessed from two threads at the same time.
However, the GDAL_OF_SHARED
option allows this to be subverted. We might open the same dataset twice with the shared option, and then pass one of the Dataset
handles to another thread. This could lead to undefined behaviours as we are accessing a non-thread-safe data-structure from different threads simultaneously.
The simplest solution I could think of is to remove GDAL_OF_SHARED
from the bitflags, thus not allowing it in the flags. Then, we could add a flag in DatasetOptions
which can only be set via an unsafe
method. This way, we allow shared open, if the user knows what they're doing, and there's no way to get UB via safe rust.
from gdal.
wow this is a really cool solution. I think @rmanoka is right. we should remove the shared bitfag and add an unsafe method to DatasetOptions to enable this feature.
from gdal.
I do agree that GDAL_OF_SHARED
defeat the purpose of multithreading safety and I'm also in favor te remove it.
from gdal.
Then, we could add a flag in DatasetOptions which can only be set via an unsafe method
Amha, this is even not necessary and it would be better to rely on rust safe way of handling shared access to dataset.
from gdal.
i guess we can add a special method for shared later ( if we need it)
from gdal.
Amha, this is even not necessary and it would be better to rely on rust safe way of handling shared access to dataset.
Sounds good; bitflags already has an unsafe fn from_bits_unchecked
that allows this anyway.
from gdal.
Related Issues (20)
- Change raster and block sizes to `usize`
- Fix issues with `SpatialRef::set_axis_mapping_strategy` API.
- Mutators in `Feature` don't require mutable receiver
- `Feature` fields getters and setters should accept field indexes HOT 3
- [Feature Request] Guess the Driver Type based on the file extension HOT 18
- FeatureIterator doesn't reset if the iterator isn't completely read HOT 1
- [Feature] Add `DriverIterator` to iterate through the available drivers HOT 1
- Random test suite crash HOT 23
- Can it support macos? HOT 6
- Update OGR arrow example to use arrow-rs
- No iterator support for rasterbands
- Cannot share dataset safely between threads HOT 2
- Error reported when cross compiling on Windows HOT 2
- Discord link not working HOT 1
- is anyone here haved this problem solve? gdal-sys HOT 5
- Cross-compile for aarch64-linux-gnu
- `Polygonize` wrapper HOT 3
- Can `Geometry` be `Send`? HOT 2
- No pre-built bindings available for GDAL version 3.8 HOT 1
- Add Wrapper for OGR_L_Intersection
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gdal.