cothread_state*
cothread_main(cothread_context *ctx)
{
- DEBUG(stderr,"returning %p, the 0th cothread\n",ctx->threads[0]);
+ DEBUG("returning %p, the 0th cothread\n",ctx->threads[0]);
return ctx->threads[0];
}
thread->pc = 0;
thread->sp = thread->top_sp;
DEBUG("cothread: cothread_stub() exit\n");
- //printf("uh, yeah, we shouldn't be here, but we should deal anyway\n");
+// printf("uh, yeah, we shouldn't be here, but we should deal anyway\n");
+}
+
+/**
+ * cothread_getcurrent:
+ *
+ * Returns: the current cothread id
+ */
+int cothread_getcurrent(void) {
+ cothread_context *ctx = pthread_getspecific(_cothread_key);
+ if (!ctx) return -1;
+ return ctx->current;
}
/**
cothread_state* cothread_create (cothread_context *ctx);
void cothread_setfunc (cothread_state *thread, cothread_func func,
int argc, char **argv);
+int cothread_getcurrent (void);
void cothread_switch (cothread_state *thread);
void cothread_set_data (cothread_state *thread, gchar *key, gpointer data);
gpointer cothread_get_data (cothread_state *thread, gchar *key);
#include <gst/gsttee.h>
+#include <gst/cothreads.h>
+
/* initialize GST */
void gst_init(int *argc,char **argv[]);
/* debugging */
#ifndef DEBUG
#ifdef DEBUG_ENABLED
-#define DEBUG(format, args...) g_print("DEBUG:(%d) " format, getpid() , ##args)
+#define DEBUG(format, args...) g_print("DEBUG:(%d:%d) " format, getpid() , cothread_getcurrent() , ##args)
#else
#define DEBUG(format, args...)
#endif