verement / lmdb-simple Goto Github PK
View Code? Open in Web Editor NEWSimple Haskell API for LMDB
Home Page: https://hackage.haskell.org/package/lmdb-simple
License: BSD 3-Clause "New" or "Revised" License
Simple Haskell API for LMDB
Home Page: https://hackage.haskell.org/package/lmdb-simple
License: BSD 3-Clause "New" or "Revised" License
In an application, it would be useful to have 2 views of the same environment, on ReadOnly environment and another ReadWrite environment. In this way, the parts of the application needing only ReadOnly operations will take a ReadOnly environment and the compiler will make sure that those parts of the application will only do read only operations on the environment.
So, it would be useful to have a simple operation that will create an Environment ReadOnly
out of an Environment ReadWrite
. It would be the same environment, but it will be marked as ReadOnly so the compiler will only allow readonly operations on it.
runInBoundThread
forks off another thread. However, suppose you're writing an application that manages a bunch of threads. Due to POSIX standards [1] one has to code the main function to catch all exceptions, track child threads, cancel the child threads when you get an exception (which may trigger cleanups in each thread) and then wait for these child threads to exit.
runInBoundThread
interferes with this process, since it (a) forks off a worker-bound-thread that nobody else knows about, (b) is uninterruptible while this worker-bound-thread runs, and (c) and if it receives an asynchronous exception in the meantime, it will not rethrow this to the worker-bound-thread. (Arguably the combination of (b) and (c) are design bugs and I'll file a GHC bug shortly.)
In the case of simple-lmdb this is problematic because the worker-bound-thread is often trying to take a lock e.g. in mdb_txn_begin where it calls _lockEnv
. If the database has already been closed, then the lock is already taken. Then, the thread will hang forever because it is running inside of runInBoundThread
which is uninterruptible.
The simple fix is to use withAsyncBound
and wait
from Control.Concurrent.Async
- define runInBoundThread' action = withAsyncBound action wait
and use this instead of runInBoundThread
everywhere.
[1] these standards dictate that when the main-thread exits, this also causes all child threads to exit immediately without giving the Haskell runtime a chance to run cleanups
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.