mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Initial checkin of unified hierarchy of WPILib 2015
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
#include "OSAL/Synchronized.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
pthread_mutexattr_t mta;
|
||||
bool hasInit = false;
|
||||
|
||||
|
||||
NTSynchronized::NTSynchronized(NTReentrantSemaphore& semaphore):m_semaphore(semaphore)
|
||||
{
|
||||
m_semaphore.take();
|
||||
}
|
||||
|
||||
NTSynchronized::~NTSynchronized()
|
||||
{
|
||||
m_semaphore.give();
|
||||
}
|
||||
29
networktables/cpp/Athena/src/main/native/OSAL/System.cpp
Normal file
29
networktables/cpp/Athena/src/main/native/OSAL/System.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* System.cpp
|
||||
*
|
||||
* Created on: Sep 26, 2012
|
||||
* Author: Mitchell Wills
|
||||
*/
|
||||
|
||||
#include "networktables2/util/System.h"
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
|
||||
void sleep_ms(unsigned long ms){
|
||||
while(ms>500){
|
||||
usleep(500*1000);
|
||||
ms-=500;
|
||||
}
|
||||
usleep(ms*1000);
|
||||
}
|
||||
unsigned long currentTimeMillis(){//TODO improve
|
||||
struct timeval tv;
|
||||
if (gettimeofday(&tv, NULL) != 0){
|
||||
return -1;
|
||||
}
|
||||
return ((tv.tv_sec % 86400) * 1000 + tv.tv_usec / 1000);
|
||||
}
|
||||
void writeWarning(const char* message){
|
||||
std::cerr << message;
|
||||
}
|
||||
Reference in New Issue
Block a user