Index: Cargo.toml ================================================================== --- Cargo.toml +++ Cargo.toml @@ -1,8 +1,8 @@ [package] name = "sqlsrv" -version = "0.0.3" +version = "0.0.4" edition = "2021" license = "0BSD" categories = [ "database" ] keywords = [ "sqlite", "server" ] repository = "https://repos.qrnch.tech/pub/sqlsrv" Index: src/lib.rs ================================================================== --- src/lib.rs +++ src/lib.rs @@ -517,30 +517,43 @@ } /// Run a closure with read/write connection pub fn rw_run(&self, f: F) where - F: FnOnce(&mut Connection) + Send + 'static + F: FnOnce(&mut Connection) -> Option + Send + 'static { let mut rwconn = self.writer(); - self.tpool.execute(move || f(&mut rwconn)); + self.tpool.execute(move || { + let dirt = f(&mut rwconn); + if let Some(dirt) = dirt { + rwconn.add_dirt(dirt); + } + }); } + /// Run a closure with read/write connection, returning a channel end-point /// for retreiving result. pub fn rw_run_result(&self, f: F) -> swctx::WaitCtx where - F: FnOnce(&mut Connection, swctx::SetCtx) + Send + 'static, + F: FnOnce(&mut Connection, swctx::SetCtx) -> Option + + Send + + 'static, T: Send + 'static, E: Send + 'static { let mut rwconn = self.writer(); let (sctx, wctx) = swctx::mkpair(); - self.tpool.execute(move || f(&mut rwconn, sctx)); + self.tpool.execute(move || { + let dirt = f(&mut rwconn, sctx); + if let Some(dirt) = dirt { + rwconn.add_dirt(dirt); + } + }); wctx } /// Perform an incremental vacuum. @@ -559,10 +572,12 @@ }; match res { Ok(_) => sctx.set(()), Err(e) => sctx.fail(e) } + + None }) } /// Consume self and wait for all threads in thread pool to complete. pub fn shutdown(self) { Index: www/changelog.md ================================================================== --- www/changelog.md +++ www/changelog.md @@ -1,17 +1,27 @@ # Change Log ## [Unreleased] -[Details](/vdiff?from=sqlsrv-0.0.3&to=trunk) +[Details](/vdiff?from=sqlsrv-0.0.4&to=trunk) ### Added ### Changed ### Removed +--- + +## [0.0.4] + +[Details](/vdiff?from=sqlsrv-0.0.3&to=sqlsrv-0.0.4) + +### Changed + +- Allow `dirt` to be returned from read/write thread wrappers. + --- ## [0.0.3] - 2024-01-18 [Details](/vdiff?from=sqlsrv-0.0.2&to=sqlsrv-0.0.3)