test/unit-hashtable.cc
// Test suite for basic transactional update functionality
Test suite for basic transactional update functionality
Test suite for basic transactional update functionality
void testBasicTransUpdate() {
    typedef Hashtable<Hashtable_params<int, int>> ht_type;
    ht_type ht;
    {
        ht.nontrans_put(1, 42);
        TestTransaction t(1);
        auto result = ht.transGet(1, ht_type::ReadWriteAccess);
        assert(!result.abort);
        assert(result.success);
        int value = 9001;
        ht.transUpdate(result.ref, &value);
        {
            int* vp = ht.nontrans_get(1);
            assert(vp);
            assert(*vp == 42);
        }
        assert(t.try_commit());
        {
            int* vp = ht.nontrans_get(1);
            assert(vp);
            assert(*vp == 9001);
        }
    }
    printf("PASS: %s\n", __FUNCTION__);
}
void testBasicTransUpdate ( ) { typedef Hashtable < Hashtable_params < int , int > > ht_type ; ht_type ht ; { ht . nontrans_put ( 1 , 42 ) ; TestTransaction t ( 1 ) ; auto result = ht . transGet ( 1 , ht_type :: ReadWriteAccess ) ; assert ( ! result . abort ) ; assert ( result . success ) ; int value = 9001 ; ht . transUpdate ( result . ref , & value ) ; { int * vp = ht . nontrans_get ( 1 ) ; assert ( vp ) ; assert ( * vp == 42 ) ; } assert ( t . try_commit ( ) ) ; { int * vp = ht . nontrans_get ( 1 ) ; assert ( vp ) ; assert ( * vp == 9001 ) ; } } printf ( " \n " , __FUNCTION__ ) ; }
Test suite for basic transactional update functionality
Test suite for basic transactional update functionality
// Test transactional update