/usr/include/dclib-0.3/dclib/core/cthread.h is in libdc-dev 0.3.24~svn3121-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | /***************************************************************************
cthread.h - description
-------------------
begin : Sun Sep 30 2001
copyright : (C) 2001-2004 by Mathias Küster
email : mathen@users.berlios.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef CTHREAD_H
#define CTHREAD_H
/**
*@author Mathias Küster
*
* Threading in dclib: there isn't really any. Almost everything
* runs on CManager's thread, there is a thread permanently waiting
* to do DNS lookups, and a thread is started for filelist refresh
* and to send public hubs data to CConfig.
*
* CConnection inherits CThread, so all hub, peer and http connections
* are threads, but none are started, all their Thread() functions
* get called by CConnectionManager, CDownloadManager or CManager
* directly.
*
* This explains the unusual design of this class, the Thread()
* virtual function (or the callback) is called repeatedly until
* someone calls Stop(), to use it like a normal thread class
* call Stop(false) at the end of your Thread() function.
*
* The Stop() function of course, does not halt the thread, just
* stops the Thread() function being called again. It does however
* wait for the thread to finish before returning unless you
* call Stop(false). But it will not wait for a thread that has already
* had Stop() called but hasn't finished running yet.
*/
#ifndef WIN32
#include <pthread.h>
#endif
#include <dclib/dcos.h>
#include <dclib/core/cmutex.h>
class _CCallback0;
class CThread : public CMutex {
public:
/** */
CThread();
/** */
virtual ~CThread();
/** */
int Start();
/** */
int Stop( bool bHard = true );
/** */
bool Stopped() const;
/**
* To avoid changing Stop() this just does
* pthread_join, i.e. it makes the calling thread
* wait forever until the thread finishes.
*
* Returns true if pthread_join() returns 0 i.e.
* was successful.
*
* If the thread isn't running according to iRun
* pthread_join() is not called and false is returned.
*/
bool Join();
/** */
static void NanoSleep( unsigned long );
/** */
void SetThreadCallBackFunction( _CCallback0 * callback );
/** */
virtual void Thread() {};
protected:
/** */
int iRun;
private:
/** callback function */
_CCallback0 * _thread_callback_function;
#ifdef WIN32
/** */
HANDLE thread;
#else
/** */
pthread_t thread;
#endif
/** */
int iStop;
/** */
#ifdef WIN32
static unsigned int __stdcall MainThread( void * object );
#else
static void * MainThread(void *object);
#endif
};
/** */
inline bool CThread::Stopped() const
{ return (iStop==1); }
#endif
|