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

Name all threads #383

Merged
merged 4 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Specify a name for every thread notify creates
  • Loading branch information
Jasper-Bekkers committed Feb 1, 2022
commit 7f9497cb37bc5fd253dcba4be336030cd8b6af31
2 changes: 1 addition & 1 deletion src/fsevent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ impl FsEventWatcher {
// channel to pass runloop around
let (rl_tx, rl_rx) = unbounded();

let thread_handle = thread::spawn(move || {
let thread_handle = thread::Builder::new().name("notify-rs fsevents".to_string()).spawn(move || {
let stream = stream.0;

unsafe {
Expand Down
4 changes: 2 additions & 2 deletions src/inotify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl EventLoop {

// Run the event loop.
pub fn run(self) {
thread::spawn(|| self.event_loop_thread());
thread::Builder::new().name("notify-rs inotify".to_string()).spawn(|| self.event_loop_thread());
}

fn event_loop_thread(mut self) {
Expand Down Expand Up @@ -418,7 +418,7 @@ impl EventLoop {
let event_loop_tx = self.event_loop_tx.clone();
let waker = self.event_loop_waker.clone();
let cookie = rename_event.tracker().unwrap(); // unwrap is safe because rename_event is always set with some cookie
thread::spawn(move || {
thread::Builder::new().name("notify-rs inotify rename".to_string()).spawn(move || {
thread::sleep(Duration::from_millis(10)); // wait up to 10 ms for a subsequent event

// An error here means the other end of the channel was closed, a thing that can
Expand Down
2 changes: 1 addition & 1 deletion src/kqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl EventLoop {

// Run the event loop.
pub fn run(self) {
thread::spawn(|| self.event_loop_thread());
thread::Builder::new().name("notify-rs kqueue".to_string()).spawn(|| self.event_loop_thread());
}

fn event_loop_thread(mut self) {
Expand Down
2 changes: 1 addition & 1 deletion src/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl PollWatcher {
let event_handler = self.event_handler.clone();
let event_handler = move |res| emit_event(&event_handler, res);

thread::spawn(move || {
thread::Builder::new().name("notify-rs poll".to_string()).spawn(move || {
// In order of priority:
// TODO: handle metadata events
// TODO: handle renames
Expand Down
2 changes: 1 addition & 1 deletion src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl ReadDirectoryChangesServer {
let (action_tx, action_rx) = unbounded();
// it is, in fact, ok to send the semaphore across threads
let sem_temp = wakeup_sem as u64;
thread::spawn(move || {
thread::Builder::new().name("notify-rs windows".to_string()).spawn(move || {
let wakeup_sem = sem_temp as HANDLE;
let server = ReadDirectoryChangesServer {
rx: action_rx,
Expand Down
2 changes: 1 addition & 1 deletion tests/race-with-remove-dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn test_race_with_remove_dir() {

{
let tmpdir = tmpdir.path().to_path_buf();
thread::spawn(move || {
thread::Builder::new().name("notify-rs test-race-with-remove-dir".to_string()).spawn(move || {
let mut watcher = notify::recommended_watcher(move |result| {
eprintln!("received event: {:?}", result);
})
Expand Down