diff options
| author | LarsAC <LarsAC@e10066b5-e1e2-0310-b819-94efdf66514b> | 2005-03-16 22:50:37 +0000 |
|---|---|---|
| committer | LarsAC <LarsAC@e10066b5-e1e2-0310-b819-94efdf66514b> | 2005-03-16 22:50:37 +0000 |
| commit | ae1a9c9f16c5e93c72fcfaae1ad14f3662b252cb (patch) | |
| tree | 2075885d9b67cb281dcef64729a106f680c94eb9 /mg_thread_sync.c | |
| parent | 283a4201828edde1cf92e59ccbb0395a0f894538 (diff) | |
| download | vdr-plugin-muggle-ae1a9c9f16c5e93c72fcfaae1ad14f3662b252cb.tar.gz vdr-plugin-muggle-ae1a9c9f16c5e93c72fcfaae1ad14f3662b252cb.tar.bz2 | |
Import now runs threaded when executed from VDR menu
git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/trunk/muggle-plugin@572 e10066b5-e1e2-0310-b819-94efdf66514b
Diffstat (limited to 'mg_thread_sync.c')
| -rw-r--r-- | mg_thread_sync.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/mg_thread_sync.c b/mg_thread_sync.c new file mode 100644 index 0000000..85b55a6 --- /dev/null +++ b/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(); +} + + |
