Never destroy the current cothread.

Original commit message from CVS:
Never destroy the current cothread.
Don't try to signal the scheduler if we don't have one
This commit is contained in:
Wim Taymans 2001-12-22 23:19:17 +00:00
parent 6cdaf3fa84
commit 467035ce70
4 changed files with 33 additions and 16 deletions

View file

@ -162,7 +162,8 @@ cothread_create (cothread_context *ctx)
for (slot = 1; slot < ctx->nthreads; slot++) { for (slot = 1; slot < ctx->nthreads; slot++) {
if (ctx->threads[slot] == NULL) if (ctx->threads[slot] == NULL)
break; break;
else if (ctx->threads[slot]->flags & COTHREAD_DESTROYED) { else if (ctx->threads[slot]->flags & COTHREAD_DESTROYED &&
slot != ctx->current) {
cothread_destroy (ctx->threads[slot]); cothread_destroy (ctx->threads[slot]);
break; break;
} }
@ -217,7 +218,7 @@ cothread_free (cothread_state *thread)
{ {
g_return_if_fail (thread != NULL); g_return_if_fail (thread != NULL);
GST_INFO (GST_CAT_COTHREADS, "flag cothread for destruction"); GST_INFO (GST_CAT_COTHREADS, "flag cothread %d for destruction", thread->threadnum);
/* we simply flag the cothread for destruction here */ /* we simply flag the cothread for destruction here */
thread->flags |= COTHREAD_DESTROYED; thread->flags |= COTHREAD_DESTROYED;
@ -230,10 +231,11 @@ cothread_destroy (cothread_state *thread)
g_return_if_fail (thread != NULL); g_return_if_fail (thread != NULL);
GST_INFO (GST_CAT_COTHREADS, "destroy cothread"); GST_INFO (GST_CAT_COTHREADS, "destroy cothread %d %p %p", thread->threadnum, thread, ctx->current);
ctx = thread->ctx; ctx = thread->ctx;
#ifndef COTHREAD_ATOMIC #ifndef COTHREAD_ATOMIC
g_mutex_unlock (thread->lock);
g_mutex_free (thread->lock); g_mutex_free (thread->lock);
#endif #endif
//munmap ((void *) thread, COTHREAD_STACKSIZE); //munmap ((void *) thread, COTHREAD_STACKSIZE);

View file

@ -1282,6 +1282,22 @@ gst_element_restore_thyself (xmlNodePtr self, GstObject *parent)
} }
#endif /* GST_DISABLE_LOADSAVE */ #endif /* GST_DISABLE_LOADSAVE */
void
gst_element_yield (GstElement *element)
{
if (GST_ELEMENT_SCHED (element)) {
gst_scheduler_yield (GST_ELEMENT_SCHED (element), element);
}
}
void
gst_element_interrupt (GstElement *element)
{
if (GST_ELEMENT_SCHED (element)) {
gst_scheduler_interrupt (GST_ELEMENT_SCHED (element), element);
}
}
/** /**
* gst_element_set_sched: * gst_element_set_sched:
* @element: Element to set manager of. * @element: Element to set manager of.

View file

@ -183,8 +183,8 @@ const gchar* gst_element_get_name (GstElement *element);
void gst_element_set_parent (GstElement *element, GstObject *parent); void gst_element_set_parent (GstElement *element, GstObject *parent);
GstObject* gst_element_get_parent (GstElement *element); GstObject* gst_element_get_parent (GstElement *element);
#define gst_element_yield(element) gst_scheduler_yield(GST_ELEMENT_SCHED(element),element) void gst_element_yield (GstElement *element);
#define gst_element_interrupt(element) gst_scheduler_interrupt(GST_ELEMENT_SCHED(element),element) void gst_element_interrupt (GstElement *element);
void gst_element_set_sched (GstElement *element, GstScheduler *sched); void gst_element_set_sched (GstElement *element, GstScheduler *sched);
GstScheduler* gst_element_get_sched (GstElement *element); GstScheduler* gst_element_get_sched (GstElement *element);

View file

@ -189,21 +189,20 @@ gst_typefind_chain (GstPad *pad, GstBuffer *buf)
gst_pad_set_caps (pad, caps); gst_pad_set_caps (pad, caps);
{ /* FIXME: this should all be in an _emit() wrapper eventually */ {
int oldstate = GST_STATE(typefind); int oldstate = GST_STATE(typefind);
gst_object_ref (GST_OBJECT (typefind)); gst_object_ref (GST_OBJECT (typefind));
g_signal_emit (G_OBJECT (typefind), gst_typefind_signals[HAVE_TYPE], 0, g_signal_emit (G_OBJECT (typefind), gst_typefind_signals[HAVE_TYPE], 0,
typefind->caps); typefind->caps);
if (GST_STATE(typefind) != oldstate) { if (GST_STATE(typefind) != oldstate) {
gst_object_unref (GST_OBJECT (typefind));
GST_DEBUG(0, "state changed during signal, aborting\n"); GST_DEBUG(0, "state changed during signal, aborting\n");
gst_element_yield (typefind); gst_element_yield (GST_ELEMENT (typefind));
} }
gst_object_unref (GST_OBJECT (typefind)); gst_object_unref (GST_OBJECT (typefind));
}
goto end; goto end;
} }
}
factories = g_slist_next (factories); factories = g_slist_next (factories);
} }