Modify chopstx_poll API

This commit is contained in:
NIIBE Yutaka
2016-04-22 13:42:01 +09:00
parent 5d40ffbffa
commit 1b12a78054
6 changed files with 154 additions and 81 deletions

View File

@@ -135,20 +135,30 @@ void chopstx_cleanup_pop (int execute);
void chopstx_wakeup_usec_wait (chopstx_t thd);
#define CHOPSTX_THREAD_SIZE 64
enum {
CHOPSTX_POLL_COND = 0,
CHOPSTX_POLL_JOIN,
};
/* Proxy for the thread. */
typedef struct chx_px chopstx_px_t;
struct chx_poll_cond {
chopstx_cond_t *cond;
chopstx_mutex_t *mutex;
int (*check) (void *);
void *arg;
};
/* Like chopstx_cond_wait. Not to wait, but to register for notification. */
void chopstx_cond_hook (chopstx_px_t *px, chopstx_cond_t *cond,
chopstx_mutex_t *mutex, int (*func) (void *),
void *arg);
void chopstx_cond_unhook (chopstx_px_t *px, chopstx_cond_t *cond);
struct chx_poll_join {
chopstx_t thd;
};
/* Like chopstx_join. Not to wait for the termination, but to register. */
void chopstx_join_hook (chopstx_px_t *px, chopstx_t thd);
void chopstx_join_unhook (chopstx_px_t *px, chopstx_t thd);
struct chx_poll_desc {
int type;
union {
struct chx_poll_cond c;
struct chx_poll_join j;
};
};
typedef void (*chopstx_poll_fnc) (int reg_or_unreg, chopstx_px_t *px);
int chopstx_poll (uint32_t *usec_p, int n, ...);
#define CHOPSTX_THREAD_SIZE 64