summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2018-05-13 23:35:07 -0700
committerVito Caputo <vcaputo@pengaru.com>2018-05-13 23:35:07 -0700
commit149643c5638f39ba03a49b8483921ce53c643a4d (patch)
tree4834c0bbdc5e64676df12cf29a91e52fdd2909a4 /src
parentfda0975cb75f439e74231b68afdc76ee754ae7ca (diff)
libpulp: add pulp_self() current fiber accessor
Analogous to pthread_self()
Diffstat (limited to 'src')
-rw-r--r--src/pulp.c7
-rw-r--r--src/pulp.h1
2 files changed, 8 insertions, 0 deletions
diff --git a/src/pulp.c b/src/pulp.c
index 179451e..4166dc5 100644
--- a/src/pulp.c
+++ b/src/pulp.c
@@ -401,6 +401,13 @@ pulp_fiber_t * pulp_fiber_new(pulp_t *pulp, unsigned delay_ms, thunk_t *thunk)
}
+/* return the current fiber */
+pulp_fiber_t * pulp_self(pulp_t *pulp)
+{
+ return pulp->current;
+}
+
+
/* sleep for the supplied number of microseconds (not public) */
static void pulp_usleep(pulp_t *pulp, unsigned useconds)
{
diff --git a/src/pulp.h b/src/pulp.h
index b90b913..6111c80 100644
--- a/src/pulp.h
+++ b/src/pulp.h
@@ -32,5 +32,6 @@ pulp_fiber_t * pulp_fiber_new(pulp_t *pulp, unsigned delay_ms, thunk_t *thunk);
void pulp_msleep(pulp_t *pulp, unsigned milliseconds);
void pulp_sleep(pulp_t *pulp, unsigned seconds);
pulp_usec_t pulp_now(pulp_t *pulp);
+pulp_fiber_t * pulp_self(pulp_t *pulp);
#endif
© All Rights Reserved