/*! \brief Enables the serial connection and starts up the reader thread */ G_MODULE_EXPORT void libreems_serial_enable(void) { GIOChannel *channel = NULL; Serial_Params *serial_params = NULL; GThread *thread = NULL; gint tmpi = 0; ENTER(); serial_params = (Serial_Params *)DATA_GET(global_data,"serial_params"); if ((!serial_params->open) || (!serial_params->fd)) { MTXDBG(CRITICAL,_("Serial port is NOT open, or filedescriptor is invalid!\n")); EXIT(); return; } DATA_SET(global_data,"serial_abort",GINT_TO_POINTER(FALSE)); #ifdef __WIN32__ thread = g_thread_new("Win32 Reader",win32_reader,GINT_TO_POINTER(serial_params->fd)); #else thread = g_thread_new("UNIX Reader",unix_reader,GINT_TO_POINTER(serial_params->fd)); #endif DATA_SET(global_data,"serial_thread_id",thread); EXIT(); return; }
static void gst_switch_server_run (GstSwitchServer * srv) { srv->main_loop = g_main_loop_new (NULL, TRUE); if (!gst_switch_server_prepare_composite (srv, DEFAULT_COMPOSE_MODE)) goto error_prepare; srv->video_acceptor = g_thread_new ("switch-server-video-acceptor", (GThreadFunc) gst_switch_server_video_acceptor, srv); srv->audio_acceptor = g_thread_new ("switch-server-audio-acceptor", (GThreadFunc) gst_switch_server_audio_acceptor, srv); srv->controller_thread = g_thread_new ("switch-server-controller", (GThreadFunc) gst_switch_server_controller, srv); gst_switch_server_prepare_bus_controller (srv); g_main_loop_run (srv->main_loop); g_thread_join (srv->video_acceptor); g_thread_join (srv->audio_acceptor); g_thread_join (srv->controller_thread); return; /* Errors Handling */ error_prepare: { ERROR ("error preparing server"); return; } }
void rtcdc_loop(struct rtcdc_peer_connection *peer) { if (peer == NULL) return; while (!peer->initialized) g_usleep(50000); GThread *thread_ice = g_thread_new("ICE thread", &ice_thread, peer); GThread *thread_sctp = g_thread_new("SCTP thread", &sctp_thread, peer); GThread *thread_startup = g_thread_new("Startup thread", &startup_thread, peer); struct ice_transport *ice = peer->transport->ice; g_main_loop_run(ice->loop); peer->exit_thread = TRUE; g_thread_join(thread_ice); g_thread_join(thread_sctp); g_thread_join(thread_startup); g_thread_unref(thread_ice); g_thread_unref(thread_sctp); g_thread_unref(thread_startup); }
void button44_treeview_fun(GtkWidget *window,gpointer *data)//创建容器的选择界面 { GtkWidget *dialog; static gint gtk_run=0; dialog=gtk_message_dialog_new(NULL,GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,GTK_MESSAGE_WARNING,GTK_BUTTONS_YES_NO,"是否使用系统默认的名字"); gtk_run=gtk_dialog_run (GTK_DIALOG(dialog)); if(gtk_run==GTK_RESPONSE_YES){ //system("sudo gnome-terminal -x bash -c \"sudo docker run -ti --name chen ubuntu /bin/bash\""); g_thread_new("docker_contains_create",docker_contains_create_func,dialog); g_thread_new ("clean",docker_tree_view_clean,dialog); gtk_widget_destroy (dialog); } else if(gtk_run==GTK_RESPONSE_NO) { printf("nnnn\n"); create_contians_view();//选择不是系统默认创建容器的界面 gtk_widget_destroy (dialog); } else{ gtk_widget_destroy (dialog); } }
void iopen_init(GtkWidget *window) { parent_window = window; GtkWidget *main_vbox = gtk_vbox_new(false, 0); iopen_buffer = buffer_create(); iopen_buffer->single_line = true; load_empty(iopen_buffer); iopen_editor = new_editor(iopen_buffer, true); buffer_set_onchange(iopen_buffer, iopen_buffer_onchange); config_set(&(iopen_buffer->config), CFG_AUTOWRAP, "0"); config_set(&(iopen_buffer->config), CFG_AUTOCOMPL_POPUP, "0"); iopen_editor->single_line_escape = &iopen_escape; iopen_editor->single_line_return = &iopen_enter; iopen_editor->single_line_other_keys = &iopen_other_keys; gtk_box_pack_start(GTK_BOX(main_vbox), GTK_WIDGET(iopen_editor), FALSE, FALSE, 0); results_list = gtk_list_store_new(4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_DOUBLE); gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(results_list), 3, GTK_SORT_ASCENDING); results_tree = gtk_tree_view_new(); crt = gtk_cell_renderer_text_new(); iopen_recoloring(); gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(results_tree), -1, "Show", crt, "markup", 0, NULL); gtk_tree_view_set_model(GTK_TREE_VIEW(results_tree), GTK_TREE_MODEL(results_list)); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(results_tree), FALSE); gtk_tree_view_set_search_column(GTK_TREE_VIEW(results_tree), 1); g_signal_connect(G_OBJECT(results_tree), "row-activated", G_CALLBACK(result_activated_callback), NULL); GtkWidget *results_scroll = gtk_scrolled_window_new(NULL, NULL); gtk_container_add(GTK_CONTAINER(results_scroll), results_tree); gtk_box_pack_start(GTK_BOX(main_vbox), frame_piece(TRUE), FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(main_vbox), results_scroll, TRUE, TRUE, 0); iopen_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_decorated(GTK_WINDOW(iopen_window), TRUE); gtk_window_set_default_size(GTK_WINDOW(iopen_window), 640, 480); g_signal_connect(G_OBJECT(iopen_window), "delete-event", G_CALLBACK(delete_callback), NULL); g_signal_connect(G_OBJECT(iopen_window), "map_event", G_CALLBACK(map_callback), NULL); gtk_container_add(GTK_CONTAINER(iopen_window), main_vbox); file_recursor_requests = g_async_queue_new(); tags_requests = g_async_queue_new(); buffers_requests = g_async_queue_new(); g_thread_new("iopen file recursion", iopen_recursor_thread, NULL); g_thread_new("tags iteration", iopen_tags_thread, NULL); g_thread_new("buffer iteration", iopen_buffer_thread, NULL); }
/** * Inits the main structure. * @note With sqlite version > 3.7.7 we should use URI filename. * @param opt : a filled options_t * structure that contains all options * by default, read into the file or selected in the command line. * @returns a main_struct_t * pointer to the main structure */ static main_struct_t *init_main_structure(options_t *opt) { main_struct_t *main_struct = NULL; gchar *db_uri = NULL; gchar *conn = NULL; if (opt != NULL) { print_debug(_("Please wait while initializing main structure...\n")); main_struct = (main_struct_t *) g_malloc0(sizeof(main_struct_t)); create_directory(opt->dircache); db_uri = g_build_filename(opt->dircache, opt->dbname , NULL); main_struct->database = open_database(db_uri); db_uri = free_variable(db_uri); main_struct->opt = opt; main_struct->hostname = g_get_host_name(); if (opt != NULL && opt->ip != NULL) { conn = make_connexion_string(opt->ip, opt->port); main_struct->comm = init_comm_struct(conn); main_struct->reconnected = init_comm_struct(conn); free_variable(conn); } else { /* This should never happen because we have default values */ main_struct->comm = NULL; } main_struct->signal_fd = start_signals(); main_struct->fanotify_fd = start_fanotify(opt); /* inits the queue that will wait for events on files */ main_struct->save_queue = g_async_queue_new(); main_struct->dir_queue = g_async_queue_new(); main_struct->regex_exclude_list = make_regex_exclude_list(opt->exclude_list); /* Thread initialization */ main_struct->save_one_file = g_thread_new("save_one_file", save_one_file_threaded, main_struct); main_struct->carve_all_directories = g_thread_new("carve_all_directories", carve_all_directories, main_struct); main_struct->reconn_thread = g_thread_new("reconnected", reconnected, main_struct); print_debug(_("Main structure initialized !\n")); } return main_struct; }
static void test_message (Fixture *f, gconstpointer data) { DBusMessage *message = dbus_message_new_signal ("/foo", "foo.bar.baz", "Foo"); Thread public_api = { f, message, (RefFunc) dbus_message_ref, NULL, (VoidFunc) dbus_message_unref, NULL, NULL, NULL }; unsigned i; if (!dbus_message_set_data (message, message_slot, f, last_unref)) g_error ("OOM"); for (i = 0; i < f->n_threads; i++) { f->threads[i] = g_thread_new (NULL, ref_thread, &public_api); g_assert (f->threads[i] != NULL); } wait_for_all_threads (f); for (i = 0; i < f->n_threads; i++) { f->threads[i] = g_thread_new (NULL, cycle_thread, &public_api); g_assert (f->threads[i] != NULL); } wait_for_all_threads (f); for (i = 0; i < f->n_threads; i++) { f->threads[i] = g_thread_new (NULL, unref_thread, &public_api); g_assert (f->threads[i] != NULL); } wait_for_all_threads (f); /* Destroy the server. This should be the last-unref. */ g_assert (!f->last_unref); dbus_message_unref (message); g_assert (f->last_unref); }
void _start_worker(guint thread_num) { #define LEELA_EXTRA_THREADNUM 2 GThread *all_threads[thread_num+LEELA_EXTRA_THREADNUM]; struct monitor *m = g_malloc0(sizeof(*m)); g_mutex_init(&m->mutex); g_cond_init(&m->cond); m->count = thread_num; m->sleep = 0; m->m = g_malloc0(thread_num * sizeof(struct leela_monitor *)); int i = 0; for(i=0;i<thread_num;i++) { m->m[i] = leela_monitor_new(); } all_threads[0] = g_thread_new("monitor",_monitor,m); all_threads[1] = g_thread_new("timer",_timer,m); static int weight[] = { -1, -1, -1, -1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, }; struct worker_parm wp[thread_num]; for(i=0;i<thread_num;i++) { wp[i].id = i; wp[i].m = m; if (i < sizeof(weight)/sizeof(weight[0])) { wp[i].weight= weight[i]; } else { wp[i].weight = 0; } all_threads[i+LEELA_EXTRA_THREADNUM] = g_thread_new("worker",_worker,&wp[i]); } for(i=0;i<thread_num+LEELA_EXTRA_THREADNUM;i++) { g_thread_join(all_threads[i]); } free_monitor(m); }
int main() { g_mutex_init(&lock); GThread *first_thread = g_thread_new("first_thread", &doSomeThing_simple, NULL); GThread *second_thread = g_thread_new("second_thread", &doSomeThing_simple, NULL); g_thread_join(first_thread); g_thread_join(second_thread); g_mutex_clear(&lock); return 0; }
gpointer ssl_ping_thread (gpointer _c) { mongo_ssl_ctx *c = (mongo_ssl_ctx*) _c; GThread *s, *f; s = g_thread_new ("ping_success", ssl_ping_success_thread, c); f = g_thread_new ("ping_fail", ssl_ping_fail_thread, c); g_thread_join (s); g_thread_join (f); g_thread_unref (s); g_thread_unref (f); return NULL; }
/** * gst_gl_context_create: * @context: a #GstGLContext: * @other_context: (allow-none): a #GstGLContext to share OpenGL objects with * @error: (allow-none): a #GError * * Creates an OpenGL context in the current thread with the specified * @other_context as a context to share shareable OpenGL objects with. See the * OpenGL specification for what is shared between contexts. * * If an error occurs, and @error is not %NULL, then error will contain details * of the error and %FALSE will be returned. * * Should only be called once. * * Returns: whether the context could successfully be created */ gboolean gst_gl_context_create (GstGLContext * context, GstGLContext * other_context, GError ** error) { gboolean alive = FALSE; g_return_val_if_fail (GST_GL_IS_CONTEXT (context), FALSE); g_return_val_if_fail (!GST_GL_IS_WRAPPED_CONTEXT (context), FALSE); _ensure_window (context); g_mutex_lock (&context->priv->render_lock); if (!context->priv->created) { context->priv->other_context = other_context; context->priv->error = error; context->priv->gl_thread = g_thread_new ("gstglcontext", (GThreadFunc) gst_gl_context_create_thread, context); g_cond_wait (&context->priv->create_cond, &context->priv->render_lock); context->priv->created = TRUE; GST_INFO ("gl thread created"); } alive = context->priv->alive; g_mutex_unlock (&context->priv->render_lock); return alive; }
static void cockpit_ssh_transport_constructed (GObject *object) { CockpitSshTransport *self = COCKPIT_SSH_TRANSPORT (object); CockpitSshData *data; static GSourceFuncs source_funcs = { cockpit_ssh_source_prepare, cockpit_ssh_source_check, cockpit_ssh_source_dispatch, NULL, }; G_OBJECT_CLASS (cockpit_ssh_transport_parent_class)->constructed (object); g_return_if_fail (self->data->creds != NULL); g_warn_if_fail (ssh_options_set (self->data->session, SSH_OPTIONS_USER, cockpit_creds_get_user (self->data->creds)) == 0); self->io = g_source_new (&source_funcs, sizeof (CockpitSshSource)); ((CockpitSshSource *)self->io)->transport = self; g_source_attach (self->io, self->data->context); /* Setup for connect thread */ self->connect_fd = ssh_get_fd (self->data->session); g_atomic_int_set (&self->connecting, 1); self->data->connecting = &self->connecting; data = self->data; self->data = NULL; self->connect_thread = g_thread_new ("ssh-transport-connect", cockpit_ssh_connect_thread, data); g_debug ("%s: constructed", self->logname); }
static void input_selector_push_eos (gint stream, gboolean active) { GstPad *pad = stream == 1 ? stream1_pad : stream2_pad; if (active) { fail_unless (gst_pad_push_event (pad, gst_event_new_eos ())); } else { /* The non-active pads will block when receving eos, so we need to do it * from a separate thread. This makes this test racy, but it should only * cause false positives, not false negatives */ GThread *t = g_thread_new ("selector-test-push-eos", (GThreadFunc) input_selector_do_push_eos, pad); /* Sleep half a second to allow the other thread to execute, this is not * a definitive solution but there is no way to know when the * EOS has reached input-selector and blocked there, so this is just * to reduce the possibility of this test being racy (false positives) */ g_usleep (0.5 * G_USEC_PER_SEC); g_thread_unref (t); } input_selector_check_eos (active); }
/** * @brief main only creates two threads */ int main (int argc, char *argv[]) { GThread* GuiThread; GThread* DataThread; gtk_init(&argc, &argv); /* create two threads: one for the GUI and the DATA, respectively */ GuiThread = g_thread_new("Thread GUI", (GThreadFunc)guiThread, (void *)NULL); DataThread = g_thread_new("Thread DATA", (GThreadFunc)dataThread, (void *)NULL); g_thread_join(DataThread); g_thread_join(GuiThread); return 0; }
static gboolean gst_ks_video_src_start_worker (GstKsVideoSrc * self) { GstKsVideoSrcPrivate *priv = GST_KS_VIDEO_SRC_GET_PRIVATE (self); gboolean result; g_mutex_init (&priv->worker_lock); g_cond_init (&priv->worker_notify_cond); g_cond_init (&priv->worker_result_cond); priv->worker_pending_caps = NULL; priv->worker_pending_run = FALSE; priv->worker_state = KS_WORKER_STATE_STARTING; priv->worker_thread = g_thread_new ("ks-worker", gst_ks_video_src_worker_func, self); KS_WORKER_LOCK (priv); while (priv->worker_state < KS_WORKER_STATE_READY) KS_WORKER_WAIT_FOR_RESULT (priv); result = priv->worker_state == KS_WORKER_STATE_READY; KS_WORKER_UNLOCK (priv); return result; }
void do_calibration (GtkWidget *widget, gpointer data) { GtkToggleButton *silent_calib; plot_xcorr_4ch = plugin_get_new_plot(); silent_calib = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "silent_calibration")); if (gtk_toggle_button_get_active(silent_calib)) { osc_plot_set_visible(plot_xcorr_4ch, false); } if (plot_xcorr_4ch) { osc_plot_set_channel_state(plot_xcorr_4ch, CAP_DEVICE_ALT, 0, true); osc_plot_set_channel_state(plot_xcorr_4ch, CAP_DEVICE_ALT, 1, true); osc_plot_set_channel_state(plot_xcorr_4ch, CAP_DEVICE_ALT, 4, true); osc_plot_set_channel_state(plot_xcorr_4ch, CAP_DEVICE_ALT, 5, true); osc_plot_set_domain(plot_xcorr_4ch, XCORR_PLOT); osc_plot_set_marker_type(plot_xcorr_4ch, MARKER_PEAK); } else return; g_thread_new("Calibrate_thread", (void *) &calibrate, data); gtk_widget_hide(GTK_WIDGET(data)); }
int dt_lua_init_call(lua_State *L) { dt_lua_push_darktable_lib(L); luaA_Type type_id = dt_lua_init_singleton(L, "control", NULL); lua_setfield(L, -2, "control"); lua_pop(L, 1); lua_pushcfunction(L, ending_cb); dt_lua_type_register_const_type(L, type_id, "ending"); lua_pushcfunction(L, dispatch_cb); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const_type(L, type_id, "dispatch"); lua_pushcfunction(L,execute_cb); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const_type(L, type_id, "execute"); lua_pushcfunction(L,sleep_cb); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const_type(L, type_id, "sleep"); lua_pushcfunction(L,read_cb); lua_pushcclosure(L, dt_lua_type_member_common, 1); dt_lua_type_register_const_type(L, type_id, "read"); lua_newtable(L); lua_setfield(L, LUA_REGISTRYINDEX, "dt_lua_bg_threads"); // create stuff in init to avoid race conditions darktable.lua_state.context = g_main_context_new(); stacked_job_init(); alien_job_init(); string_job_init(); end_job_init(); g_thread_new("lua thread",lua_thread_main,NULL); return 0; }
SR_PRIV int usb_source_add(struct sr_context *ctx, int timeout, sr_receive_data_callback cb, void *cb_data) { if (ctx->usb_source_present) { sr_err("A USB event source is already present."); return SR_ERR; } #ifdef _WIN32 ctx->usb_event = CreateEvent(NULL, TRUE, FALSE, NULL); g_mutex_init(&ctx->usb_mutex); ctx->usb_thread_running = TRUE; ctx->usb_thread = g_thread_new("usb", usb_thread, ctx); ctx->usb_pollfd.fd = ctx->usb_event; ctx->usb_pollfd.events = G_IO_IN; ctx->usb_cb = cb; ctx->usb_cb_data = cb_data; sr_session_source_add_pollfd(&ctx->usb_pollfd, timeout, usb_callback, ctx); #else const struct libusb_pollfd **lupfd; unsigned int i; lupfd = libusb_get_pollfds(ctx->libusb_ctx); for (i = 0; lupfd[i]; i++) sr_source_add(lupfd[i]->fd, lupfd[i]->events, timeout, cb, cb_data); free(lupfd); #endif ctx->usb_source_present = TRUE; return SR_OK; }
int test9 (void) { g_print ("%s started, main thread is %p\n", __FUNCTION__, g_thread_self ()); GdaWorker *worker; gint nfailed = 0; worker = gda_worker_new (); #define NB_THREADS 2 GThread *threads[NB_THREADS]; guint i; for (i = 0; i < NB_THREADS; i++) { gchar *name; name = g_strdup_printf ("th%u", i); threads[i] = g_thread_new (name, (GThreadFunc) test9_main_func, worker); g_free (name); } for (i = 0; i < NB_THREADS; i++) { if (g_thread_join (threads[i])) nfailed++; } g_print ("Unref worker...\n"); gda_worker_unref (worker); g_print ("%s done\n", __FUNCTION__); return nfailed; }
static void TestWrite(gconstpointer user_data) { guint index = GPOINTER_TO_UINT(user_data); gint fds [] = { 0, 0 }; GIOChannel *reader = NULL; GIOChannel *writer = NULL; GThread *thread = NULL; EscalateMessage *message = NULL; GError *error = NULL; gboolean success = FALSE; gchar *result = NULL; g_assert(g_unix_open_pipe(fds, 0, NULL)); reader = g_io_channel_unix_new(fds[0]); writer = g_io_channel_unix_new(fds[1]); thread = g_thread_new("Reader", (GThreadFunc) ReaderThread, reader); message = EscalateMessageLoad(example_messages[index], NULL); g_assert(message); success = EscalateMessageWrite(message, writer, &error); g_assert_no_error(error); g_assert(success); g_assert_cmpint(G_IO_STATUS_NORMAL, ==, g_io_channel_shutdown(writer, TRUE, NULL)); result = (gchar *) g_thread_join(thread); result[strlen(result)-1] = '\0'; // Cut off newline. g_assert_cmpstr(example_messages[index], ==, result); g_io_channel_unref(reader); g_io_channel_unref(writer); EscalateMessageUnref(message); g_free(result); }
JNIEXPORT void JNICALL Java_org_GNOME_Accessibility_AtkWrapper_loadAtkBridge() { // Enable ATK Bridge so we can load it now g_unsetenv ("NO_AT_BRIDGE"); GThread *thread; GError *err; char * message; message = "JNI main loop"; err = NULL; jaw_initialized = jaw_accessibility_init(); if (jaw_debug) printf("Jaw Initialization STATUS in loadAtkBridge: %d\n", jaw_initialized); jni_main_loop = g_main_loop_new (NULL, FALSE); /*main loop NOT running*/ thread = g_thread_new(message, jni_loop_callback, (void *) jni_main_loop); if(thread == NULL) { if (jaw_debug) { printf("Thread create failed: %s!!\n", err->message ); g_error_free (err); } } }
static gpointer ev_job_scheduler_init (gpointer data) { g_thread_new ("EvJobScheduler", ev_job_thread_proxy, NULL); return NULL; }
/* * Start the version checking in a new thread. * @dialogs - The Dialogs structure to be used. Set it to NULL if a process bar * is not required to be shown during version checking. */ void version_check_start(Dialogs *_dialogs) { g_thread_new("version-check", (GThreadFunc)version_check, NULL); g_timeout_add(150, version_progress_update, _dialogs); if (_dialogs) gtk_widget_show(_dialogs->ver_progress_window); }
void xviewer_job_scheduler_init () { g_thread_new ("XviewerJobScheduler", xviewer_job_scheduler, NULL); }
void probe_modem(char* device, PyObject* callback) { struct thread_info* info = g_new0(struct thread_info, 1); info->device = g_strdup(device); info->callback = callback; Py_INCREF(callback); g_thread_new("probe modem", do_probe, info); }
int main (int argc, char **argv) { gst_init (&argc, &argv); g_mutex_init (&trans_lock); mainloop = g_main_loop_new (NULL, TRUE); worker0 = GST_WORKER (g_object_new (GST_TYPE_WORKER, "name", "test-worker-0", NULL)); worker0->pipeline_func = test_worker_pipeline; g_signal_connect (worker0, "prepare-worker", G_CALLBACK (test_worker_prepare), NULL); g_signal_connect (worker0, "start-worker", G_CALLBACK (test_worker_start), NULL); g_signal_connect (worker0, "end-worker", G_CALLBACK (test_worker_end), NULL); g_thread_new ("test-pulse", (GThreadFunc) test_worker_pulse, worker0); gst_worker_start (worker0); g_main_loop_run (mainloop); g_mutex_clear (&trans_lock); INFO ("end"); return 0; }
gboolean kiro_sb_clone (KiroSb *self, const gchar* address, const gchar* port) { g_return_val_if_fail (self != NULL, FALSE); KiroSbPrivate *priv = KIRO_SB_GET_PRIVATE (self); g_return_val_if_fail (priv->initialized == 0, FALSE); g_return_val_if_fail ((priv->trb = kiro_trb_new ()), FALSE); priv->client = kiro_client_new (); if (0 > kiro_client_connect (priv->client, address, port)) { g_debug ("Failed to connect to remote Sync Buffer"); kiro_trb_free (priv->trb); kiro_client_free (priv->client); return FALSE; } kiro_client_sync (priv->client); kiro_trb_adopt (priv->trb, kiro_client_get_memory (priv->client)); priv->main_loop = g_main_loop_new (NULL, FALSE); g_idle_add ((GSourceFunc)idle_func, priv); priv->main_thread = g_thread_new ("KIRO SB Main Loop", (GThreadFunc)start_main_loop, priv->main_loop); priv->initialized = 2; return TRUE; }
static GtkWidget* create_viewer() { GtkWidget *viewer; GtkWidget *hpanel; GtkWidget *canvas; GThread *worker; // canvas to draw framebuffer canvas = gtk_drawing_area_new(); g_signal_connect(canvas, "expose-event", G_CALLBACK(on_canvas_expose), NULL); // root container hpanel = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hpanel), canvas, TRUE, TRUE, 0); // window viewer = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_container_add(GTK_CONTAINER(viewer), hpanel); gtk_window_set_default_size(GTK_WINDOW(viewer), 640, 480); gtk_window_set_title(GTK_WINDOW(viewer), "Framebuffer Viewer"); g_signal_connect(viewer, "delete-event", G_CALLBACK(on_window_destroy), &worker); // paint thread worker running = 1; worker = g_thread_new("Painter", (GThreadFunc) thread_queue_draw_framebuffer, canvas); return viewer; }
static struct httpc* _httpc_new() { gint err; gchar sid[33]; GString *buff = qev_buffer_get(); struct httpc *hc = g_slice_alloc0(sizeof(*hc)); _uuid(sid); hc->polling = test_socket(); hc->waiting = test_socket(); hc->aq = g_async_queue_new(); hc->sid = g_strdup(sid); hc->th_run = TRUE; g_mutex_init(&hc->lock); hc->th = g_thread_new("httpc", _httpc_thread, hc); g_string_printf(buff, INIT_HEADERS, hc->sid); err = send(hc->polling, buff->str, buff->len, 0); ck_assert_int_eq(err, buff->len); qev_buffer_put(buff); _next(hc, "/qio/callback/1:0={\"code\":200,\"data\":\"localhost\"}"); return hc; }
int main(int ac, char **av) { ThreadData td; td.argc = ac; td.argv = av; td.testResult = 0; DEBUG_CONF("ut_cangenplugin", #ifdef _DEBUG CUtil::Logger::file_on|CUtil::Logger::screen_on, #else CUtil::Logger::file_on|CUtil::Logger::screen_off, #endif CUtil::Logger::EInfo, CUtil::Logger::EWarning); td.mainLoop = g_main_loop_new(NULL, FALSE); // Run the mainloop and the tests thread GThread* testThread = g_thread_new("tests thread", &tests_thread, &td); g_main_loop_run(td.mainLoop); g_thread_join(testThread); g_main_loop_unref(td.mainLoop); return td.testResult; }