示例#1
0
文件: wxe_main.cpp 项目: HansN/otp
int start_native_gui(wxe_data *sd)
{
  int res;
  wxe_status_m = erl_drv_mutex_create((char *) "wxe_status_m");
  wxe_status_c = erl_drv_cond_create((char *)"wxe_status_c");

  wxe_batch_locker_m = erl_drv_mutex_create((char *)"wxe_batch_locker_m");
  wxe_batch_locker_c = erl_drv_cond_create((char *)"wxe_batch_locker_c");
  init_caller = driver_connected(sd->port_handle);

#ifdef __DARWIN__
  res = erl_drv_steal_main_thread((char *)"wxwidgets",
				  &wxe_thread,wxe_main_loop,(void *) sd->pdl,NULL);
#else
  ErlDrvThreadOpts *opts = erl_drv_thread_opts_create((char *)"wx thread");
  opts->suggested_stack_size = 8192;
  res = erl_drv_thread_create((char *)"wxwidgets",
			      &wxe_thread,wxe_main_loop,(void *) sd->pdl,opts);
  erl_drv_thread_opts_destroy(opts);
#endif
  if(res == 0) {
    erl_drv_mutex_lock(wxe_status_m);
    for(;wxe_status == WXE_NOT_INITIATED;) {
      erl_drv_cond_wait(wxe_status_c, wxe_status_m);
    }
    erl_drv_mutex_unlock(wxe_status_m);
    return wxe_status;
  } else {
    wxString msg;
    msg.Printf(wxT("Erlang failed to create wxe-thread %d\r\n"), res);
    send_msg("error", &msg);
    return -1;
  }
}
示例#2
0
文件: dthread.c 项目: relabsoss/uart
dthread_t* dthread_start(ErlDrvPort port,
			 void* (*func)(void* arg),
			 void* arg, int stack_size)
{
    ErlDrvThreadOpts* opts = NULL;
    dthread_t* thr = NULL;

    if (!(thr = DALLOC(sizeof(dthread_t))))
	return 0;

    if (dthread_init(thr, port) < 0)
	goto error;

    if (!(opts = erl_drv_thread_opts_create("dthread_opts")))
	goto error;

    opts->suggested_stack_size = stack_size;
    thr->arg = arg;

    if (erl_drv_thread_create("dthread", &thr->tid, func, thr, opts) < 0)
	goto error;
    erl_drv_thread_opts_destroy(opts);
    return thr;

error:
    dthread_finish(thr);
    if (opts)
        erl_drv_thread_opts_destroy(opts);
    dthread_finish(thr);
    DFREE(thr);
    return 0;
}
示例#3
0
文件: erl_nif.c 项目: a5an0/otp
ErlNifThreadOpts* enif_thread_opts_create(char *name) { return (ErlNifThreadOpts*) erl_drv_thread_opts_create(name); }