• Main Page
  • Related Pages
  • Data Structures
  • Files
  • File List
  • Globals

include/sbthread.h

Go to the documentation of this file.
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 #include <sphinxbase_export.h>
00048 #include <cmd_ln.h>
00049 
00050 #ifdef __cplusplus
00051 extern "C" {
00052 #endif
00053 #if 0
00054 /* Fool Emacs. */
00055 }
00056 #endif
00057 
00061 typedef struct sbthread_s sbthread_t;
00062 
00066 typedef struct sbmsgq_s sbmsgq_t;
00067 
00071 typedef struct sbmtx_s sbmtx_t;
00072 
00076 typedef struct sbevent_s sbevent_t;
00077 
00081 typedef int (*sbthread_main)(sbthread_t *th);
00082 
00086 SPHINXBASE_EXPORT
00087 sbthread_t *sbthread_start(cmd_ln_t *config, sbthread_main func, void *arg);
00088 
00092 SPHINXBASE_EXPORT
00093 int sbthread_wait(sbthread_t *th);
00094 
00098 SPHINXBASE_EXPORT
00099 void sbthread_free(sbthread_t *th);
00100 
00104 SPHINXBASE_EXPORT
00105 cmd_ln_t *sbthread_config(sbthread_t *th);
00106 
00110 SPHINXBASE_EXPORT
00111 void *sbthread_arg(sbthread_t *th);
00112 
00116 SPHINXBASE_EXPORT
00117 sbmsgq_t *sbthread_msgq(sbthread_t *th);
00118 
00122 SPHINXBASE_EXPORT
00123 int sbthread_wait(sbthread_t *th);
00124 
00131 SPHINXBASE_EXPORT
00132 int sbthread_send(sbthread_t *th, size_t len, void const *data);
00133 
00139 SPHINXBASE_EXPORT
00140 sbmsgq_t *sbmsgq_init(size_t depth);
00141 
00145 SPHINXBASE_EXPORT
00146 void sbmsgq_free(sbmsgq_t *q);
00147 
00151 SPHINXBASE_EXPORT
00152 int sbmsgq_send(sbmsgq_t *q, size_t len, void const *data);
00153 
00157 SPHINXBASE_EXPORT
00158 void *sbmsgq_wait(sbmsgq_t *q, size_t *out_len, int sec, int nsec);
00159 
00163 SPHINXBASE_EXPORT
00164 sbmtx_t *sbmtx_init(void);
00165 
00169 SPHINXBASE_EXPORT
00170 int sbmtx_trylock(sbmtx_t *mtx);
00171 
00175 SPHINXBASE_EXPORT
00176 int sbmtx_lock(sbmtx_t *mtx);
00177 
00181 SPHINXBASE_EXPORT
00182 int sbmtx_unlock(sbmtx_t *mtx);
00183 
00187 SPHINXBASE_EXPORT
00188 void sbmtx_free(sbmtx_t *mtx);
00189 
00193 SPHINXBASE_EXPORT
00194 sbevent_t *sbevent_init(void);
00195 
00199 SPHINXBASE_EXPORT
00200 void sbevent_free(sbevent_t *evt);
00201 
00205 SPHINXBASE_EXPORT
00206 int sbevent_signal(sbevent_t *evt);
00207 
00211 SPHINXBASE_EXPORT
00212 int sbevent_wait(sbevent_t *evt, int sec, int nsec);
00213 
00214 
00215 #ifdef __cplusplus
00216 }
00217 #endif
00218 
00219 
00220 #endif /* __SBTHREAD_H__ */

Generated on Mon Aug 29 2011 for SphinxBase by  doxygen 1.7.1