Merge branch 'ab/progress-cleanup' into seen
[git] / compat / fsmonitor / fsmonitor-fs-listen.h
1 #ifndef FSMONITOR_FS_LISTEN_H
2 #define FSMONITOR_FS_LISTEN_H
3
4 /* This needs to be implemented by each backend */
5
6 #ifdef HAVE_FSMONITOR_DAEMON_BACKEND
7
8 struct fsmonitor_daemon_state;
9
10 /*
11  * Initialize platform-specific data for the fsmonitor listener thread.
12  * This will be called from the main thread PRIOR to staring the
13  * fsmonitor_fs_listener thread.
14  *
15  * Returns 0 if successful.
16  * Returns -1 otherwise.
17  */
18 int fsmonitor_fs_listen__ctor(struct fsmonitor_daemon_state *state);
19
20 /*
21  * Cleanup platform-specific data for the fsmonitor listener thread.
22  * This will be called from the main thread AFTER joining the listener.
23  */
24 void fsmonitor_fs_listen__dtor(struct fsmonitor_daemon_state *state);
25
26 /*
27  * The main body of the platform-specific event loop to watch for
28  * filesystem events.  This will run in the fsmonitor_fs_listen thread.
29  *
30  * It should call `ipc_server_stop_async()` if the listener thread
31  * prematurely terminates (because of a filesystem error or if it
32  * detects that the .git directory has been deleted).  (It should NOT
33  * do so if the listener thread receives a normal shutdown signal from
34  * the IPC layer.)
35  *
36  * It should set `state->error_code` to -1 if the daemon should exit
37  * with an error.
38  */
39 void fsmonitor_fs_listen__loop(struct fsmonitor_daemon_state *state);
40
41 /*
42  * Gently request that the fsmonitor listener thread shutdown.
43  * It does not wait for it to stop.  The caller should do a JOIN
44  * to wait for it.
45  */
46 void fsmonitor_fs_listen__stop_async(struct fsmonitor_daemon_state *state);
47
48 #endif /* HAVE_FSMONITOR_DAEMON_BACKEND */
49 #endif /* FSMONITOR_FS_LISTEN_H */