aboutsummaryrefslogtreecommitdiff
path: root/src/pth.c
blob: d82a46577425d16c1ccbc4768accfb3d7e1bd911 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <errno.h>

#include "util_rt.h"
#include "pth.h"


void prne_init_worker (prne_worker_t *w) {
	w->ctx = NULL;
	w->entry = NULL;
	w->fin = NULL;
	w->free_ctx = NULL;
	w->pth = NULL;
}

void prne_free_worker (prne_worker_t *w) {
	if (w->ctx != NULL) {
		prne_assert(w->free_ctx != NULL);
		w->free_ctx(w->ctx);
		w->ctx = NULL;
	}
}

void prne_fin_worker (prne_worker_t *w) {
	if (w->fin != NULL) {
		w->fin(w->ctx);
	}
}

void prne_pth_cv_notify (pth_mutex_t *lock, pth_cond_t *cond, bool broadcast) {
	prne_dbgtrap(pth_mutex_acquire(lock, FALSE, NULL));
	prne_dbgtrap(pth_cond_notify(cond, broadcast));
	pth_mutex_release(lock);
}

pth_time_t prne_pth_tstimeout (const struct timespec ts) {
	return pth_timeout(ts.tv_sec, ts.tv_nsec / 1000);
}