Skip to content

Various cleanups from anguslees@#1

Merged
gyuho merged 1 commit into
gyuho:mainfrom
anguslees:gus
Jun 10, 2021
Merged

Various cleanups from anguslees@#1
gyuho merged 1 commit into
gyuho:mainfrom
anguslees:gus

Conversation

@gyuho
Copy link
Copy Markdown
Owner

@gyuho gyuho commented May 24, 2021

More idiomatic Rust :)

Split channel sender and receiver into two clear owners.

Replace sync crossbeam with async tokio channels, so we don't hold a
synchronous lock over async await.

Simplify applier start/stop lifecycle with RAII pattern (could do more here).

Pass owned echo::Manager to apply_async rather than Arc reference.

Use ? operator and early-return to refactor some deeply nested code,
particularly in server::handle_request.

Notifier: Replace async RwLock<> with simpler sync Arc<Mutex<>>
because these locks don't need to be held over async await.

echo::Manager: Use ownership (&mut) to assert mutual exclusion
rather than a lock.

echo::Request: Treat omitted message as equivalent to
message == "", to better match golang omitempty semantics.

Split channel sender and receiver into two clear owners.

Replace sync crossbeam with async tokio channels, so we don't hold a
synchronous lock over async await.

Simplify applier start/stop lifecycle with RAII pattern (could do more here).

Pass owned `echo::Manager` to `apply_async` rather than `Arc` reference.

Use `?` operator and early-return to refactor some deeply nested code,
particularly in `server::handle_request`.

`Notifier`: Replace async `RwLock<>` with simpler sync `Arc<Mutex<>>`
because these locks don't need to be held over async await.

`echo::Manager`: Use ownership (`&mut`) to assert mutual exclusion
rather than a lock.

`echo::Request`: Treat omitted `message` as equivalent to
`message == ""`, to better match golang `omitempty` semantics.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants