static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data) { GMainLoop *loop = (GMainLoop *) data; switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_APPLICATION: { const GstStructure * msg_struct = gst_message_get_structure(msg); guint64 duration = 0; guint64 timestamp = 0; int stream_thread_id = 0; g_debug("APPLICATION CUSTOM MESSAGE !!!"); g_debug("MESSAGE THREAD ID[%p]", g_thread_self()); gst_structure_get_clock_time (msg_struct, "duration" , &duration); gst_structure_get_clock_time (msg_struct, "timestamp" , ×tamp); gst_structure_get_int (msg_struct, "stream_thread_id" , &stream_thread_id); g_debug("STREAM THREAD ID[0x%x]", stream_thread_id); g_debug("DURATION[%llu], TIMESTAMP[%llu]", duration, timestamp); g_debug("Testing string message, [%s]\n", gst_structure_get_string(msg_struct, "msg")); break; } case GST_MESSAGE_EOS: { g_print ("End of stream\n"); g_main_loop_quit (loop); break; } case GST_MESSAGE_ERROR: { gchar *debug; GError *error; gst_message_parse_error (msg, &error, &debug); g_free (debug); g_printerr ("Error: %s\n", error->message); g_error_free (error); g_main_loop_quit (loop); break; } default: g_print("Msg type [%d], Msg name [%s]\n", GST_MESSAGE_TYPE (msg), GST_MESSAGE_TYPE_NAME(msg)); break; } return TRUE; }
static gpointer test3_worker_func (Data3 *data, G_GNUC_UNUSED GError **error) { gint *retval; g_print ("%s() called from thread %p\n", __FUNCTION__, g_thread_self()); g_usleep (500000); /* short delay */ retval = g_new0 (gint, 1); *retval = data->counter + 1; return retval; }
/* function called back in the context which submitted the jobs */ static void test9_worker_cb (G_GNUC_UNUSED GdaWorker *worker, G_GNUC_UNUSED guint job_id, Test9Data *data, G_GNUC_UNUSED GError *error, GThread *thread) { g_print ("%s (thread => %p, result_data => %p)\n", __FUNCTION__, g_thread_self(), data); if (thread != g_thread_self()) { g_print ("callback from gda_worker_set_callback() called in thread %p, expected in thread %p\n", g_thread_self(), thread); exit (1); } else if (data->in != data->out) { g_print ("Expected data->out[%u] to be equal to data->in[%u]\n", data->out, data->in); exit (1); } if (data->loop) g_main_loop_quit (data->loop); g_free (data); }
static VipsBufferCacheList * buffer_cache_list_new( VipsBufferCache *cache, VipsImage *im ) { VipsBufferCacheList *cache_list; cache_list = g_new( VipsBufferCacheList, 1 ); cache_list->buffers = NULL; cache_list->thread = g_thread_self(); cache_list->cache = cache; cache_list->im = im; #ifdef DEBUG_CREATE printf( "buffer_cache_list_new: new cache %p for thread %p\n", cache, g_thread_self() ); printf( "\t(%d cachees now)\n", buffer_cache_n ); #endif /*DEBUG_CREATE*/ return( cache_list ); }
/* Helper thread to create a SCTP association that will use this DTLS stack */ void *janus_dtls_sctp_setup_thread(void *data) { if(data == NULL) { JANUS_LOG(LOG_ERR, "No DTLS stack??\n"); g_thread_unref(g_thread_self()); return NULL; } janus_dtls_srtp *dtls = (janus_dtls_srtp *)data; if(dtls->sctp == NULL) { JANUS_LOG(LOG_ERR, "No SCTP stack??\n"); g_thread_unref(g_thread_self()); return NULL; } janus_sctp_association *sctp = (janus_sctp_association *)dtls->sctp; /* Do the accept/connect stuff now */ JANUS_LOG(LOG_VERB, "[%"SCNu64"] Started thread: setup of the SCTP association\n", sctp->handle_id); janus_sctp_association_setup(sctp); g_thread_unref(g_thread_self()); return NULL; }
static void success_cb (GstInsertBin * insertbin, GstElement * element, gboolean success, gpointer user_data) { fail_unless (g_thread_self () != push_thread); fail_unless (success == TRUE); fail_unless (GST_IS_ELEMENT (insertbin)); fail_unless (GST_IS_ELEMENT (element)); cb_count++; }
static gboolean gst_gl_wrapped_context_activate (GstGLContext * context, gboolean activate) { if (activate) context->priv->gl_thread = g_thread_self (); else context->priv->gl_thread = NULL; return TRUE; }
void vips__region_check_ownership( VipsRegion *region ) { if( region->thread ) { g_assert( region->thread == g_thread_self() ); if( region->buffer && region->buffer->cache ) g_assert( region->thread == region->buffer->cache->thread ); } }
void vfs_file_task_abort ( VFSFileTask* task ) { task->state = VFS_FILE_TASK_ABORTED; /* Called from another thread */ if ( g_thread_self() != task->thread ) { g_thread_join( task->thread ); task->thread = NULL; } }
/** * Release the IO lock */ void rs_io_unlock_real(const gchar *source_file, gint line, const gchar *caller) { RS_DEBUG(LOCKING, "[%s:%d %s()] releasing IO lock after \033[36m%.2f\033[0mms (thread %p)", source_file, line, caller, g_timer_elapsed(io_lock_timer, NULL)*1000.0, g_thread_self()); g_static_rec_mutex_unlock(&io_lock); }
static double do_profile_run (const ProfileRunVTable *vtable) { GTimer *timer; int i; double secs; ServerData sd; void *server; g_printerr ("Profiling %s\n", vtable->name); sd.handled = 0; sd.n_clients = 0; sd.loop = g_main_loop_new (NULL, FALSE); sd.vtable = vtable; server = (* vtable->init_server) (&sd); for (i = 0; i < N_CLIENT_THREADS; i++) { g_thread_create (vtable->client_thread_func, (void*) vtable, FALSE, NULL); } timer = g_timer_new (); g_printerr ("Server thread %p entering main loop\n", g_thread_self()); (* vtable->main_loop_run_func) (sd.loop); g_printerr ("Server thread %p exiting main loop\n", g_thread_self()); secs = g_timer_elapsed (timer, NULL); g_timer_destroy (timer); g_printerr ("%s: %g seconds, %d round trips, %f seconds per pingpong\n", vtable->name, secs, sd.handled, secs/sd.handled); (* vtable->stop_server) (&sd, server); g_main_loop_unref (sd.loop); return secs; }
static gpointer tracker_controller_thread_func (gpointer user_data) { TrackerController *controller; TrackerControllerPrivate *priv; GError *error = NULL; #ifdef THREAD_ENABLE_TRACE g_debug ("Thread:%p (Controller) --- Created, dispatching...", g_thread_self ()); #endif /* THREAD_ENABLE_TRACE */ controller = user_data; priv = controller->priv; g_main_context_push_thread_default (priv->context); reset_shutdown_timeout (controller); if (!tracker_controller_dbus_start (controller, &error)) { /* Error has been filled in, so we return * in this thread. The main thread will be * notified about the error and exit. */ controller_notify_main_thread (controller, error); return NULL; } g_main_loop_run (priv->main_loop); #ifdef THREAD_ENABLE_TRACE g_debug ("Thread:%p (Controller) --- Shutting down...", g_thread_self ()); #endif /* THREAD_ENABLE_TRACE */ g_object_unref (controller); /* This is where we exit, be it * either through umount events on monitored * files' volumes or the timeout being reached */ exit (0); return NULL; }
static void check_log_handler (const gchar * const log_domain, const GLogLevelFlags log_level, const gchar * const message, gpointer const user_data) { gchar *msg, *level; GstClockTime elapsed; //-- check message contents if (__check_method && (strstr (message, __check_method) != NULL) && __check_test && (strstr (message, __check_test) != NULL)) __check_error_trapped = TRUE; else if (__check_method && (strstr (message, __check_method) != NULL) && !__check_test) __check_error_trapped = TRUE; else if (__check_test && (strstr (message, __check_test) != NULL) && !__check_method) __check_error_trapped = TRUE; //-- format switch (log_level & G_LOG_LEVEL_MASK) { case G_LOG_LEVEL_ERROR: level = "ERROR"; break; case G_LOG_LEVEL_CRITICAL: level = "CRITICAL"; break; case G_LOG_LEVEL_WARNING: level = "WARNING"; break; case G_LOG_LEVEL_MESSAGE: level = "MESSAGE"; break; case G_LOG_LEVEL_INFO: level = "INFO"; break; case G_LOG_LEVEL_DEBUG: level = "DEBUG"; break; default: level = "???"; break; } elapsed = GST_CLOCK_DIFF (_priv_bt_info_start_time, gst_util_get_timestamp ()); msg = g_alloca (85 + strlen (level) + (log_domain ? strlen (log_domain) : 0) + (message ? strlen (message) : 0)); g_sprintf (msg, "%" GST_TIME_FORMAT " %" PID_FMT " %" PTR_FMT " %-7s %20s ::: %s", GST_TIME_ARGS (elapsed), getpid (), g_thread_self (), level, (log_domain ? log_domain : ""), (message ? message : "")); check_print_handler (msg); }
static void test5_worker_callback (G_GNUC_UNUSED GdaWorker *worker, guint job_id, G_GNUC_UNUSED gpointer result_data, G_GNUC_UNUSED GError *error, GMainLoop *loop) { static guint i = 0; i++; g_print ("test5_worker_callback called for job %u\n", job_id); if (i == 5) { g_print ("Requesting loop quit, from thread %p\n", g_thread_self ()); g_main_loop_quit (loop); } }
static void do_element_query_pre (GstStatsTracer * self, guint64 ts, GstElement * elem, GstQuery * qry) { GstElementStats *stats = get_element_stats (self, elem); stats->last_ts = ts; gst_tracer_record_log (tr_element_query, (guint64) (guintptr) g_thread_self (), ts, stats->index, GST_QUERY_TYPE_NAME (qry)); }
static im_buffer_cache_list_t * buffer_cache_list_new( im_buffer_cache_t *cache, IMAGE *im ) { im_buffer_cache_list_t *cache_list; if( !(cache_list = IM_NEW( NULL, im_buffer_cache_list_t )) ) return( NULL ); cache_list->buffers = NULL; cache_list->thread = g_thread_self(); cache_list->cache = cache; cache_list->im = im; #ifdef DEBUG_CREATE printf( "buffer_cache_list_new: new cache %p for thread %p\n", cache, g_thread_self() ); printf( "\t(%d cachees now)\n", buffer_cache_n ); #endif /*DEBUG_CREATE*/ return( cache_list ); }
static VipsBufferCache * buffer_cache_new( void ) { VipsBufferCache *cache; cache = g_new( VipsBufferCache, 1 ); cache->hash = g_hash_table_new_full( g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) buffer_cache_list_free ); cache->thread = g_thread_self(); #ifdef DEBUG_CREATE buffer_cache_n += 1; printf( "buffer_cache_new: new cache %p for thread %p\n", cache, g_thread_self() ); printf( "\t(%d cachees now)\n", buffer_cache_n ); #endif /*DEBUG_CREATE*/ return( cache ); }
static void ephy_history_service_close_database_connections (EphyHistoryService *self) { EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv; g_assert (priv->history_thread == g_thread_self ()); ephy_sqlite_connection_close (priv->history_database); g_object_unref (priv->history_database); priv->history_database = NULL; }
static void do_push_event_pre (GstStatsTracer * self, guint64 ts, GstPad * pad, GstEvent * ev) { GstElement *elem = get_real_pad_parent (pad); GstElementStats *elem_stats = get_element_stats (self, elem); GstPadStats *pad_stats = get_pad_stats (self, pad); elem_stats->last_ts = ts; gst_tracer_record_log (tr_event, (guint64) (guintptr) g_thread_self (), ts, pad_stats->index, elem_stats->index, GST_EVENT_TYPE_NAME (ev)); }
static void get_field(struct FieldRequest *request) { if (g_thread_self() == main_thread) get_field_cb(request); else { g_mutex_lock(info_mutex); g_timeout_add(0, get_field_cb, request); g_cond_wait(info_cond, info_mutex); g_mutex_unlock(info_mutex); } }
static void get_mpris_metadata(struct MprisMetadataRequest *request) { if (g_thread_self() == main_thread) get_mpris_metadata_cb(request); else { g_mutex_lock(info_mutex); g_timeout_add(0, get_mpris_metadata_cb, request); g_cond_wait(info_cond, info_mutex); g_mutex_unlock(info_mutex); } }
void pragha_process_gtk_events () { #ifdef DEBUG extern GThread *pragha_main_thread; if (g_thread_self () != pragha_main_thread) g_warning ("THREAD SAFETY ERROR!"); #endif while (g_main_context_pending (NULL)) { g_main_context_iteration (NULL, FALSE); } }
static int png2vips_generate( VipsRegion *or, void *seq, void *a, void *b, gboolean *stop ) { VipsRect *r = &or->valid; Read *read = (Read *) a; int y; #ifdef DEBUG printf( "png2vips_generate: line %d, %d rows\n", r->top, r->height ); #endif /*DEBUG*/ /* We're inside a tilecache where tiles are the full image width, so * this should always be true. */ g_assert( r->left == 0 ); g_assert( r->width == or->im->Xsize ); g_assert( VIPS_RECT_BOTTOM( r ) <= or->im->Ysize ); /* Tiles should always be a strip in height, unless it's the final * strip. */ g_assert( r->height == VIPS_MIN( 8, or->im->Ysize - r->top ) ); /* And check that y_pos is correct. It should be, since we are inside * a vips_sequential(). */ g_assert( r->top == read->y_pos ); for( y = 0; y < r->height; y++ ) { png_bytep q = (png_bytep) VIPS_REGION_ADDR( or, 0, r->top + y ); /* We need to catch and ignore errors from read_row(). */ if( !setjmp( png_jmpbuf( read->pPng ) ) ) png_read_row( read->pPng, q, NULL ); else { #ifdef DEBUG printf( "png2vips_generate: png_read_row() failed, " "line %d\n", r->top + y ); printf( "png2vips_generate: file %s\n", read->name ); printf( "png2vips_generate: thread %p\n", g_thread_self() ); #endif /*DEBUG*/ } read->y_pos += 1; } return( 0 ); }
/** * g_thread_exit: * @retval: the return value of this thread * * Terminates the current thread. * * If another thread is waiting for us using g_thread_join() then the * waiting thread will be woken up and get @retval as the return value * of g_thread_join(). * * Calling <literal>g_thread_exit (retval)</literal> is equivalent to * returning @retval from the function @func, as given to g_thread_new(). * * <note><para> * You must only call g_thread_exit() from a thread that you created * yourself with g_thread_new() or related APIs. You must not call * this function from a thread created with another threading library * or or from within a #GThreadPool. * </para></note> */ void g_thread_exit (gpointer retval) { GRealThread* real = (GRealThread*) g_thread_self (); if G_UNLIKELY (!real->ours) g_error ("attempt to g_thread_exit() a thread not created by GLib"); real->retval = retval; g_system_thread_exit (); }
/* * Initialization functions */ void xs_reinit(void) { XSDEBUG("xs_reinit() thread = %p\n", g_thread_self()); XS_MUTEX_LOCK(xs_status); XS_MUTEX_LOCK(xs_cfg); /* Initialize status and sanitize configuration */ memset(&xs_status, 0, sizeof(xs_status)); if (xs_cfg.audioFrequency < 8000) xs_cfg.audioFrequency = 8000; if (xs_cfg.oversampleFactor < XS_MIN_OVERSAMPLE) xs_cfg.oversampleFactor = XS_MIN_OVERSAMPLE; else if (xs_cfg.oversampleFactor > XS_MAX_OVERSAMPLE) xs_cfg.oversampleFactor = XS_MAX_OVERSAMPLE; if (xs_cfg.audioChannels != XS_CHN_MONO) xs_cfg.oversampleEnable = FALSE; xs_status.audioFrequency = xs_cfg.audioFrequency; xs_status.audioBitsPerSample = xs_cfg.audioBitsPerSample; xs_status.audioChannels = xs_cfg.audioChannels; xs_status.audioFormat = -1; xs_status.oversampleEnable = xs_cfg.oversampleEnable; xs_status.oversampleFactor = xs_cfg.oversampleFactor; /* Try to initialize emulator engine */ xs_init_emu_engine(&xs_cfg.playerEngine, &xs_status); /* Get settings back, in case the chosen emulator backend changed them */ xs_cfg.audioFrequency = xs_status.audioFrequency; xs_cfg.audioBitsPerSample = xs_status.audioBitsPerSample; xs_cfg.audioChannels = xs_status.audioChannels; xs_cfg.oversampleEnable = xs_status.oversampleEnable; XS_MUTEX_UNLOCK(xs_status); XS_MUTEX_UNLOCK(xs_cfg); /* Initialize song-length database */ xs_songlen_close(); if (xs_cfg.songlenDBEnable && (xs_songlen_init() != 0)) { xs_error("Error initializing song-length database!\n"); } /* Initialize STIL database */ xs_stil_close(); if (xs_cfg.stilDBEnable && (xs_stil_init() != 0)) { xs_error("Error initializing STIL database!\n"); } }
static void _rb_debug_print (const char *func, const char *file, const int line, gboolean newline, const char *buffer) { char str_time[255]; time_t the_time; time (&the_time); strftime (str_time, 254, "%H:%M:%S", localtime (&the_time)); g_printerr (newline ? "(%s) [%p] [%s] %s:%d: %s\n" : "(%s) [%p] [%s] %s:%d: %s", str_time, g_thread_self (), func, file, line, buffer); }
int test3 (void) { g_print ("Test3 started, main thread is %p\n", g_thread_self ()); GdaWorker *worker; gint nfailed = 0; worker = gda_worker_new (); guint jid; GError *error = NULL; Data3 *data; data = g_new (Data3, 1); data->counter = 5; jid = gda_worker_submit_job (worker, NULL, (GdaWorkerFunc) test3_worker_func, data, (GDestroyNotify) data3_free, NULL, &error); if (jid == 0) { g_print ("Error in gda_worker_submit_job(): %s\n", error && error->message ? error->message : "no detail"); g_clear_error (&error); nfailed++; goto out; } while (1) { gint *result; if (! gda_worker_fetch_job_result (worker, jid, (gpointer*) &result, &error)) { g_print ("Still not done, error: %s\n", error && error->message ? error->message : "no detail"); if ((error->domain == GDA_WORKER_ERROR) && (error->code == GDA_WORKER_JOB_NOT_FOUND_ERROR)) { nfailed++; g_clear_error (&error); break; } g_clear_error (&error); } else { if (result) { g_print ("Got result value: %d\n", *result); g_free (result); } else { g_print ("Error: got no result value!\n"); nfailed++; } break; } g_usleep (100000); } out: gda_worker_unref (worker); return nfailed; }
static im_buffer_cache_t * buffer_cache_new( void ) { im_buffer_cache_t *cache; if( !(cache = IM_NEW( NULL, im_buffer_cache_t )) ) return( NULL ); cache->hash = g_hash_table_new_full( g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) buffer_cache_list_free ); cache->thread = g_thread_self(); #ifdef DEBUG_CREATE buffer_cache_n += 1; printf( "buffer_cache_new: new cache %p for thread %p\n", cache, g_thread_self() ); printf( "\t(%d cachees now)\n", buffer_cache_n ); #endif /*DEBUG_CREATE*/ return( cache ); }
/******************************** * Entity_RebuildAll_Thread * */ void Entity_RebuildAll_Thread( ProgressDialogWidgets * wids ) { Logger_SetQueue( wids->queue ); // redirects a Logger_* to pass messages Entity_ExtractRoutines(); Meg_enumerateFilesCallback("/scripts/maps/", EntityCompiler_RebuildForEach, NULL); Meg_enumerateFilesCallback("/scripts/", EntityCompiler_RebuildForEach, NULL); Logger_SetQueue( NULL ); // resets logger g_async_queue_push( wids->queue, g_thread_self() ); // closes thread. Also tells the watch that the dialog can close. }
static VipsBufferThread * buffer_thread_new( void ) { VipsBufferThread *buffer_thread; buffer_thread = g_new( VipsBufferThread, 1 ); buffer_thread->hash = g_hash_table_new_full( g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) buffer_cache_free ); buffer_thread->thread = g_thread_self(); return( buffer_thread ); }