| 2010 | } |
| 2011 | |
| 2012 | void |
| 2013 | Layout::update () const |
| 2014 | { |
| 2015 | // NOTE: this is double checking - which is not inherently thread-safe. |
| 2016 | // However, it's so much faster, and the deal is to start multithreaded |
| 2017 | // reads with an already-updated layout and not to do reading from one thread |
| 2018 | // while writing from another. So it's worth the risk. |
| 2019 | if (! (hier_dirty () || bboxes_dirty () || prop_ids_dirty ())) { |
| 2020 | return; |
| 2021 | } |
| 2022 | |
| 2023 | tl::MutexLocker locker (&lock ()); |
| 2024 | |
| 2025 | // We do double checking here as another thread might do the update as well. |
| 2026 | // Checking "under_constrcution" will also prevent recursion in "update". |
| 2027 | if (under_construction () || ! (hier_dirty () || bboxes_dirty () || prop_ids_dirty ())) { |
| 2028 | return; |
| 2029 | } |
| 2030 | |
| 2031 | force_update_no_lock (); |
| 2032 | } |
| 2033 | |
| 2034 | bool |
| 2035 | Layout::update_needed () const |