summaryrefslogtreecommitdiff
path: root/mg_thread_sync.c
blob: 85b55a6f86f1292ae7634e29b02fd2b70850d977 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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();
}