Ejemplo n.º 1
0
TEST( shared_blk , ownership ){
  codex::buffer::shared_blk blk2( 32 );
  ASSERT_EQ( (int)blk2.size() , 32 );
  ASSERT_NE( blk2.read_ptr() , nullptr );
  ASSERT_NE( blk2.write_ptr() , nullptr );
  ASSERT_EQ( blk2.ref_count() , 1 );
  {
    codex::buffer::shared_blk bls3( blk2 );
    ASSERT_EQ( blk2.ref_count() , 2 );
  }
  ASSERT_EQ( blk2.ref_count() , 1 );

  codex::buffer::shared_blk blk( std::move( blk2 ));
  ASSERT_EQ( blk2.ref_count() , 0 );
  ASSERT_EQ( blk.ref_count() , 1 );

  blk2 = blk;
  ASSERT_EQ( blk.ref_count() , 2 );
  ASSERT_EQ( blk2.ref_count() , 2 );

  blk = std::move( blk2 );
  ASSERT_EQ( blk2.ref_count() , 0 );
  ASSERT_EQ( blk.ref_count() , 1 );
}
Ejemplo n.º 2
0
void Space::oop_iterate(OopClosure* blk) {
  ObjectToOopClosure blk2(blk);
  object_iterate(&blk2);
}