-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Description
@Stebalien First off, thank you for maintaining this wonderful library. :-)
I came across a particular issue with the current API. Specifically, TerminfoTerminal::new_with_terminfo takes ownership over a TermInfo. Even though TermInfo is never mutated by a TerminfoTerminal, a TermInfo cannot be reused across multiple TerminfoTerminal values. In particular, the only way to amortize the cost of building a TermInfo is to clone it, but even this can be costly.
I'm not sure what the right API is, but I will note that using Arc solves my specific problem (which permits very cheap multithreaded read-only access).
There are potentially many other solutions, all with their own downsides:
- Require
Arc<TermInfo>instead ofTermInfo, but this feels a little strange to me. - Require
<T: AsRef<TermInfo>>. This meansTermInfoTerminalwill need to grow a type parameter. - Define a new trait with the existing methods on
TermInfoand require that. This also requires an additional type parameter. - Make
TermInfoan opaque struct and use anArcinternally, which will make cloning trivially cheap.
Other ideas? Thoughts?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels