summaryrefslogtreecommitdiff
path: root/src/lib/writer.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-03-17 01:25:02 +0100
committerCarl Hetherington <cth@carlh.net>2025-03-22 13:29:58 +0100
commit9dd72fc481349f0b5ce985164441eecfa6485c19 (patch)
treed8136ef6d6b660a5a411722a128d0e309333ff3d /src/lib/writer.cc
parent169c47ede14b6e86e054871a56ffa048357b4463 (diff)
Add abstraction of io_{context,service} and use it as appropriate.
Diffstat (limited to 'src/lib/writer.cc')
-rw-r--r--src/lib/writer.cc58
1 files changed, 28 insertions, 30 deletions
diff --git a/src/lib/writer.cc b/src/lib/writer.cc
index 33e4b8f81..563a86e80 100644
--- a/src/lib/writer.cc
+++ b/src/lib/writer.cc
@@ -529,45 +529,43 @@ Writer::calculate_digests ()
job->sub (_("Computing digests"));
}
- boost::asio::io_service service;
+ dcpomatic::io_context context;
boost::thread_group pool;
- auto work = make_shared<boost::asio::io_service::work>(service);
+ {
+ auto work = dcpomatic::make_work_guard(context);
- int const threads = max (1, Config::instance()->master_encoding_threads());
+ int const threads = max (1, Config::instance()->master_encoding_threads());
- for (int i = 0; i < threads; ++i) {
- pool.create_thread (boost::bind (&boost::asio::io_service::run, &service));
- }
+ for (int i = 0; i < threads; ++i) {
+ pool.create_thread(boost::bind(&dcpomatic::io_context::run, &context));
+ }
- std::function<void (int, int64_t, int64_t)> set_progress;
- if (job) {
- set_progress = boost::bind(&Writer::set_digest_progress, this, job.get(), _1, _2, _3);
- } else {
- set_progress = [](int, int64_t, int64_t) {
- boost::this_thread::interruption_point();
- };
- }
+ std::function<void (int, int64_t, int64_t)> set_progress;
+ if (job) {
+ set_progress = boost::bind(&Writer::set_digest_progress, this, job.get(), _1, _2, _3);
+ } else {
+ set_progress = [](int, int64_t, int64_t) {
+ boost::this_thread::interruption_point();
+ };
+ }
- int index = 0;
+ int index = 0;
- for (auto& i: _reels) {
- service.post(
- boost::bind(
- &ReelWriter::calculate_digests,
- &i,
+ for (auto& i: _reels) {
+ dcpomatic::post(context, boost::bind(
+ &ReelWriter::calculate_digests,
+ &i,
+ std::function<void (int64_t, int64_t)>(boost::bind(set_progress, index, _1, _2))
+ ));
+ ++index;
+ }
+ dcpomatic::post(context, boost::bind(
+ &Writer::calculate_referenced_digests,
+ this,
std::function<void (int64_t, int64_t)>(boost::bind(set_progress, index, _1, _2))
));
- ++index;
}
- service.post(
- boost::bind(
- &Writer::calculate_referenced_digests,
- this,
- std::function<void (int64_t, int64_t)>(boost::bind(set_progress, index, _1, _2))
- ));
-
- work.reset ();
try {
pool.join_all ();
@@ -579,7 +577,7 @@ Writer::calculate_digests ()
pool.join_all ();
}
- service.stop ();
+ context.stop();
}