summaryrefslogtreecommitdiff
path: root/muggle-plugin/mg_thread_sync.c
diff options
context:
space:
mode:
Diffstat (limited to 'muggle-plugin/mg_thread_sync.c')
-rw-r--r--muggle-plugin/mg_thread_sync.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/muggle-plugin/mg_thread_sync.c b/muggle-plugin/mg_thread_sync.c
new file mode 100644
index 0000000..85b55a6
--- /dev/null
+++ b/muggle-plugin/mg_thread_sync.c
@@ -0,0 +1,63 @@
+
+#include <mysql/mysql.h>
+
+#include "mg_thread_sync.h"
+#include "mg_sync.h"
+
+static mgThreadSync* the_instance = NULL;
+
+mgThreadSync* mgThreadSync::get_instance()
+{
+ if( !the_instance )
+ {
+ the_instance = new mgThreadSync();
+ }
+
+
+ if( the_instance->Active() )
+ {
+ return NULL;
+ }
+ else
+ {
+ return the_instance;
+ }
+}
+
+void mgThreadSync::SetArguments( char * const * path_argv, bool delete_missing )
+{
+ m_path = path_argv;
+ m_delete = delete_missing;
+}
+
+bool mgThreadSync::Sync(char * const * path_argv, bool delete_missing )
+{
+ mgThreadSync *s = mgThreadSync::get_instance();
+ if( s )
+ {
+ s->SetArguments( path_argv, delete_missing );
+ s->Start();
+
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+void
+mgThreadSync::Action()
+{
+ mysql_thread_init();
+
+ if( m_path )
+ {
+ mgSync s;
+ s.Sync( m_path, m_delete );
+ }
+
+ mysql_thread_end();
+}
+
+