Merge changes from the witness.
This commit is contained in:
@ -150,8 +150,8 @@ namespace nv {
|
||||
private:
|
||||
// don't provide operator = or == ; make the client write Store( Load() )
|
||||
NV_FORBID_COPY(Atomic);
|
||||
|
||||
NV_COMPILER_CHECK(sizeof(T) == sizeof(uint32) || sizeof(T) == sizeof(uint64));
|
||||
|
||||
NV_COMPILER_CHECK(sizeof(T) == sizeof(uint32) || sizeof(T) == sizeof(uint64));
|
||||
|
||||
T m_value;
|
||||
};
|
||||
|
@ -48,6 +48,6 @@ void Event::wait() {
|
||||
}
|
||||
|
||||
#elif NV_OS_UNIX
|
||||
// @@ TODO
|
||||
// @@ TODO
|
||||
#pragma NV_MESSAGE("Implement event using pthreads!")
|
||||
#endif
|
||||
|
@ -18,8 +18,8 @@ namespace nv
|
||||
Event();
|
||||
~Event();
|
||||
|
||||
void post();
|
||||
void wait(); // Wait resets the event.
|
||||
void post();
|
||||
void wait(); // Wait resets the event.
|
||||
|
||||
static void post(Event * events, uint count);
|
||||
static void wait(Event * events, uint count);
|
||||
|
@ -18,14 +18,14 @@ namespace nv
|
||||
Mutex ();
|
||||
~Mutex ();
|
||||
|
||||
void lock();
|
||||
bool tryLock();
|
||||
void unlock();
|
||||
void lock();
|
||||
bool tryLock();
|
||||
void unlock();
|
||||
|
||||
private:
|
||||
struct Private;
|
||||
AutoPtr<Private> m;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// Templated lock that can be used with any mutex.
|
||||
@ -35,8 +35,8 @@ namespace nv
|
||||
NV_FORBID_COPY(Lock);
|
||||
public:
|
||||
|
||||
Lock (M & m) : m_mutex (m) { m_mutex.lock(); }
|
||||
~Lock () { m_mutex.unlock(); }
|
||||
Lock (M & m) : m_mutex (m) { m_mutex.lock(); }
|
||||
~Lock () { m_mutex.unlock(); }
|
||||
|
||||
private:
|
||||
M & m_mutex;
|
||||
|
@ -19,21 +19,21 @@ namespace nv
|
||||
Thread();
|
||||
~Thread();
|
||||
|
||||
void start(ThreadFunc * func, void * arg);
|
||||
void wait();
|
||||
void start(ThreadFunc * func, void * arg);
|
||||
void wait();
|
||||
|
||||
bool isRunning() const;
|
||||
bool isRunning() const;
|
||||
|
||||
static void spinWait(uint count);
|
||||
static void yield();
|
||||
static void sleep(uint ms);
|
||||
static void spinWait(uint count);
|
||||
static void yield();
|
||||
static void sleep(uint ms);
|
||||
|
||||
static void wait(Thread * threads, uint count);
|
||||
static void wait(Thread * threads, uint count);
|
||||
|
||||
private:
|
||||
|
||||
struct Private;
|
||||
AutoPtr<Private> p;
|
||||
struct Private;
|
||||
AutoPtr<Private> p;
|
||||
|
||||
public: // @@ Why public? Also in private?!
|
||||
ThreadFunc * func;
|
||||
|
@ -1,8 +1,8 @@
|
||||
// This code is in the public domain -- castano@gmail.com
|
||||
|
||||
#pragma once
|
||||
#ifndef NV_THREAD_THREADPOOL_H
|
||||
#define NV_THREAD_THREADPOOL_H
|
||||
// This code is in the public domain -- castano@gmail.com
|
||||
|
||||
#pragma once
|
||||
#ifndef NV_THREAD_THREADPOOL_H
|
||||
#define NV_THREAD_THREADPOOL_H
|
||||
|
||||
#include "nvthread.h"
|
||||
|
||||
|
@ -5,10 +5,10 @@
|
||||
#include "Thread.h"
|
||||
|
||||
#if NV_OS_WIN32
|
||||
#include "Win32.h"
|
||||
#include "Win32.h"
|
||||
#elif NV_OS_UNIX
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
|
||||
@ -40,12 +40,12 @@ uint nv::hardwareThreadCount() {
|
||||
sysctl(mib, 2, &numCPU, &len, NULL, 0);
|
||||
|
||||
if (numCPU < 1) {
|
||||
mib[1] = HW_NCPU;
|
||||
sysctl( mib, 2, &numCPU, &len, NULL, 0 );
|
||||
mib[1] = HW_NCPU;
|
||||
sysctl( mib, 2, &numCPU, &len, NULL, 0 );
|
||||
|
||||
if (numCPU < 1) {
|
||||
return 1; // Assume single core.
|
||||
}
|
||||
if (numCPU < 1) {
|
||||
return 1; // Assume single core.
|
||||
}
|
||||
}
|
||||
|
||||
return numCPU;
|
||||
|
Reference in New Issue
Block a user