/*
 * pidmap.h
 *
 * Copyright (C) Leni Mayo 2001-2002
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License, version 2, as
 *	published by the Free Software Foundation.
 *	
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *	
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
#ifndef _PIDMAP_H_
#define _PIDMAP_H_

#include <sys/time.h>
#include <glib.h>
#include "common.h"
#include "node.h"

typedef GHashTable PidMap;
typedef struct timeval StopwatchTime;

PidMap * pidmapNew();
void     pidmapDelete(PidMap *pPidmap);
int      pidmapAdd(PidMap *pPidmap, Pid pid, Node *pNode);
void     pidmapRemove(PidMap *pPidmap, Pid pid);
Node   * pidmapToNode(PidMap *pPidmap, Pid pid);
const char * pidmapAsString(PidMap *pTable, char *buf, int bufsiz);

/*
 * The stopwatch methods manipulate the stopwatch that's associated with
 * each pid, which counts how much time the pid has spent unblocked.
 */

void pidmapStopwatchStart(PidMap *pPidmap, Pid pid, const StopwatchTime *pTime);
void pidmapStopwatchStop(PidMap *pPidmap, Pid pid, const StopwatchTime *pTime);
long pidmapStopwatchTime(PidMap *pPidmap, Pid pid);
int  getStopwatchTime(StopwatchTime *pTime);
const char *printTime();

const char *printTimeDelta(const StopwatchTime *pStart);

#endif /* _PIDMAP_H_ */
