diff options
author | Manish Goregaokar <manishsmail@gmail.com> | 2015-08-07 03:45:29 +0530 |
---|---|---|
committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-08-07 03:45:29 +0530 |
commit | 730ee4d341cdaa4a1dcc1a3517f45db1f522ea94 (patch) | |
tree | f9d733e5b556f2f79635c6e8117221f6828824c3 /components/layout/layout_task.rs | |
parent | fb28b3ddb4530617efb40e8009609e4b238b6e5a (diff) | |
parent | bf3ecaa90179535cacb22a39f324a45b64eb51c4 (diff) | |
download | servo-730ee4d341cdaa4a1dcc1a3517f45db1f522ea94.tar.gz servo-730ee4d341cdaa4a1dcc1a3517f45db1f522ea94.zip |
Rollup merge of #7034 - Ms2ger:mem, r=jdm
Create a run_with_memory_reporting method to reduce the boilerplate a…
…ssociated with registering memory reporters.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7034)
<!-- Reviewable:end -->
Diffstat (limited to 'components/layout/layout_task.rs')
-rw-r--r-- | components/layout/layout_task.rs | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index fb5b6e5ef79..575aee4a71a 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -47,7 +47,7 @@ use log; use msg::compositor_msg::{Epoch, ScrollPolicy, LayerId}; use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::{ConstellationChan, Failure, PipelineExitType, PipelineId}; -use profile_traits::mem::{self, Report, Reporter, ReporterRequest, ReportKind, ReportsChan}; +use profile_traits::mem::{self, Report, ReportKind, ReportsChan}; use profile_traits::time::{self, ProfilerMetadata, profile}; use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType}; use net_traits::{load_bytes_iter, PendingAsyncLoad}; @@ -257,25 +257,10 @@ impl LayoutTaskFactory for LayoutTask { time_profiler_chan, mem_profiler_chan.clone()); - // Create a memory reporter thread. let reporter_name = format!("layout-reporter-{}", id.0); - let (reporter_sender, reporter_receiver) = - ipc::channel::<ReporterRequest>().unwrap(); - let layout_chan_for_reporter = layout_chan.clone(); - ROUTER.add_route(reporter_receiver.to_opaque(), box move |message| { - // Just injects an appropriate event into the layout task's queue. - let request: ReporterRequest = message.to().unwrap(); - layout_chan_for_reporter.0.send(Msg::CollectReports(request.reports_channel)) - .unwrap(); - }); - mem_profiler_chan.send(mem::ProfilerMsg::RegisterReporter( - reporter_name.clone(), - Reporter(reporter_sender))); - - layout.start(); - - let msg = mem::ProfilerMsg::UnregisterReporter(reporter_name); - mem_profiler_chan.send(msg); + mem_profiler_chan.run_with_memory_reporting(|| { + layout.start(); + }, reporter_name, layout_chan.0, Msg::CollectReports); } shutdown_chan.send(()).unwrap(); }, ConstellationMsg::Failure(failure_msg), con_chan); |