/***************************************************************************
                Monitoring
                -----------------------------------------
	begin      : 2012/05/14
	copyright  : (C) 2011 SolutionBox Inc.
	author     : Service 1 Team
	email      : svc1@solbox.com
	version    : 3.1.0

    CopyRight(C) 2011 SolutionBox Inc. All Rights reserved.
    Redistribution and use in source and binary forms, with or with out
    modification, are not permitted in outside of SolutionBox Inc.
***************************************************************************/
#ifndef __MONITORING__
#define __MONITORING__

class jobmanager;

class monitoring
{
public:
	static	monitoring*		getInstance();
	static	void			release();
	
	bool					init();
	void					destory();

	void					setjobs(vector<jobmanager *> *p) { m_pjobs = p; }
	void					setexit() { m_exit = true; }

	void					monlock() { pthread_mutex_lock(&m_mutex); }
	void					monunlock() { pthread_mutex_unlock(&m_mutex); }
	
private:
	monitoring();
	virtual ~monitoring();

	void	printjobstatus(string prefixed = "");

	static void* monitoringfn(void * pdata);

private:
	static monitoring*		m_inst;
	pthread_t				m_thread;
	bool					m_exit;
	vector<jobmanager *>	*m_pjobs;

	pthread_mutex_t			m_mutex;
};

#endif // __MONITORING__

