syslog-ng source
mainloop-threaded-worker.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2002-2013 Balabit
3  * Copyright (c) 1998-2013 Balázs Scheidler
4  * Copyright (c) 2022 Balázs Scheidler <bazsi77@gmail.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  *
20  * As an additional exemption you are allowed to compile & link against the
21  * OpenSSL libraries as published by the OpenSSL project. See the file
22  * COPYING for details.
23  *
24  */
25 
26 #ifndef MAINLOOP_THREADED_WORKER_H_INCLUDED
27 #define MAINLOOP_THREADED_WORKER_H_INCLUDED
28 
29 #include "mainloop-worker.h"
30 
31 typedef void (*MainLoopThreadedWorkerFunc)(gpointer user_data);
32 typedef struct _MainLoopThreadedWorker MainLoopThreadedWorker;
34 {
35  gpointer data;
37  GThread *thread;
38  GMutex lock;
39  struct
40  {
41  GCond cond;
42  gboolean finished;
43  gboolean result;
45  gboolean (*thread_init)(MainLoopThreadedWorker *s);
46  void (*thread_deinit)(MainLoopThreadedWorker *s);
47  void (*request_exit)(MainLoopThreadedWorker *self);
48  void (*run)(MainLoopThreadedWorker *self);
49 };
50 
51 gboolean main_loop_threaded_worker_start(MainLoopThreadedWorker *self);
52 
53 void main_loop_threaded_worker_init(MainLoopThreadedWorker *self,
54  MainLoopWorkerType worker_type, gpointer data);
55 void main_loop_threaded_worker_clear(MainLoopThreadedWorker *self);
56 
57 #endif
void(* MainLoopThreadedWorkerFunc)(gpointer user_data)
Definition: mainloop-threaded-worker.h:31
gboolean main_loop_threaded_worker_start(MainLoopThreadedWorker *self)
Definition: mainloop-threaded-worker.c:106
void main_loop_threaded_worker_init(MainLoopThreadedWorker *self, MainLoopWorkerType worker_type, gpointer data)
Definition: mainloop-threaded-worker.c:121
void main_loop_threaded_worker_clear(MainLoopThreadedWorker *self)
Definition: mainloop-threaded-worker.c:135
MainLoopWorkerType
Definition: mainloop-worker.h:35
Definition: mainloop-threaded-worker.h:34
gboolean result
Definition: mainloop-threaded-worker.h:43
void(* run)(MainLoopThreadedWorker *self)
Definition: mainloop-threaded-worker.h:48
void(* request_exit)(MainLoopThreadedWorker *self)
Definition: mainloop-threaded-worker.h:47
struct _MainLoopThreadedWorker::@62 startup
gboolean finished
Definition: mainloop-threaded-worker.h:42
void(* thread_deinit)(MainLoopThreadedWorker *s)
Definition: mainloop-threaded-worker.h:46
gpointer data
Definition: mainloop-threaded-worker.h:35
GCond cond
Definition: mainloop-threaded-worker.h:41
gboolean(* thread_init)(MainLoopThreadedWorker *s)
Definition: mainloop-threaded-worker.h:45
GMutex lock
Definition: mainloop-threaded-worker.h:38
GThread * thread
Definition: mainloop-threaded-worker.h:37
MainLoopWorkerType worker_type
Definition: mainloop-threaded-worker.h:36