-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change: VoiceModel
→ VoiceModelFile
#832
Merged
qryxip
merged 19 commits into
VOICEVOX:main
from
qryxip:change-voice-model-to-voice-model-file
Sep 19, 2024
Merged
Changes from 11 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f32872e
change: `VoiceModel` → `VoiceModelFile`
qryxip 58a42aa
Minor refactor
qryxip 2fe40f6
`__aexit__`をロックする実装にする
qryxip dfc5002
ドキュメントを訂正
qryxip 695c0a9
クローズしてても`Drop`が警告を出すのを修正
qryxip d69571a
Java APIでも`RwLock`管理にする
qryxip a906bcd
`Synthesizer.__aexit__`はexampleではやらない
qryxip 6f0edf4
Javadocを更新
qryxip d9c86ed
Minor refactor
qryxip aebe2ea
誤字訂正
qryxip 80c707b
Minor refactor
qryxip 22c36e0
`open_file_ro`にdoc
qryxip 11be136
`try_map_guard`にdoc
qryxip 32be19f
誤字訂正
qryxip 752aedb
fixup! `open_file_ro`にdoc
qryxip 74a482d
`try_map_guard`から`T: 'static`を外す
qryxip 9555cfc
fixup! `try_map_guard`から`T: 'static`を外す
qryxip b01afb0
fixup! `try_map_guard`から`T: 'static`を外す
qryxip aed651b
fixup! `try_map_guard`から`T: 'static`を外す
qryxip File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use std::{marker::PhantomData, ops::Deref}; | ||
|
||
use ouroboros::self_referencing; | ||
|
||
pub enum MaybeClosed<T> { | ||
Open(T), | ||
Closed, | ||
} | ||
|
||
// [`mapped_lock_guards`]のようなことをやるためのユーティリティ。 | ||
// | ||
// [`mapped_lock_guards`]: https://github.com/rust-lang/rust/issues/117108 | ||
pub fn try_map_guard<'a, G, F, T, E>(guard: G, f: F) -> Result<impl Deref<Target = T> + 'a, E> | ||
where | ||
G: 'a, | ||
F: FnOnce(&G) -> Result<&T, E>, | ||
T: 'static, | ||
{ | ||
return MappedLockTryBuilder { | ||
guard, | ||
content_builder: f, | ||
marker: PhantomData, | ||
} | ||
.try_build(); | ||
|
||
#[self_referencing] | ||
struct MappedLock<'a, G: 'a, T: 'static> { | ||
guard: G, | ||
|
||
#[borrows(guard)] | ||
content: &'this T, | ||
|
||
marker: PhantomData<&'a ()>, | ||
} | ||
|
||
impl<'a, G: 'a, T: 'static> Deref for MappedLock<'a, G, T> { | ||
type Target = T; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
self.borrow_content() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このコードをそのままChatGPT 4oに投げ付けてみたら一発で満点の答えを返してくれた。こういうところではコメントでの説明を省いていきたいなーと個人的には思っている。
https://chatgpt.com/share/66ea8dce-a580-800c-b4fd-37af1084bfa5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
実装の中身については、
G: 'a, T: 'static
(∀.'a
)という制約を入れることで"T
ourlivesG
"の関係にしてouroborosに突っ込めばSafe Rustで記述しきれる、というのが肝。ただChatGPTがこのことに辿り着くのは難しそう。「この
'a
は?」って聞いてもわかってなさげな答えを返してきた。…やっぱコメント書くべきか?いやRust詳しい人ならわかるだろうし…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
11be136
(#832)T: 'static
についてwhyのコメントが要りそうだったので、今回の場合はdocstringに入れることにしました。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
あ!!!
T
outlivesG
の関係にするのにT: 'static
にする必要は無い!ということで、whyのドキュメントは消えてまたコメント無しに…
74a482d
(#832)追記: さらに改修して、今はこんな感じになりました。
https://github.com/qryxip/voicevox_core/blob/aed651b9105046b37036f0178368abdf15b96f64/crates/voicevox_core/src/__internal/interop/raii.rs#L10-L43
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここについて色々考えてみて結論としては
try_map_guard
という名前はwhatもわからないけど、処理を大きく変えてくるような印象はないという感じかなと!!