From ac6b9e4eb702b71c2371c07aa24f1249ead302f5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Anna-Sophia=20Schr=C3=B6ck?= <pba3h11aso@t-online.de>
Date: Mon, 26 Nov 2018 17:11:48 +0100
Subject: [PATCH] rename *sleep to mn_*sleep

---
 example/BasicExample/__main.cpp |  4 +++-
 example/HelloWorld/__main.cpp   |  4 +++-
 src/mn-sleep.cpp                |  6 +++---
 src/mn-sleep.h                  |  6 +++---
 src/mn-thread.cpp               |  4 +++-
 src/mn-thread.h                 | 10 +++++-----
 6 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/example/BasicExample/__main.cpp b/example/BasicExample/__main.cpp
index 584e21c..478e66b 100644
--- a/example/BasicExample/__main.cpp
+++ b/example/BasicExample/__main.cpp
@@ -8,6 +8,8 @@ public:
   basic_task() : mthread("basic_task", 5, 2048) { }
 
   virtual void*         on_thread() {
+    mthread::on_thread();
+
     int id = get_id();
     int core = get_on_core();
 
@@ -25,7 +27,7 @@ extern "C" void app_main() {
     printf("Thank you for using libmnthread version: %s\n",
             libmn_version.to_string().c_str());
 
-    sleep(3);
+    mn_sleep(3);
     basic_task basic_task;
     basic_task.create(TASk_ON_CPU);
 
diff --git a/example/HelloWorld/__main.cpp b/example/HelloWorld/__main.cpp
index 623a9fc..4fb3db1 100644
--- a/example/HelloWorld/__main.cpp
+++ b/example/HelloWorld/__main.cpp
@@ -6,6 +6,8 @@ public:
   helloWorld_task() : mthread("hello_task", 5, 2048) { k = 0;}
 
   virtual void*         on_thread() {
+    mthread::on_thread();
+    
     int id = get_id();
     int core = get_on_core();
 
@@ -24,7 +26,7 @@ extern "C" void app_main() {
     printf("Thank you for using libmnthread version: %s\n",
             libmn_version.to_string().c_str());
 
-    sleep(3);
+    mn_sleep(3);
     helloWorld_task __test[10];
     for(int i=0; i < 10; i++) {
       __test[i].create(i % 2);
diff --git a/src/mn-sleep.cpp b/src/mn-sleep.cpp
index 4602f4e..4a9670d 100644
--- a/src/mn-sleep.cpp
+++ b/src/mn-sleep.cpp
@@ -16,16 +16,16 @@
 
 
 
-unsigned sleep(unsigned int secs) {
+unsigned mn_sleep(unsigned int secs) {
 	vTaskDelay( (secs * 1000) / ((TickType_t) 1000 / configTICK_RATE_HZ));
 	return 0;
 }
-int usleep(useconds_t usec) {
+int mn_usleep(useconds_t usec) {
 	vTaskDelay(usec / ((TickType_t) 1000000 / configTICK_RATE_HZ));
 	return 0;
 }
 
-int IRAM_ATTR nsleep(const struct timespec *req, struct timespec *rem) {
+int IRAM_ATTR mn_nsleep(const struct timespec *req, struct timespec *rem) {
 	struct timeval start, end;
 
 	if ((req->tv_nsec < 0) || (req->tv_nsec > 999999999)) {
diff --git a/src/mn-sleep.h b/src/mn-sleep.h
index 2d84217..e2d187c 100644
--- a/src/mn-sleep.h
+++ b/src/mn-sleep.h
@@ -11,9 +11,9 @@
 #include <sys/signal.h>
 
 
-unsigned sleep(unsigned int secs);
-int usleep(useconds_t usec);
+unsigned mn_sleep(unsigned int secs);
+int mn_usleep(useconds_t usec);
 
-int nsleep(const struct timespec *req, struct timespec *rem);
+int mn_nsleep(const struct timespec *req, struct timespec *rem);
 
 #endif
diff --git a/src/mn-thread.cpp b/src/mn-thread.cpp
index 6c520b3..6ac67cc 100644
--- a/src/mn-thread.cpp
+++ b/src/mn-thread.cpp
@@ -182,7 +182,9 @@ void basic_thread::runtaskstub(void* parm) {
 
   esp_thread->m_runningMutex->unlock();
 }
-
+void basic_thread::thread_started() {
+  m_continuemutex2->unlock();
+}
 uint32_t __internal_id_base__ = 0;
 
 uint32_t basic_thread::get_new_id() {
diff --git a/src/mn-thread.h b/src/mn-thread.h
index 71ca6f0..bc74b0b 100644
--- a/src/mn-thread.h
+++ b/src/mn-thread.h
@@ -27,7 +27,6 @@ public:
   int                   create(int uiCore = -1);
   int                   kill();
 
-
   bool                  is_running();
 
   const char*           get_name();
@@ -44,7 +43,7 @@ public:
   void                  suspend();
   void                  resume();
 
-  virtual void*         on_thread() { return NULL; }
+  virtual void*         on_thread() { thread_started(); return NULL; }
 
   basic_thread*         get_root();
   basic_thread*         get_child();
@@ -54,16 +53,17 @@ public:
   static void suspend(basic_thread *t)  { t->suspend(); }
   static void resume(basic_thread *t)   {   t->resume(); }
   static void yield()                   { taskYIELD(); }
-  static void sleep(unsigned int secs)     { ::sleep(secs); }
-  static void usleep(unsigned int usec)     { ::usleep(usec); }
+  static void sleep(unsigned int secs)     { ::mn_sleep(secs); }
+  static void usleep(unsigned int usec)     { ::mn_usleep(usec); }
   static void nsleep(const struct timespec *req, struct timespec *rem)     {
-    ::nsleep(req, rem);
+    ::mn_nsleep(req, rem);
   }
 
   static void lock(basic_thread * t)    { t->m_runningMutex->lock(); }
   static void unlock(basic_thread * t)    { t->m_runningMutex->unlock(); }
 protected:
   static void runtaskstub(void* parm);
+	void thread_started();
 private:
   static uint32_t get_new_id();
 protected:
-- 
GitLab