unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Running Emacs module in other thread
@ 2021-07-20  9:34 mrf
  0 siblings, 0 replies; only message in thread
From: mrf @ 2021-07-20  9:34 UTC (permalink / raw)
  To: help-gnu-emacs


hi,

I'm learning howto create dynamic emacs modules in C and I try to run my
module with

(make-thread (mymod-test))

and even I try to use pthread inside my module but without using join it
breaks my running emacs.

my code contain gtk main loop and this is my code:

///////////////////////////////////////////////////////////////////////////////
#include <emacs-module.h>
#include <gtk/gtk.h>

int plugin_is_GPL_compatible;

static emacs_value
Fmymod_test (emacs_env *env, ptrdiff_t nargs, emacs_value args[], void *data)
{
  gtk_init (NULL, NULL);

  GtkWidget *win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (win, "destroy", G_CALLBACK (gtk_main_quit), NULL);

  gtk_widget_show_all (win);
  gtk_main ();

  return env->make_integer (env, 39);
}

void bind_fun (emacs_env *env, const char *fname, emacs_value fun)
{
  env->funcall (env,
		env->intern (env, "fset"),
		2,
		(emacs_value []) {
		  env->intern (env, fname),
		  fun
		}
		);
}

int emacs_module_init (struct emacs_runtime *ert)
{
  emacs_env *env = ert->get_environment (ert);

  emacs_value fun = env->make_function (env,
					0,
					0,
					Fmymod_test,
					"doc",
					NULL);

  bind_fun (env, "mymod-test", fun);
  return 0;
}

/* Local Variables: */
/* compile-command: "gcc -pthread -fPIC `pkg-config --libs --cflags gtk+-3.0` -shared mymod.c -o mymod.so && cp mymod.so ~/.emacs.d/library/" */
/* End: */



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-20  9:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-20  9:34 Running Emacs module in other thread mrf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).