SphinxBase 0.6
|
00001 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 00002 /* ==================================================================== 00003 * Copyright (c) 2008 Carnegie Mellon University. All rights 00004 * reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 00010 * 1. Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * 00013 * 2. Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in 00015 * the documentation and/or other materials provided with the 00016 * distribution. 00017 * 00018 * This work was supported in part by funding from the Defense Advanced 00019 * Research Projects Agency and the National Science Foundation of the 00020 * United States of America, and the CMU Sphinx Speech Consortium. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 00023 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 00024 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00025 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 00026 * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00027 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00028 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00029 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00030 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00031 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00032 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 * ==================================================================== 00035 * 00036 */ 00043 #ifndef __SBTHREAD_H__ 00044 #define __SBTHREAD_H__ 00045 00046 #include <sphinx_config.h> 00047 00048 #include <sphinxbase/sphinxbase_export.h> 00049 #include <sphinxbase/cmd_ln.h> 00050 00051 #ifdef __cplusplus 00052 extern "C" { 00053 #endif 00054 #if 0 00055 /* Fool Emacs. */ 00056 } 00057 #endif 00058 00062 typedef struct sbthread_s sbthread_t; 00063 00067 typedef struct sbmsgq_s sbmsgq_t; 00068 00072 typedef struct sbmtx_s sbmtx_t; 00073 00077 typedef struct sbevent_s sbevent_t; 00078 00082 typedef int (*sbthread_main)(sbthread_t *th); 00083 00087 SPHINXBASE_EXPORT 00088 sbthread_t *sbthread_start(cmd_ln_t *config, sbthread_main func, void *arg); 00089 00093 SPHINXBASE_EXPORT 00094 int sbthread_wait(sbthread_t *th); 00095 00099 SPHINXBASE_EXPORT 00100 void sbthread_free(sbthread_t *th); 00101 00105 SPHINXBASE_EXPORT 00106 cmd_ln_t *sbthread_config(sbthread_t *th); 00107 00111 SPHINXBASE_EXPORT 00112 void *sbthread_arg(sbthread_t *th); 00113 00117 SPHINXBASE_EXPORT 00118 sbmsgq_t *sbthread_msgq(sbthread_t *th); 00119 00123 SPHINXBASE_EXPORT 00124 int sbthread_wait(sbthread_t *th); 00125 00132 SPHINXBASE_EXPORT 00133 int sbthread_send(sbthread_t *th, size_t len, void const *data); 00134 00140 SPHINXBASE_EXPORT 00141 sbmsgq_t *sbmsgq_init(size_t depth); 00142 00146 SPHINXBASE_EXPORT 00147 void sbmsgq_free(sbmsgq_t *q); 00148 00152 SPHINXBASE_EXPORT 00153 int sbmsgq_send(sbmsgq_t *q, size_t len, void const *data); 00154 00158 SPHINXBASE_EXPORT 00159 void *sbmsgq_wait(sbmsgq_t *q, size_t *out_len, int sec, int nsec); 00160 00164 SPHINXBASE_EXPORT 00165 sbmtx_t *sbmtx_init(void); 00166 00170 SPHINXBASE_EXPORT 00171 int sbmtx_trylock(sbmtx_t *mtx); 00172 00176 SPHINXBASE_EXPORT 00177 int sbmtx_lock(sbmtx_t *mtx); 00178 00182 SPHINXBASE_EXPORT 00183 int sbmtx_unlock(sbmtx_t *mtx); 00184 00188 SPHINXBASE_EXPORT 00189 void sbmtx_free(sbmtx_t *mtx); 00190 00194 SPHINXBASE_EXPORT 00195 sbevent_t *sbevent_init(void); 00196 00200 SPHINXBASE_EXPORT 00201 void sbevent_free(sbevent_t *evt); 00202 00206 SPHINXBASE_EXPORT 00207 int sbevent_signal(sbevent_t *evt); 00208 00212 SPHINXBASE_EXPORT 00213 int sbevent_wait(sbevent_t *evt, int sec, int nsec); 00214 00215 00216 #ifdef __cplusplus 00217 } 00218 #endif 00219 00220 00221 #endif /* __SBTHREAD_H__ */