test/unit-hashtable.cc
// Test suite for basic transactional get functionality
Test suite for basic transactional get functionality
Test suite for basic transactional get functionality
void testBasicTransGet() {
    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.value);
        assert(*result.value == 42);
        assert(t.try_commit());
    }
    {
        TestTransaction t1(1);
        int value1 = 9001;
        auto result1 = ht.transPut(3, &value1);
        assert(!result1.abort);
        assert(!result1.existed);
        TestTransaction t2(2);
        auto result2 = ht.transGet(3, ht_type::ReadWriteAccess);
        assert(!result2.value);
        assert(t1.try_commit());
        assert(t2.try_commit());
    }
    printf("PASS: %s\n", __FUNCTION__);
}
void testBasicTransGet ( ) { 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 . value ) ; assert ( * result . value == 42 ) ; assert ( t . try_commit ( ) ) ; } { TestTransaction t1 ( 1 ) ; int value1 = 9001 ; auto result1 = ht . transPut ( 3 , & value1 ) ; assert ( ! result1 . abort ) ; assert ( ! result1 . existed ) ; TestTransaction t2 ( 2 ) ; auto result2 = ht . transGet ( 3 , ht_type :: ReadWriteAccess ) ; assert ( ! result2 . value ) ; assert ( t1 . try_commit ( ) ) ; assert ( t2 . try_commit ( ) ) ; } printf ( " \n " , __FUNCTION__ ) ; }
Test suite for basic transactional get functionality
Test suite for basic transactional get functionality
// Test transactional get // Reads should not see pending writes