#!./pmemobjcli -s
# This is an example script for pmemobjcli application.
# usage: ./example_tx.posc <file>

# allocate root object with specified size
pmemobj_root 256

# allocate two zeroed objects in root object
# at positions 0 and 1
pmemobj_zalloc r.0 1 8192
pmemobj_zalloc r.1 2 256

# begin transaction with jmp_buf argument
pmemobj_tx_begin jmp

# create a snapshot of entire root object
pmemobj_tx_add_range r 0 256

# allocate an object using strdup at 4th position
# in root object
pmemobj_tx_strdup r.4 0 5

# add snaphots
pmemobj_tx_add_range_direct r.0 64 128
pmemobj_tx_add_range r.1 16 16

# allocate object transactionally
pmemobj_tx_zalloc r.3 8192 3

# reallocate object transactionally
pmemobj_tx_zrealloc r.3 2048 3

# de-allocate object transactionally
pmemobj_tx_free r.4

# print current stage
pmemobj_tx_stage

# begin transaction without jmp_buf argument
pmemobj_tx_begin

# commit current transaction
pmemobj_tx_commit

# print current stage
pmemobj_tx_stage

# move to the next stage
pmemobj_tx_process

# print current stage
pmemobj_tx_stage

# end current transaction
pmemobj_tx_end

# print current stage
pmemobj_tx_stage

# abort current transaction
pmemobj_tx_abort -1

# print current stage
pmemobj_tx_stage

# end current transaction
pmemobj_tx_end

# print current stage
pmemobj_tx_stage
