block_in_place in transcoder

This commit is contained in:
Dmitry Belyaev 2022-09-23 22:03:19 +03:00
parent 0ad014a544
commit 0b98540e35
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3

View File

@ -120,14 +120,12 @@ async fn transcoder_task(
encoding_to: EncodingRef, encoding_to: EncodingRef,
) { ) {
while let Some(FileData { name, data }) = rx.recv().await { while let Some(FileData { name, data }) = rx.recv().await {
let new_data = task::spawn_blocking(move || { let new_data = task::block_in_place(move || {
let text = encoding_from.decode(&data, DecoderTrap::Ignore).unwrap(); let text = encoding_from.decode(&data, DecoderTrap::Ignore).unwrap();
encoding_to encoding_to
.encode(text.as_str(), EncoderTrap::Ignore) .encode(text.as_str(), EncoderTrap::Ignore)
.unwrap() .unwrap()
}) });
.await
.unwrap();
tx.send(FileData { tx.send(FileData {
name, name,