File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -313,6 +313,34 @@ func (txn *Txn) abort() {
313313 txn .clearTxn ()
314314}
315315
316+ func (txn * Txn ) Park (autounpark bool ) error {
317+ if txn ._txn == nil {
318+ return nil
319+ }
320+
321+ if txn .env ._env != nil {
322+ ret := C .mdbx_txn_park (txn ._txn , C .bool (autounpark ))
323+ if ret != success {
324+ return operrno ("mdbx_txn_park" , ret )
325+ }
326+ }
327+ return nil
328+ }
329+
330+ func (txn * Txn ) Unpark (restartIfOusted bool ) error {
331+ if txn ._txn == nil {
332+ return nil
333+ }
334+
335+ if txn .env ._env != nil {
336+ ret := C .mdbx_txn_unpark (txn ._txn , C .bool (restartIfOusted ))
337+ if ret != success {
338+ return operrno ("mdbx_txn_park" , ret )
339+ }
340+ }
341+ return nil
342+ }
343+
316344func (txn * Txn ) clearTxn () {
317345 // Clear the C object to prevent any potential future use of the freed
318346 // pointer.
Original file line number Diff line number Diff line change @@ -717,6 +717,27 @@ func TestTxn_Reset_doubleReset(t *testing.T) {
717717 txn .Reset ()
718718}
719719
720+ func TestTxn_ParkUnpark (t * testing.T ) {
721+ env , _ := setup (t )
722+
723+ txn , err := env .BeginTxn (nil , Readonly )
724+ if err != nil {
725+ t .Error (err )
726+ return
727+ }
728+ defer txn .Abort ()
729+ err = txn .Park (true )
730+ if err != nil {
731+ t .Error (err )
732+ return
733+ }
734+ err = txn .Unpark (true )
735+ if err != nil {
736+ t .Error (err )
737+ return
738+ }
739+ }
740+
720741// This test demonstrates that Reset/Renew have no effect on writable
721742// transactions. The transaction may be committed after Reset/Renew are called.
722743func TestTxn_Reset_writeTxn (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments