summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2019-07-28 09:51:25 +0800
committerGitHub <[email protected]>2019-07-28 09:51:25 +0800
commit388a293a277e98e1f499be4626f47b6d455c9aba (patch)
tree2aca035e7e1f2a195e5cf0cd58e075eaf99e3b0c /components
parent6c15b1856f784d93a271c1f28025a7ce3d19967b (diff)
parent85a9f5add9fd54b3917cfca2a8555c6525df0538 (diff)
Merge pull request #2902 from tyustli/fix_cpp
fix bug in Thread.cpp/Thread.h/components.c files
Diffstat (limited to 'components')
-rw-r--r--components/cplusplus/Thread.cpp16
-rw-r--r--components/cplusplus/Thread.h7
2 files changed, 13 insertions, 10 deletions
diff --git a/components/cplusplus/Thread.cpp b/components/cplusplus/Thread.cpp
index 9b2a2ad5e0..b21fbdce1f 100644
--- a/components/cplusplus/Thread.cpp
+++ b/components/cplusplus/Thread.cpp
@@ -80,23 +80,23 @@ void Thread::func(Thread *pThis)
}
else
{
- pThis->run();
+ pThis->run(pThis->_param);
}
rt_event_send(&pThis->_event, 1);
}
-void Thread::run()
+void Thread::run(void *parameter)
{
/* please overload this method */
}
-void Thread::wait(int32_t millisec)
+rt_err_t Thread::wait(int32_t millisec)
{
- join(millisec);
+ return join(millisec);
}
-void Thread::join(int32_t millisec)
+rt_err_t Thread::join(int32_t millisec)
{
if (started)
{
@@ -107,6 +107,10 @@ void Thread::join(int32_t millisec)
else
tick = rt_tick_from_millisecond(millisec);
- rt_event_recv(&_event, 1, RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, tick, RT_NULL);
+ return rt_event_recv(&_event, 1, RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, tick, RT_NULL);
+ }
+ else
+ {
+ return -RT_ENOSYS;
}
}
diff --git a/components/cplusplus/Thread.h b/components/cplusplus/Thread.h
index 71ee50e1f9..b578659489 100644
--- a/components/cplusplus/Thread.h
+++ b/components/cplusplus/Thread.h
@@ -45,16 +45,15 @@ public:
static void sleep(int32_t millisec);
- void wait(int32_t millisec);
- void join(int32_t millisec = -1);
+ rt_err_t wait(int32_t millisec);
+ rt_err_t join(int32_t millisec = -1);
protected:
- virtual void run();
+ virtual void run(void *parameter);
private:
static void func(Thread *pThis);
-private:
rt_thread_t _thread;
thread_func_t _entry;