Skip to content
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

Thread module to be used for server connection handler #18

Merged
merged 3 commits into from
Apr 5, 2022

Conversation

taikiy
Copy link
Contributor

@taikiy taikiy commented Mar 28, 2022

A simple thread module with mspc channel for sending jobs / terminating the thread. A thread will wait indefinitely for incoming messages from the caller (Receiver's recv() is blocking). Message will either contain a function to be executed by the thread, or a message to let the thread to terminate itself gracefully.

I'll use this thread mod to create a server module in the next diff.

❯ cargo test --lib net -- --nocapture
   Compiling raw-ipa v0.1.0 (/Users/taiki/src/raw-ipa)
    Finished test [unoptimized + debuginfo] target(s) in 0.43s
     Running unittests (target/debug/deps/raw_ipa-6735d863a171d867)

running 1 test
Worker 0 received a job; executing.
Terminating thread 0
Worker 0 is shutting down.
test net::server::tests::test_no_panic ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 7 filtered out; finished in 0.51s

src/net/thread.rs Outdated Show resolved Hide resolved
src/net/thread.rs Outdated Show resolved Hide resolved
src/net/thread.rs Outdated Show resolved Hide resolved
src/net/thread.rs Show resolved Hide resolved
src/net/thread.rs Show resolved Hide resolved
src/net/thread.rs Show resolved Hide resolved
src/net/server.rs Outdated Show resolved Hide resolved
src/net/thread.rs Outdated Show resolved Hide resolved
src/net/thread.rs Outdated Show resolved Hide resolved
src/net/server.rs Show resolved Hide resolved
src/net/thread.rs Outdated Show resolved Hide resolved
@martinthomson martinthomson merged commit e55c93d into private-attribution:main Apr 5, 2022
@taikiy taikiy deleted the thread branch April 14, 2022 09:41
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