hmmer-3.3/easel/esl_dsqdata.c
/* Function:  esl_dsqdata_Recycle()
 * Synopsis:  Give a chunk back to the reader.
 * Incept:    SRE, Thu Feb 11 19:24:33 2016
 *
 * Purpose:   Recycle chunk <chu> back to the reader <dd>.  The reader
 *            is responsible for all allocation and deallocation of
 *            chunks. The reader will either reuse the chunk's memory
 *            if more chunks remain to be read, or it will free it.
 *            
 * Args:      dd  : dsqdata reader
 *            chu : chunk to recycle
 *
 * Returns:   <eslOK> on success. 
 *
 * Throws:    <eslESYS> on a pthread call failure. Caller should regard
 *            such an error as disastrous; if pthread calls are
 *            failing, you cannot depend on the reader to be working
 *            at all, and you should treat <dd> as toxic. Do whatever
 *            desperate things you need to do and exit.
 */
esl_dsqdata_Recycle()
Synopsis:  Give a chunk back to the reader.

Recycle chunk  back to the reader .  The reader
is responsible for all allocation and deallocation of
chunks. The reader will either reuse the chunk's memory
if more chunks remain to be read, or it will free it.

dd  : dsqdata reader
chu : chunk to recycle

 on success.

 on a pthread call failure. Caller should regard
such an error as disastrous; if pthread calls are
failing, you cannot depend on the reader to be working
at all, and you should treat  as toxic. Do whatever
desperate things you need to do and exit.
esl_dsqdata_Recycle () Synopsis : Give a chunk back to the reader . Recycle chunk back to the reader . The reader is responsible for all allocation and deallocation of chunks . The reader will either reuse the chunk ' s memory if more chunks remain to be read or it will free it . dd : dsqdata reader chu : chunk to recycle on success . on a pthread call failure . Caller should regard such an error as disastrous ; if pthread calls are failing you cannot depend on the reader to be working at all and you should treat as toxic . Do whatever desperate things you need to do and exit .
int
esl_dsqdata_Recycle(ESL_DSQDATA *dd, ESL_DSQDATA_CHUNK *chu)
{
  if (chu)
    {
      if ( pthread_mutex_lock(&dd->recycling_mutex)   != 0) ESL_EXCEPTION(eslESYS, "pthread mutex lock failed");
      chu->nxt      = dd->recycling;       
      dd->recycling = chu;
      if ( pthread_mutex_unlock(&dd->recycling_mutex) != 0) ESL_EXCEPTION(eslESYS, "pthread mutex unlock failed");
      if ( pthread_cond_signal(&dd->recycling_cv)     != 0) ESL_EXCEPTION(eslESYS, "pthread cond signal failed");  
    }
  return eslOK;
}
int esl_dsqdata_Recycle ( ESL_DSQDATA * dd , ESL_DSQDATA_CHUNK * chu ) { if ( chu ) { if ( pthread_mutex_lock ( & dd -> recycling_mutex ) != 0 ) ESL_EXCEPTION ( eslESYS , " " ) ; chu -> nxt = dd -> recycling ; dd -> recycling = chu ; if ( pthread_mutex_unlock ( & dd -> recycling_mutex ) != 0 ) ESL_EXCEPTION ( eslESYS , " " ) ; if ( pthread_cond_signal ( & dd -> recycling_cv ) != 0 ) ESL_EXCEPTION ( eslESYS , " " ) ; } return eslOK ; }
Function:  esl_dsqdata_Recycle()
 Synopsis:  Give a chunk back to the reader.
Function : esl_dsqdata_Recycle () Synopsis : Give a chunk back to the reader .
// Push chunk onto head of recycling stack // loader may wait for this signal