m_future.wait ();
}
-cooked_index::cooked_index (vec_type &&vec, dwarf2_per_bfd *per_bfd)
+cooked_index::cooked_index (vec_type &&vec)
: m_vector (std::move (vec))
{
for (auto &idx : m_vector)
idx->finalize ();
- /* This must be set after all the finalization tasks have been
- started, because it may call 'wait'. */
- m_write_future
- = gdb::thread_pool::g_thread_pool->post_task ([this, per_bfd] ()
- {
- maybe_write_index (per_bfd);
- });
-
/* ACTIVE_VECTORS is not locked, and this assert ensures that this
will be caught if ever moved to the background. */
gdb_assert (is_main_thread ());
active_vectors.insert (this);
}
+/* See cooked-index.h. */
+
+void
+cooked_index::start_writing_index (dwarf2_per_bfd *per_bfd)
+{
+ /* This must be set after all the finalization tasks have been
+ started, because it may call 'wait'. */
+ m_write_future
+ = gdb::thread_pool::g_thread_pool->post_task ([this, per_bfd] ()
+ {
+ maybe_write_index (per_bfd);
+ });
+}
+
cooked_index::~cooked_index ()
{
/* The 'finalize' method may be run in a different thread. If
object. */
using vec_type = std::vector<std::unique_ptr<cooked_index_shard>>;
- cooked_index (vec_type &&vec, dwarf2_per_bfd *per_bfd);
+ explicit cooked_index (vec_type &&vec);
~cooked_index () override;
DISABLE_COPY_AND_ASSIGN (cooked_index);
m_write_future.wait ();
}
+ /* Start writing to the index cache, if the user asked for this. */
+ void start_writing_index (dwarf2_per_bfd *per_bfd);
+
private:
/* Maybe write the index to the index cache. */
indexes.push_back (index_storage.release ());
indexes.shrink_to_fit ();
- cooked_index *vec = new cooked_index (std::move (indexes), per_bfd);
+ cooked_index *vec = new cooked_index (std::move (indexes));
per_bfd->index_table.reset (vec);
+ /* Cannot start writing the index entry until after the
+ 'index_table' member has been set. */
+ vec->start_writing_index (per_bfd);
+
const cooked_index_entry *main_entry = vec->get_main ();
if (main_entry != nullptr)
{