| ... | @@ -796,14 +796,15 @@ impl Library { | ... | @@ -796,14 +796,15 @@ impl Library { |
| 796 | ) -> Result<Section, Box<dyn Error>> { | 796 | ) -> Result<Section, Box<dyn Error>> { |
| 797 | // The background may hold the replica for a step, which takes a network round trip, | 797 | // The background may hold the replica for a step, which takes a network round trip, |
| 798 | // or be making it as an offline copy. | 798 | // or be making it as an offline copy. |
| 799 | self.open_by(path, notify, Instant::now() + TIMEOUT * 3) | 799 | self.open_by(path, Box::new(notify), Instant::now() + TIMEOUT * 3) |
| 800 | } | 800 | } |
| 801 | | 801 | |
| 802 | /// `open`, waiting until `deadline` for whatever holds the section's replica. | 802 | /// `open`, waiting until `deadline` for whatever holds the section's replica. `notify` is |
| | 803 | /// boxed to compile this once rather than once per caller's closure. |
| 803 | fn open_by( | 804 | fn open_by( |
| 804 | &self, | 805 | &self, |
| 805 | path: &str, | 806 | path: &str, |
| 806 | notify: impl Fn() + Send + 'static, | 807 | notify: Box<dyn Fn() + Send>, |
| 807 | deadline: Instant, | 808 | deadline: Instant, |
| 808 | ) -> Result<Section, Box<dyn Error>> { | 809 | ) -> Result<Section, Box<dyn Error>> { |
| 809 | let notify = Arc::new(Mutex::new(notify)); | 810 | let notify = Arc::new(Mutex::new(notify)); |
| ... | @@ -901,7 +902,7 @@ impl Library { | ... | @@ -901,7 +902,7 @@ impl Library { |
| 901 | path: &str, | 902 | path: &str, |
| 902 | notify: impl Fn() + Send + 'static, | 903 | notify: impl Fn() + Send + 'static, |
| 903 | ) -> Result<Arc<notebook::Replica>, Box<dyn Error>> { | 904 | ) -> Result<Arc<notebook::Replica>, Box<dyn Error>> { |
| 904 | let section = self.open_by(path, notify, Instant::now())?; | 905 | let section = self.open_by(path, Box::new(notify), Instant::now())?; |
| 905 | let replica = Arc::clone(section.replica()); | 906 | let replica = Arc::clone(section.replica()); |
| 906 | self.keep(path, section); | 907 | self.keep(path, section); |
| 907 | Ok(replica) | 908 | Ok(replica) |