[anjuta/libgit2-glib] git: Implement GitThreadPool



commit 792387bd6ff56d79362292b35f94510257f90c32
Author: James Liggett <jrliggett cox net>
Date:   Fri Jul 12 22:50:10 2013 -0700

    git: Implement GitThreadPool
    
    GitThreadPool is an AnjutaThreadPool subclass that decorates each enqueued
    GitCommand object with a reference to the repository that the plugin is
    currently working with.

 plugins/git/Makefile.am       |    4 +-
 plugins/git/git-thread-pool.c |   83 +++++++++++++++++++++++++++++++++++++++++
 plugins/git/git-thread-pool.h |   61 ++++++++++++++++++++++++++++++
 3 files changed, 147 insertions(+), 1 deletions(-)
---
diff --git a/plugins/git/Makefile.am b/plugins/git/Makefile.am
index f59d488..2f63ecf 100644
--- a/plugins/git/Makefile.am
+++ b/plugins/git/Makefile.am
@@ -233,7 +233,9 @@ libanjuta_git_la_SOURCES = \
        git-apply-mailbox-pane.c \
        git-apply-mailbox-pane.h \
        git-command.c \
-       git-command.h
+       git-command.h \
+       git-thread-pool.c \
+       git_thread-pool.h
        
 
 libanjuta_git_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
diff --git a/plugins/git/git-thread-pool.c b/plugins/git/git-thread-pool.c
new file mode 100644
index 0000000..d9edfaa
--- /dev/null
+++ b/plugins/git/git-thread-pool.c
@@ -0,0 +1,83 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*-  */
+/*
+ * git-thread-pool.c
+ * Copyright (C) 2013 James Liggett <jrliggett cox net>
+ *
+ * anjuta is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * anjuta is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "git-thread-pool.h"
+
+struct _GitThreadPoolPrivate
+{
+       GgitRepository *repository;
+};
+
+
+G_DEFINE_TYPE (GitThreadPool, git_thread_pool, ANJUTA_TYPE_THREAD_POOL);
+
+static void
+git_thread_pool_init (GitThreadPool *git_thread_pool)
+{
+       git_thread_pool->priv = G_TYPE_INSTANCE_GET_PRIVATE (git_thread_pool, GIT_TYPE_THREAD_POOL, 
GitThreadPoolPrivate);
+
+       /* TODO: Add initialization code here */
+}
+
+static void
+git_thread_pool_finalize (GObject *object)
+{
+       GitThreadPool *self;
+
+       self = GIT_THREAD_POOL (object);
+
+       g_object_unref (self->priv->repository);
+
+       G_OBJECT_CLASS (git_thread_pool_parent_class)->finalize (object);
+}
+
+static void
+git_thread_pool_class_init (GitThreadPoolClass *klass)
+{
+       GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+       g_type_class_add_private (klass, sizeof (GitThreadPoolPrivate));
+
+       object_class->finalize = git_thread_pool_finalize;
+}
+
+
+void
+git_thread_pool_push (GitThreadPool *self, GitCommand *command)
+{
+       if (self->priv->repository)
+       {
+               g_object_set (command, "repository", self->priv->repository, NULL);
+               anjuta_thread_pool_push (ANJUTA_THREAD_POOL (self), 
+                                        ANJUTA_THREAD_POOL_TASK (command));
+       }
+}
+
+GitThreadPool *
+git_thread_pool_new (GgitRepository *repository)
+{
+       GitThreadPool *self;
+
+       self = g_object_new (GIT_TYPE_THREAD_POOL, NULL);
+
+       self->priv->repository = g_object_ref (repository);
+
+       return self;
+       
+}
diff --git a/plugins/git/git-thread-pool.h b/plugins/git/git-thread-pool.h
new file mode 100644
index 0000000..6d2fd59
--- /dev/null
+++ b/plugins/git/git-thread-pool.h
@@ -0,0 +1,61 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*-  */
+/*
+ * git-thread-pool.h
+ * Copyright (C) 2013 James Liggett <jrliggett cox net>
+ *
+ * anjuta is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * anjuta is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _GIT_THREAD_POOL_H_
+#define _GIT_THREAD_POOL_H_
+
+#include <glib-object.h>
+#include <libanjuta/anjuta-thread-pool.h>
+#include "git-command.h"
+
+G_BEGIN_DECLS
+
+#define GIT_TYPE_THREAD_POOL             (git_thread_pool_get_type ())
+#define GIT_THREAD_POOL(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIT_TYPE_THREAD_POOL, 
GitThreadPool))
+#define GIT_THREAD_POOL_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GIT_TYPE_THREAD_POOL, 
GitThreadPoolClass))
+#define GIT_IS_THREAD_POOL(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIT_TYPE_THREAD_POOL))
+#define GIT_IS_THREAD_POOL_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GIT_TYPE_THREAD_POOL))
+#define GIT_THREAD_POOL_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GIT_TYPE_THREAD_POOL, 
GitThreadPoolClass))
+
+typedef struct _GitThreadPoolClass GitThreadPoolClass;
+typedef struct _GitThreadPool GitThreadPool;
+typedef struct _GitThreadPoolPrivate GitThreadPoolPrivate;
+
+
+struct _GitThreadPoolClass
+{
+       AnjutaThreadPoolClass parent_class;
+};
+
+struct _GitThreadPool
+{
+       AnjutaThreadPool parent_instance;
+
+       GitThreadPoolPrivate *priv;
+};
+
+GType git_thread_pool_get_type (void) G_GNUC_CONST;
+
+void git_thread_pool_push (GitThreadPool *self, GitCommand *command);
+GitThreadPool *git_thread_pool_new (GgitRepository *self);
+
+G_END_DECLS
+
+#endif /* _GIT_THREAD_POOL_H_ */
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]