| 1 | /* |
| 2 | * Copyright 2011 Red Hat Inc., Durham, North Carolina. |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2.1 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Lesser General Public |
| 16 | * License along with this library; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | * |
| 19 | * Authors: |
| 20 | * Daniel Kopecek <[email protected]> |
| 21 | */ |
| 22 | #ifndef WORKER_H |
| 23 | #define WORKER_H |
| 24 | |
| 25 | #include "_seap.h" |
| 26 | #include <sexp.h> |
| 27 | #include <pthread.h> |
| 28 | #include "probe.h" |
| 29 | |
| 30 | #ifndef PROBE_WORKER_DEFAULT_MAX_THREADS |
| 31 | # define PROBE_WORKER_DEFAULT_MAX_THREADS 64 /**< maximum number of worker threads that will be created */ |
| 32 | #endif |
| 33 | |
| 34 | #ifndef PROBE_WORKER_DEFAULT_MAX_CHDEPTH |
| 35 | # define PROBE_WORKER_DEFAULT_MAX_CHDEPTH 8 /**< maximum depth of a worker thread chain */ |
| 36 | #endif |
| 37 | |
| 38 | typedef struct { |
| 39 | SEAP_msgid_t sid; /**< SEAP message handled by this thread */ |
| 40 | pthread_t tid; /**< thread ID */ |
| 41 | SEXP_t * (*msg_handler)(probe_t *, SEAP_msg_t *, int *); /**< input message (object) handler */ |
| 42 | SEAP_msg_t *msg; /**< the message being handled */ |
| 43 | } probe_worker_t; |
| 44 | |
| 45 | typedef struct { |
| 46 | probe_t *probe; |
| 47 | probe_worker_t *pth; |
| 48 | } probe_pwpair_t; |
| 49 | |
| 50 | probe_worker_t *probe_worker_new(void); |
| 51 | void *probe_worker_runfn(void *arg); |
| 52 | SEXP_t *probe_worker(probe_t *probe, SEAP_msg_t *msg_in, int *ret); |
| 53 | |
| 54 | #endif /* WORKER_H */ |