open_toontown_panda3d/panda/src/pstatclient/pStatThread.I

92 lines
3.1 KiB
Plaintext

// Filename: pStatThread.I
// Created by: drose (11Jul00)
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: PStatThread::Default Constructor
// Access: Private
// Description: Normally, this constructor is called only from
// PStatClient. Use one of the constructors below to
// create your own Thread.
////////////////////////////////////////////////////////////////////
INLINE PStatThread::
PStatThread() {
}
////////////////////////////////////////////////////////////////////
// Function: PStatThread::Constructor
// Access: Private
// Description: Normally, this constructor is called only from
// PStatClient. Use one of the constructors below to
// create your own Thread.
////////////////////////////////////////////////////////////////////
INLINE PStatThread::
PStatThread(PStatClient *client, int index) :
_client(client),
_index(index)
{
}
////////////////////////////////////////////////////////////////////
// Function: PStatThread::Constructor
// Access: Public
// Description: Creates a new named thread. This will be used to
// unify tasks that share a common thread, and
// differentiate tasks that occur in different threads.
// If any two different PStatThread objects share the
// same name, then they are really the same thread.
////////////////////////////////////////////////////////////////////
INLINE PStatThread::
PStatThread(const string &name, PStatClient *client) {
#ifdef HAVE_NET
if (client == (PStatClient *)NULL) {
client = PStatClient::get_global_pstats();
}
PStatThread thread(client->make_thread(name));
(*this) = thread;
#else
_client = (PStatClient *)NULL;
_index = 0;
#endif
}
////////////////////////////////////////////////////////////////////
// Function: PStatThread::Copy Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE PStatThread::
PStatThread(const PStatThread &copy) :
_client(copy._client),
_index(copy._index)
{
}
////////////////////////////////////////////////////////////////////
// Function: PStatThread::Copy Assignment Operator
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE void PStatThread::
operator = (const PStatThread &copy) {
_client = copy._client;
_index = copy._index;
}
////////////////////////////////////////////////////////////////////
// Function: PStatThread::new_frame
// Access: Public
// Description: This must be called at the start of every "frame",
// whatever a frame may be deemed to be, to accumulate
// all the stats that have collected so far for the
// thread and ship them off to the server.
////////////////////////////////////////////////////////////////////
INLINE void PStatThread::
new_frame() {
#ifdef HAVE_NET
_client->new_frame(_index);
#endif
}