/*
 * CThread.h
 *
 *  Created on: 2019-6-26
 *      Author: fiona fan
 */

#ifndef CTHREAD_H_
#define CTHREAD_H_

#include "../CossCore/log_tool.h"
#include <stdint.h>
#include <stdio.h>
#include <stddef.h>
#include <functional>

//namespace message_manager {

using EndOfThread = std::function<void(void*)>;

class CThread {

private:
	pthread_t  m_thread_id;
    EndOfThread* end = nullptr;

public:
    void *param;

    explicit CThread();
	virtual ~CThread();

	void thread_exit();
	void thread_cancel(pthread_t thread);
	virtual void Run() = 0;
	static void* thread_run_temp(void* param);
	int8_t Start(void*obj, void* run_param);
	pthread_t GetThreadID();

    void onEnd();

    void setEndHandler(const EndOfThread &endHandler);
};

//} /* namespace message_manager */
#endif /* CTHREAD_H_ */
