/* See cooked-index-worker.h. */
void
-cooked_index_worker::write_to_cache (const cooked_index *idx,
- deferred_warnings *warn) const
+cooked_index_worker::write_to_cache (const cooked_index *idx)
{
if (idx != nullptr)
{
See PR symtab/30837. This arranges to capture all such
warnings. This is safe because we know the deferred_warnings
object isn't in use by any other thread at this point. */
- scoped_restore_warning_hook defer (warn);
+ scoped_restore_warning_hook defer (&m_warnings);
m_cache_store.store ();
}
}
void
cooked_index_worker::done_reading ()
{
- /* Only handle the scanning results here. Complaints and exceptions
- can only be dealt with on the main thread. */
- std::vector<cooked_index_shard_up> shards;
-
for (auto &one_result : m_results)
- {
- shards.push_back (one_result.release_shard ());
- m_all_parents_map.add_map (*one_result.get_parent_map ());
- }
-
- shards.shrink_to_fit ();
+ m_all_parents_map.add_map (*one_result.get_parent_map ());
dwarf2_per_bfd *per_bfd = m_per_objfile->per_bfd;
cooked_index *table
= (gdb::checked_static_cast<cooked_index *>
(per_bfd->index_table.get ()));
- table->set_contents (std::move (shards), &m_warnings, &m_all_parents_map);
+ table->set_contents ();
}
cache writer.) */
bool wait (cooked_state desired_state, bool allow_quit);
+ /* Release all shards from the results. */
+ std::vector<cooked_index_shard_up> release_shards ()
+ {
+ std::vector<cooked_index_shard_up> result;
+ for (auto &one_result : m_results)
+ result.push_back (one_result.release_shard ());
+ result.shrink_to_fit ();
+ return result;
+ }
+
+ /* Return the object holding all the parent maps. */
+ const parent_map_map *get_parent_map_map () const
+ {
+ return &m_all_parents_map;
+ }
+
protected:
/* Let cooked_index call the 'set' and 'write_to_cache' methods. */
void set (cooked_state desired_state);
/* Write to the index cache. */
- void write_to_cache (const cooked_index *idx,
- deferred_warnings *warn) const;
+ void write_to_cache (const cooked_index *idx);
/* Helper function that does the work of reading. This must be able
to be run in a worker thread without problems. */
}
void
-cooked_index::set_contents (std::vector<cooked_index_shard_up> &&shards,
- deferred_warnings *warn,
- const parent_map_map *parent_maps)
+cooked_index::set_contents ()
{
gdb_assert (m_shards.empty ());
- m_shards = std::move (shards);
+ m_shards = m_state->release_shards ();
m_state->set (cooked_state::MAIN_AVAILABLE);
finalization. However, that would take a slot in the global
thread pool, and if enough such tasks were submitted at once, it
would cause a livelock. */
- gdb::task_group finalizers ([this, warn] ()
+ gdb::task_group finalizers ([this] ()
{
m_state->set (cooked_state::FINALIZED);
- m_state->write_to_cache (index_for_writing (), warn);
+ m_state->write_to_cache (index_for_writing ());
m_state->set (cooked_state::CACHE_DONE);
});
for (auto &shard : m_shards)
{
auto this_shard = shard.get ();
+ const parent_map_map *parent_maps = m_state->get_parent_map_map ();
finalizers.add_task ([=] () { this_shard->finalize (parent_maps); });
}
void start_reading () override;
/* Called by cooked_index_worker to set the contents of this index
- and transition to the MAIN_AVAILABLE state. WARN is used to
- collect any warnings that may arise when writing to the cache.
- PARENT_MAPS is used when resolving pending parent links.
- PARENT_MAPS may be NULL if there are no IS_PARENT_DEFERRED
- entries in VEC. */
- void set_contents (std::vector<cooked_index_shard_up> &&vec,
- deferred_warnings *warn,
- const parent_map_map *parent_maps);
+ and transition to the MAIN_AVAILABLE state. */
+ void set_contents ();
/* A range over a vector of subranges. */
using range = range_chain<cooked_index_shard::range>;