[DEV] update etk null
This commit is contained in:
parent
8ee819a6e1
commit
9902ff0e2d
@ -16,7 +16,7 @@ ethread::Future::Future(ememory::SharedPtr<ethread::Promise> _promise):
|
||||
}
|
||||
|
||||
bool ethread::Future::isFinished() {
|
||||
if (m_promise == nullptr) {
|
||||
if (m_promise == null) {
|
||||
ETHREAD_ERROR("Promise does not exist...");
|
||||
return true;
|
||||
}
|
||||
@ -24,7 +24,7 @@ bool ethread::Future::isFinished() {
|
||||
}
|
||||
|
||||
bool ethread::Future::wait(echrono::Duration _delay) {
|
||||
if (m_promise == nullptr) {
|
||||
if (m_promise == null) {
|
||||
ETHREAD_ERROR("Promise does not exist...");
|
||||
return false;
|
||||
}
|
||||
@ -32,7 +32,7 @@ bool ethread::Future::wait(echrono::Duration _delay) {
|
||||
}
|
||||
|
||||
void ethread::Future::andThen(etk::Function<void()> _action) {
|
||||
if (m_promise == nullptr) {
|
||||
if (m_promise == null) {
|
||||
ETHREAD_ERROR("Promise does not exist...");
|
||||
return;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace ethread {
|
||||
* @brief Simple Future contructor
|
||||
* @param[in] _promise Associated promise to wait
|
||||
*/
|
||||
Future(ememory::SharedPtr<ethread::Promise> _promise=nullptr);
|
||||
Future(ememory::SharedPtr<ethread::Promise> _promise=null);
|
||||
/**
|
||||
* @brief Check if the action is finished
|
||||
* @return true, the action is done, false otherwise
|
||||
|
@ -17,7 +17,7 @@ ETK_DECLARE_TYPE(ethread::UniqueLock);
|
||||
|
||||
ethread::Mutex::Mutex() {
|
||||
// create interface mutex :
|
||||
int ret = pthread_mutex_init(&m_mutex, nullptr);
|
||||
int ret = pthread_mutex_init(&m_mutex, null);
|
||||
//ETHREAD_ASSERT(ret == 0, "Error creating Mutex ...");
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ ethread::Pool::Pool(uint16_t _numberOfThread):
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
for (uint32_t iii=0; iii<_numberOfThread; ++iii) {
|
||||
ememory::SharedPtr<ethread::PoolExecutor> tmp = ememory::makeShared<ethread::PoolExecutor>(*this);
|
||||
if (tmp != nullptr) {
|
||||
if (tmp != null) {
|
||||
tmp->start();
|
||||
m_listThread.pushBack(tmp);
|
||||
}
|
||||
@ -34,7 +34,7 @@ uint32_t ethread::Pool::createGroupId() {
|
||||
|
||||
ethread::Future ethread::Pool::async(etk::Function<void()> _call, uint64_t _executionInGroupId) {
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
if (_call == nullptr) {
|
||||
if (_call == null) {
|
||||
ETHREAD_ERROR("Can not add an action with no function to call...");
|
||||
return ethread::Future();
|
||||
}
|
||||
@ -42,7 +42,7 @@ ethread::Future ethread::Pool::async(etk::Function<void()> _call, uint64_t _exec
|
||||
ememory::SharedPtr<ethread::PoolAction> action = ememory::makeShared<ethread::PoolAction>(_executionInGroupId, promise, _call);
|
||||
m_listActions.pushBack(action);
|
||||
for(auto &it : m_listThread) {
|
||||
if (it == nullptr) {
|
||||
if (it == null) {
|
||||
continue;
|
||||
}
|
||||
if (it->touch() == true) {
|
||||
@ -73,7 +73,7 @@ ememory::SharedPtr<ethread::PoolAction> ethread::Pool::getAction() {
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
auto it = m_listActions.begin();
|
||||
while (it != m_listActions.end()) {
|
||||
if (*it == nullptr) {
|
||||
if (*it == null) {
|
||||
it = m_listActions.erase(it);
|
||||
continue;
|
||||
}
|
||||
@ -98,7 +98,7 @@ ememory::SharedPtr<ethread::PoolAction> ethread::Pool::getAction() {
|
||||
}
|
||||
++it;
|
||||
}
|
||||
return nullptr;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@ void ethread::Pool::stop() {
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
auto it = m_listThread.begin();
|
||||
while (it != m_listThread.end()) {
|
||||
if (*it == nullptr) {
|
||||
if (*it == null) {
|
||||
it = m_listThread.erase(it);
|
||||
continue;
|
||||
}
|
||||
@ -120,7 +120,7 @@ void ethread::Pool::join() {
|
||||
ETHREAD_DEBUG("start join all the threads in pool " << m_listThread.size());
|
||||
for (size_t iii=0; iii<m_listThread.size(); ++iii) {
|
||||
ETHREAD_DEBUG(" join " << iii);
|
||||
if (m_listThread[iii] == nullptr) {
|
||||
if (m_listThread[iii] == null) {
|
||||
continue;
|
||||
}
|
||||
m_listThread[iii]->join();
|
||||
|
@ -21,13 +21,13 @@ uint64_t ethread::PoolAction::getPoolId() const {
|
||||
}
|
||||
|
||||
void ethread::PoolAction::call() {
|
||||
if (m_call == nullptr) {
|
||||
if (m_call == null) {
|
||||
return;
|
||||
}
|
||||
if (m_call != nullptr) {
|
||||
if (m_call != null) {
|
||||
m_call();
|
||||
}
|
||||
if (m_promise != nullptr) {
|
||||
if (m_promise != null) {
|
||||
m_promise->finish();
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ void ethread::PoolExecutor::threadCallback() {
|
||||
while (m_running == true) {
|
||||
// get an action:
|
||||
m_action = m_pool.getAction();
|
||||
if (m_action == nullptr) {
|
||||
if (m_action == null) {
|
||||
// If no action availlable and not requested to check, just sleep ...
|
||||
if (m_needProcess == false) {
|
||||
m_isWaiting = true;
|
||||
@ -57,7 +57,7 @@ void ethread::PoolExecutor::start() {
|
||||
m_running = true;
|
||||
m_semaphore.post();
|
||||
m_thread = ememory::makeShared<ethread::Thread>([&](){ threadCallback();});
|
||||
if (m_thread == nullptr) {
|
||||
if (m_thread == null) {
|
||||
m_running = false;
|
||||
ETHREAD_ERROR("START: thread in Pool [STOP] can not intanciate THREAD!");
|
||||
return;
|
||||
@ -76,7 +76,7 @@ void ethread::PoolExecutor::stop() {
|
||||
void ethread::PoolExecutor::join() {
|
||||
ETHREAD_DEBUG("JOIN: thread in Pool [START]");
|
||||
m_semaphore.post();
|
||||
if (m_thread != nullptr) {
|
||||
if (m_thread != null) {
|
||||
ETHREAD_DEBUG("JOIN: waiting ...");
|
||||
m_thread->join();
|
||||
m_thread.reset();
|
||||
|
@ -30,12 +30,12 @@ void ethread::Promise::finish() {
|
||||
return;
|
||||
}
|
||||
m_isFinished = true;
|
||||
if (m_callback != nullptr) {
|
||||
if (m_callback != null) {
|
||||
// call callbacks ...
|
||||
callback = etk::move(m_callback);
|
||||
}
|
||||
}
|
||||
if (callback != nullptr) {
|
||||
if (callback != null) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ ETK_DECLARE_TYPE(ethread::Semaphore);
|
||||
|
||||
etk::Semaphore::Semaphore(uint32_t _nbBasicElement, uint32_t _nbMessageMax) {
|
||||
// create interface mutex :
|
||||
m_semaphore = CreateSemaphore(nullptr, _nbBasicElement, _nbMessageMax, nullptr);
|
||||
m_semaphore = CreateSemaphore(null, _nbBasicElement, _nbMessageMax, null);
|
||||
TK_ASSERT(m_semaphore != 0, "Error creating SEMAPHORE ...");
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ uint32_t etk::Semaphore::getCount() {
|
||||
}
|
||||
|
||||
void etk::Semaphore::post() {
|
||||
ReleaseSemaphore(m_semaphore, 1, nullptr);
|
||||
ReleaseSemaphore(m_semaphore, 1, null);
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,10 +12,10 @@ ETK_DECLARE_TYPE(ethread::Semaphore);
|
||||
|
||||
ethread::Semaphore::Semaphore(uint32_t _nbBasicElement, uint32_t _nbMessageMax) {
|
||||
// create interface mutex :
|
||||
int ret = pthread_mutex_init(&m_mutex, nullptr);
|
||||
int ret = pthread_mutex_init(&m_mutex, null);
|
||||
//TK_ASSERT(ret == 0, "Error creating Mutex ...");
|
||||
// create contition :
|
||||
ret = pthread_cond_init(&m_condition, nullptr);
|
||||
ret = pthread_cond_init(&m_condition, null);
|
||||
//TK_ASSERT(ret == 0, "Error creating Condition ...");
|
||||
if (ret != 0) {
|
||||
ret = pthread_mutex_destroy(&m_mutex);
|
||||
@ -71,7 +71,7 @@ bool ethread::Semaphore::wait(uint64_t _timeOutInUs) {
|
||||
if(m_data == 0) {
|
||||
struct timeval tp;
|
||||
struct timespec ts;
|
||||
gettimeofday(&tp, nullptr);
|
||||
gettimeofday(&tp, null);
|
||||
uint64_t totalTimeUS = tp.tv_sec * 1000000 + tp.tv_usec;
|
||||
totalTimeUS += _timeOutInUs;
|
||||
ts.tv_sec = totalTimeUS / 1000000;
|
||||
|
@ -17,10 +17,10 @@ namespace ethread {
|
||||
|
||||
void* ethread::Thread::threadCallback(void* _userData) {
|
||||
ethread::Thread* threadHandle = static_cast<ethread::Thread*>(_userData);
|
||||
if (threadHandle != nullptr) {
|
||||
if (threadHandle != null) {
|
||||
threadHandle->threadCall();
|
||||
}
|
||||
return nullptr;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ ethread::Thread::Thread(etk::Function<void()>&& _call, const etk::String& _name)
|
||||
m_name(_name),
|
||||
m_function(etk::move(_call)) {
|
||||
uint32_t iii = ethread::getId();
|
||||
pthread_create(&m_thread, nullptr, ðread::Thread::threadCallback, this);
|
||||
pthread_create(&m_thread, null, ðread::Thread::threadCallback, this);
|
||||
m_uid = ethread::getThreadHumanId(uint64_t(m_thread));
|
||||
printf("New thread: %ld from %d\n", m_uid, iii);
|
||||
}
|
||||
@ -40,7 +40,7 @@ ethread::Thread::~Thread() {
|
||||
}
|
||||
|
||||
void ethread::Thread::join() {
|
||||
void* ret = nullptr;
|
||||
void* ret = null;
|
||||
int val = pthread_join(m_thread, &ret);
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ const etk::String& ethread::Thread::getName() const {
|
||||
}
|
||||
|
||||
void ethread::Thread::threadCall() {
|
||||
if (m_function != nullptr) {
|
||||
if (m_function != null) {
|
||||
m_function();
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ namespace ethread {
|
||||
) \
|
||||
&& !defined(__TARGET_OS__Web)
|
||||
pthread_t pthreadID;
|
||||
if (_thread == nullptr) {
|
||||
if (_thread == null) {
|
||||
pthreadID = pthread_self();
|
||||
} else {
|
||||
pthreadID = _thread->getNativeHandle();
|
||||
@ -99,7 +99,7 @@ uint32_t ethread::getId(ethread::Thread& _thread) {
|
||||
}
|
||||
|
||||
void ethread::setName(const etk::String& _name) {
|
||||
setThreadName(nullptr, _name);
|
||||
setThreadName(null, _name);
|
||||
}
|
||||
|
||||
void ethread::setName(ethread::Thread& _thread, const etk::String& _name) {
|
||||
|
Loading…
Reference in New Issue
Block a user