a implementation of template class that is used for create event-driven task thread.

Revision:
1:7d11951c1fc0
Parent:
0:1f4516e81c1b
--- a/Actor.cpp	Wed May 20 08:11:04 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-#include "Actor.h"
-
-Actor::Actor() :
-    thread(&Actor::threadKicker, this, osPriorityNormal, STACK_SIZE)
-{
-    thread.signal_set(START_THREAD);
-}
-
-Actor::~Actor()
-{
-}
-
-void Actor::threadMain()
-{
-    printf("thread main\n");
-    osEvent event;
-    while(true) {
-        event = mbox.get();
-        if (event.status == osEventMail) {
-            MailPacket *mail = (MailPacket*)event.value.p;
-            if (joblist[mail->messageId] != NULL) {
-                joblist[mail->messageId](mail->packet);
-            }
-            mbox.free(mail);
-        }
-    }
-}
-
-void Actor::subscribe(MessageID msg, void(*task)(void *))
-{
-    printf("subsc\n");
-    joblist[msg] = task;
-}
-
-void Actor::unsubscribe(MessageID msg)
-{
-    printf("unsub\n");
-    joblist.erase(msg);
-}
-
-void Actor::sendMail(Actor *dest, MessageID msg, void *pkt)
-{
-    printf("sendMail\n");
-    MailPacket *mail = dest->mbox.alloc();
-    mail->messageId  = msg;
-    mail->packet     = pkt;
-    dest->mbox.put(mail);
-}
-
-void Actor::threadKicker(void const *p)
-{
-    printf("thread kicker\n");
-    Actor *instance = (Actor*)p;
-    instance->threadMain();
-}