WPILib Reorganization

This is a major restructuring of the WPILib repository to simply build
procedures and remove the remnants of Maven from everything except the
eclipse plugins. Gradle files have been largely simplified or rewritten,
taking advantage of splitting up parts of the build into separate build
files for ease of reading.

The eclipse plugins are now in a separate project, as is ntcore. All
dependencies are resolved via Maven dependencies, with the
Jenkins-maintained WPILib repo. Project structures have also been
simplified: we no longer have separate subprojects inside wpilibc and
wpilibj. Where possible, these changes hav been done with git renames,
to make sure we still have full history for all repositories. Other
unrelated subprojects have also been broken out: OutlineViewer is now a
separate project.

Change-Id: Ib4e2a6e1a2f66427a14f16612b0e0d69ed661878
This commit is contained in:
Fredric Silberberg
2015-09-24 20:26:49 -04:00
parent c20d34c2b6
commit 6d854afb0e
1769 changed files with 2278 additions and 333177 deletions

115
wpilibc/Athena/src/Task.cpp Normal file
View File

@@ -0,0 +1,115 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.
*/
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#include "Task.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "WPIErrors.h"
#include <errno.h>
#include <string.h>
#include <stdio.h>
#ifndef OK
#define OK 0
#endif /* OK */
#ifndef ERROR
#define ERROR (-1)
#endif /* ERROR */
const uint32_t Task::kDefaultPriority;
Task& Task::operator=(Task&& task) {
m_thread.swap(task.m_thread);
m_taskName = std::move(task.m_taskName);
return *this;
}
Task::~Task() {
if (m_thread.joinable()) {
std::cout << "[HAL] Exited task " << m_taskName << std::endl;
}
}
bool Task::joinable() const noexcept {
return m_thread.joinable();
}
void Task::join() {
m_thread.join();
}
void Task::detach() {
m_thread.detach();
}
std::thread::id Task::get_id() const noexcept {
return m_thread.get_id();
}
std::thread::native_handle_type Task::native_handle() {
return m_thread.native_handle();
}
/**
* Verifies a task still exists.
*
* @return true on success.
*/
bool Task::Verify() {
TASK id = (TASK)m_thread.native_handle();
return verifyTaskID(id) == OK;
}
/**
* Gets the priority of a task.
*
* @return task priority or 0 if an error occured
*/
int32_t Task::GetPriority() {
int priority;
auto id = m_thread.native_handle();
if (HandleError(getTaskPriority(&id, &priority)))
return priority;
else
return 0;
}
/**
* This routine changes a task's priority to a specified priority.
* Priorities range from 1, the lowest priority, to 99, the highest priority.
* Default task priority is 60.
*
* @param priority The priority at which the internal thread should run.
* @return true on success.
*/
bool Task::SetPriority(int32_t priority) {
auto id = m_thread.native_handle();
return HandleError(setTaskPriority(&id, priority));
}
/**
* Returns the name of the task.
*
* @return The name of the task.
*/
std::string Task::GetName() const { return m_taskName; }
/**
* Handles errors generated by task related code.
*/
bool Task::HandleError(STATUS results) {
if (results != ERROR) return true;
int errsv = errno;
if (errsv == HAL_taskLib_ILLEGAL_PRIORITY) {
wpi_setWPIErrorWithContext(TaskPriorityError, m_taskName.c_str());
} else {
printf("ERROR: errno=%i", errsv);
wpi_setWPIErrorWithContext(TaskError, m_taskName.c_str());
}
return false;
}