Skip to content

Commit

Permalink
main: add re_nfds() and poll_method_get() getters (#435)
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers authored Jul 15, 2022
1 parent 02ccfb7 commit 074e51a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/re_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void libre_close(void);
int re_main(re_signal_h *signalh);
void re_cancel(void);
int re_debug(struct re_printf *pf, void *unused);
int re_nfds(void);

int re_alloc(struct re **rep);
int re_thread_attach(struct re *re);
Expand All @@ -70,6 +71,7 @@ enum poll_method {
};

int poll_method_set(enum poll_method method);
enum poll_method poll_method_get(void);
enum poll_method poll_method_best(void);
const char *poll_method_name(enum poll_method method);
int poll_method_type(enum poll_method *method, const struct pl *name);
26 changes: 26 additions & 0 deletions src/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,32 @@ int re_debug(struct re_printf *pf, void *unused)
}


/**
* Get number of active file descriptors
*
* @return nfds
*/
int re_nfds(void)
{
struct re *re = re_get();

return re ? re->nfds : 0;
}


/**
* Get current async I/O polling method.
*
* @return enum poll_method
*/
enum poll_method poll_method_get(void)
{
struct re *re = re_get();

return re ? re->method : METHOD_NULL;
}


/**
* Set async I/O polling method. This function can also be called while the
* program is running.
Expand Down

0 comments on commit 074e51a

Please sign in to comment.