Lock when modifying @pending_size and @pending