ardupilot/libraries/AP_HAL_Linux/Thread.h
2016-02-12 23:42:34 -02:00

52 lines
1.3 KiB
C++

/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
/*
* Copyright (C) 2016 Intel Corporation. All rights reserved.
*
* This file 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 3 of the License, or
* (at your option) any later version.
*
* This file 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, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <pthread.h>
#include <inttypes.h>
#include <stdlib.h>
#include <AP_HAL/utility/functor.h>
#include "AP_HAL_Linux_Namespace.h"
namespace Linux {
/*
* Interface abstracting threads
*/
class Thread {
public:
FUNCTOR_TYPEDEF(task_t, void);
Thread(task_t t) : _task(t) { }
virtual ~Thread() { }
bool start(const char *name, int policy, int prio);
protected:
static void *_run_trampoline(void *arg);
task_t _task;
bool _started;
pthread_t _ctx;
};
}