mirror of
https://github.com/eclipse/paho.mqtt-sn.embedded-c.git
synced 2025-12-16 17:06:51 +01:00
Bugfix of Handling Exception #236
Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
@@ -135,7 +135,7 @@ void Mutex::lock(void)
|
||||
}
|
||||
} catch (char* errmsg)
|
||||
{
|
||||
throw Exception( -1, "The same thread can't aquire a mutex twice.");
|
||||
throw Exception( -1, "The same thread can't acquire a mutex twice.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -263,11 +263,6 @@ void NamedSemaphore::timedwait(uint16_t millsec)
|
||||
/*=========================================
|
||||
Class RingBuffer
|
||||
=========================================*/
|
||||
RingBuffer::RingBuffer()
|
||||
{
|
||||
RingBuffer(MQTTSNGW_KEY_DIRECTORY);
|
||||
}
|
||||
|
||||
RingBuffer::RingBuffer(const char* keyDirectory)
|
||||
{
|
||||
int fp = 0;
|
||||
@@ -506,6 +501,7 @@ void RingBuffer::reset()
|
||||
Thread::Thread()
|
||||
{
|
||||
_threadID = 0;
|
||||
_taskName = nullptr;
|
||||
}
|
||||
|
||||
Thread::~Thread()
|
||||
@@ -539,11 +535,6 @@ int Thread::start(void)
|
||||
return pthread_create(&_threadID, 0, _run, runnable);
|
||||
}
|
||||
|
||||
void Thread::stopProcess(void)
|
||||
{
|
||||
theMultiTaskProcess->threadStopped();
|
||||
}
|
||||
|
||||
void Thread::stop(void)
|
||||
{
|
||||
if ( _threadID )
|
||||
@@ -552,3 +543,13 @@ void Thread::stop(void)
|
||||
_threadID = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Thread::setTaskName(const char* name)
|
||||
{
|
||||
_taskName = name;
|
||||
}
|
||||
|
||||
const char* Thread::getTaskName(void)
|
||||
{
|
||||
return _taskName;
|
||||
}
|
||||
|
||||
@@ -92,8 +92,7 @@ private:
|
||||
class RingBuffer
|
||||
{
|
||||
public:
|
||||
RingBuffer();
|
||||
RingBuffer(const char* keyDirctory);
|
||||
RingBuffer(const char* keyDirctory = MQTTSNGW_KEY_DIRECTORY);
|
||||
~RingBuffer();
|
||||
void put(char* buffer);
|
||||
int get(char* buffer, int bufferLength);
|
||||
@@ -124,15 +123,17 @@ public:
|
||||
#define MAGIC_WORD_FOR_THREAD \
|
||||
public: void EXECRUN() \
|
||||
{ \
|
||||
try \
|
||||
{ \
|
||||
run(); \
|
||||
stopProcess(); \
|
||||
} \
|
||||
catch(...) \
|
||||
{ \
|
||||
throw; \
|
||||
} \
|
||||
try \
|
||||
{ \
|
||||
run(); \
|
||||
theMultiTaskProcess->threadStopped(); \
|
||||
} \
|
||||
catch ( Exception &ex ) \
|
||||
{ \
|
||||
theMultiTaskProcess->threadStopped(); \
|
||||
WRITELOG("%s catch exception\n", getTaskName()); \
|
||||
ex.writeMessage(); \
|
||||
} \
|
||||
}
|
||||
|
||||
/*=====================================
|
||||
@@ -146,12 +147,14 @@ public:
|
||||
static pthread_t getID();
|
||||
static bool equals(pthread_t*, pthread_t*);
|
||||
virtual void initialize(int argc, char** argv);
|
||||
void stopProcess(void);
|
||||
void waitStop(void);
|
||||
void stop(void);
|
||||
const char* getTaskName(void);
|
||||
void setTaskName(const char* name);
|
||||
private:
|
||||
static void* _run(void*);
|
||||
pthread_t _threadID;
|
||||
const char* _taskName;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user