asycxx-devel Mailing List for Asynchronous C++ Application framework
Status: Alpha
Brought to you by:
joe_steeve
You can subscribe to this list here.
| 2009 |
Jan
|
Feb
(16) |
Mar
(27) |
Apr
(44) |
May
(3) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|---|
|
From: <joe...@us...> - 2009-06-16 06:12:21
|
Revision: 66
http://asycxx.svn.sourceforge.net/asycxx/?rev=66&view=rev
Author: joe_steeve
Date: 2009-06-16 06:12:17 +0000 (Tue, 16 Jun 2009)
Log Message:
-----------
Release 0.2.1
Added Paths:
-----------
tags/releases/0.2.1/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <joe...@us...> - 2009-06-16 06:05:17
|
Revision: 64
http://asycxx.svn.sourceforge.net/asycxx/?rev=64&view=rev
Author: joe_steeve
Date: 2009-06-16 06:05:16 +0000 (Tue, 16 Jun 2009)
Log Message:
-----------
Release 0.2
* refactor of reactor registration mechanism.
* removed half-baked deferred implementation.
* now we have support to add Datagram based protocols
Added Paths:
-----------
tags/releases/0.2/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Joe S. <js...@hi...> - 2009-05-11 18:15:04
|
On Sun, 2009-05-10 at 22:19 +0530, Karthik Balakrishnan wrote: > Please provide me details on how to get asycxx source tested locally > and any other details I should be aware of. Build asycxx and check out the example apps. -- Joe Steeve HiPro IT Solutions Pvt. Ltd. http://hipro.co.in/ |
|
From: Karthik B. <ka...@hi...> - 2009-05-10 17:13:51
|
Guys, Please provide me details on how to get asycxx source tested locally and any other details I should be aware of. -- Karthik HiPro IT Solutions Pvt. Ltd. http://hipro.co.in/ |
|
From: <fj...@us...> - 2009-05-04 14:29:09
|
Revision: 63
http://asycxx.svn.sourceforge.net/asycxx/?rev=63&view=rev
Author: fjosh
Date: 2009-05-04 14:29:08 +0000 (Mon, 04 May 2009)
Log Message:
-----------
Fixed amd64 build issues
Modified Paths:
--------------
trunk/include/asycxx/RawCANTransport.h
trunk/src/DataBuffer.cxx
trunk/src/GimpleMsgBus.cxx
Modified: trunk/include/asycxx/RawCANTransport.h
===================================================================
--- trunk/include/asycxx/RawCANTransport.h 2009-04-25 10:23:03 UTC (rev 62)
+++ trunk/include/asycxx/RawCANTransport.h 2009-05-04 14:29:08 UTC (rev 63)
@@ -14,6 +14,7 @@
#ifndef __HIPRO_ASYCXX__CAN_TRANSPORT_H__
#define __HIPRO_ASYCXX__CAN_TRANSPORT_H__
+#include <stdint.h>
#include "Error.h"
#include "Reactor.h"
Modified: trunk/src/DataBuffer.cxx
===================================================================
--- trunk/src/DataBuffer.cxx 2009-04-25 10:23:03 UTC (rev 62)
+++ trunk/src/DataBuffer.cxx 2009-05-04 14:29:08 UTC (rev 63)
@@ -141,7 +141,7 @@
if (m_ProcessedLen == m_DataLen) { return NULL; }
/* compute the new pointer and return it */
- ptr = (void *)((unsigned int)m_Data + m_ProcessedLen);
+ ptr = (void *)((unsigned char *)m_Data + m_ProcessedLen);
return ptr;
}
Modified: trunk/src/GimpleMsgBus.cxx
===================================================================
--- trunk/src/GimpleMsgBus.cxx 2009-04-25 10:23:03 UTC (rev 62)
+++ trunk/src/GimpleMsgBus.cxx 2009-05-04 14:29:08 UTC (rev 63)
@@ -89,7 +89,7 @@
getTransport()->loseConnection ();
return;
}
- data_ptr = (void *)((unsigned int)data_ptr + processed);
+ data_ptr = (void *)((unsigned char *)data_ptr + processed);
dleft -= processed;
break;
@@ -100,7 +100,7 @@
getTransport()->loseConnection ();
return;
}
- data_ptr = (void *)((unsigned int)data_ptr + processed);
+ data_ptr = (void *)((unsigned char *)data_ptr + processed);
dleft -= processed;
break;
};
@@ -130,7 +130,7 @@
else { to_copy = m_Hdr_left; }
/* setup the pointers and do the copy */
- dptr = (void *)((unsigned int)&m_Hdr + m_Hdr_filled);
+ dptr = (void *)((unsigned char *)&m_Hdr + m_Hdr_filled);
memcpy (dptr, data_ptr, to_copy);
m_Hdr_filled += to_copy;
@@ -148,7 +148,7 @@
if (memcmp ((void *)&sign, (void *)&m_Hdr.signature, 4) != 0)
{
processed = 0;
- ERR ("bad signature in header '%c', '%c', '%c', %c", m_Hdr.signature[0],
+ ERR ("bad signature in header '%c','%c','%c',%c", m_Hdr.signature[0],
m_Hdr.signature[1], m_Hdr.signature[2], m_Hdr.signature[3]);
return RetCode_Error;
}
@@ -189,7 +189,7 @@
else { to_copy = m_Payload_left; }
/* setup the pointers and do the copy */
- dptr = (void *)((unsigned int)m_Payload->Data() + m_Payload_filled);
+ dptr = (void *)((unsigned char *)m_Payload->Data() + m_Payload_filled);
memcpy (dptr, data_ptr, to_copy);
m_Payload_filled += to_copy;
@@ -235,7 +235,8 @@
pkt->Len (pkt_len);
GMBPacketHdr_s *pktHdr = (GMBPacketHdr_s *) pkt->Data();
- void *data = (void *)((unsigned int)pktHdr + sizeof (struct GMBPacketHdr_s));
+ void *data = (void *)((unsigned char *)pktHdr +
+ sizeof(struct GMBPacketHdr_s));
/* construct the packet */
pktHdr->signature[0] = 'G';
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <viv...@us...> - 2009-04-25 10:23:18
|
Revision: 62
http://asycxx.svn.sourceforge.net/asycxx/?rev=62&view=rev
Author: vivekanand83
Date: 2009-04-25 10:23:03 +0000 (Sat, 25 Apr 2009)
Log Message:
-----------
Impelented 'Call in Reactor' for Thread.
Modified Paths:
--------------
trunk/examples/threadtest/Threadtest.cxx
trunk/include/asycxx/Thread.h
trunk/src/Thread.cxx
Modified: trunk/examples/threadtest/Threadtest.cxx
===================================================================
--- trunk/examples/threadtest/Threadtest.cxx 2009-04-22 13:40:03 UTC (rev 61)
+++ trunk/examples/threadtest/Threadtest.cxx 2009-04-25 10:23:03 UTC (rev 62)
@@ -27,12 +27,20 @@
Logger *Log;
-static DataBuffer* threadFunction(void *objthread, DataBuffer *obj)
+static void callInReatorFn(void *th_obj, DataBuffer *data)
{
- fprintf(stderr,"Thread function called!\n");
+ fprintf (stderr, "%s called\n", __FUNCTION__);
+}
+
+static DataBuffer* threadFunction(void *thmain_obj,void *objthread, DataBuffer *obj)
+{
+ fprintf(stderr,"Thread function called!\n");
+ Thread *mainThread = (Thread*)thmain_obj;
+ mainThread->CallInReactor(mainThread, &callInReatorFn, NULL);
return NULL;
}
+
static void CallbackFunc(void *obj, DataBuffer *param)
{
fprintf(stderr,"CallBack function called.\n");
Modified: trunk/include/asycxx/Thread.h
===================================================================
--- trunk/include/asycxx/Thread.h 2009-04-22 13:40:03 UTC (rev 61)
+++ trunk/include/asycxx/Thread.h 2009-04-25 10:23:03 UTC (rev 62)
@@ -27,14 +27,17 @@
namespace asycxx
{
- typedef DataBuffer* (*ThreadFunction_t)(void* obj, DataBuffer* param);
- typedef void (*CallbackFunction_t)(void* obj, DataBuffer *result);
-
+ typedef DataBuffer* (*ThreadFunction_t)(void *thmain_obj, void* obj,
+ DataBuffer* param);
+ typedef void (*CallbackFunction_t)(void* obj, DataBuffer *result);
+ typedef void (*CallInReactorFunction_t)(void *th_obj,
+ DataBuffer *data);
class Thread
{
enum ThreadStatus
{
ThreadComplete = 1,
+ ThreadCallInReactor,
ThreadKilled
};
@@ -44,6 +47,9 @@
CallbackFunction_t cb_fn, void *cb_obj);
pthread_t getThreadId(void) { return m_ThreadId; }
+ void CallInReactor(Thread *th_obj, CallInReactorFunction_t cir_fn,
+ DataBuffer *cir_param);
+ void HandleCallInReactor(void);
void Own (void) { m_Owned = true; }
void DisOwn (void);
@@ -89,7 +95,7 @@
private:
~Thread ();
- static void * ThreadFunction (void *obj);
+ static void* ThreadFunction_Main(void *obj);
pthread_t m_ThreadId;
int m_PipeFd[2];
@@ -99,6 +105,9 @@
CallbackFunction_t m_CB_Func;
void *m_CB_Obj;
+ CallInReactorFunction_t m_CIRFunc;
+ DataBuffer *m_CIR_Param;
+
DataBuffer *m_Thread_Param;
DataBuffer *m_Thread_Result;
@@ -107,7 +116,8 @@
StreamTransport *m_StreamTransport;
bool m_Owned;
- bool m_ThreadAlive;
+ bool m_ThreadAlive;
+ pthread_mutex_t m_CallInThreadMutex;
};
}
Modified: trunk/src/Thread.cxx
===================================================================
--- trunk/src/Thread.cxx 2009-04-22 13:40:03 UTC (rev 61)
+++ trunk/src/Thread.cxx 2009-04-25 10:23:03 UTC (rev 62)
@@ -66,9 +66,10 @@
/* by default we are owned by our owner */
m_Owned = true;
+ pthread_mutex_init(&m_CallInThreadMutex, NULL);
/* start the thread */
- ret = pthread_create(&m_ThreadId, NULL, ThreadFunction, (void *)this);
- ASSERT((ret == 0), "Thread creation failed");
+ ret = pthread_create(&m_ThreadId, NULL, ThreadFunction_Main, (void *)this);
+ ASSERT((ret == 0), "Thread creation failed %s", strerror(errno));
m_ThreadAlive = true;
}
@@ -90,9 +91,10 @@
m_Thread_Param->DisOwn();
}
- delete m_PipeProtocol;
- delete m_PipeProtocolFactory;
- delete m_StreamTransport;
+ LOG("Destroying thread");
+// delete m_PipeProtocol;
+// delete m_PipeProtocolFactory;
+// delete m_StreamTransport;
}
@@ -102,6 +104,7 @@
if (m_ThreadAlive == false)
{
/* we got no owners and thread is not around. So, just die */
+ m_StreamTransport->loseConnection();
delete this;
}
}
@@ -115,7 +118,7 @@
* failure, it will write the status to the pipe and quit.
*/
void*
-Thread::ThreadFunction (void *obj)
+Thread::ThreadFunction_Main (void *obj)
{
ASSERT((obj != NULL), "bad parameter");
@@ -124,7 +127,7 @@
ASSERT((pThis->m_Thread_Func != NULL), "badly constructed");
- pThis->m_Thread_Result = pThis->m_Thread_Func (pThis->m_Thread_Obj,
+ pThis->m_Thread_Result = pThis->m_Thread_Func (pThis,pThis->m_Thread_Obj,
pThis->m_Thread_Param);
if (pThis->m_Thread_Result != NULL)
@@ -132,13 +135,13 @@
pThis->m_Thread_Result->Own ();
}
- int status = ThreadComplete;
+ int status = ThreadComplete;
ret = write(pThis->m_PipeFd[1], &status, sizeof(ThreadStatus));
if (ret == -1)
- {
- ERR ("(THREAD-END) writing to pipe : %s", strerror(errno));
- }
-
+ {
+ ERR ("(THREAD-END) writing to pipe : %s", strerror(errno));
+ }
+
pthread_exit(0);
}
@@ -166,22 +169,29 @@
Thread::ThreadStatus *status = (ThreadStatus*)data->Data();
if (*status == Thread::ThreadComplete)
- {
- /* thread has completed */
- pthread_t threadId = m_Thread->getThreadId();
- pthread_join (threadId, NULL);
+ {
+ /* thread has completed */
+ pthread_t threadId = m_Thread->getThreadId();
+ pthread_join (threadId, NULL);
- /* Are we still owned? */
- if ((m_Thread->IsOwned() == true) && (m_Thread->m_CB_Func != NULL))
- {
- m_Thread->m_CB_Func (m_Thread->m_CB_Obj, m_Thread->m_Thread_Result);
- }
- }
+ /* Are we still owned? */
+ if ((m_Thread->IsOwned() == true) && (m_Thread->m_CB_Func != NULL))
+ {
+ m_Thread->m_CB_Func (m_Thread->m_CB_Obj, m_Thread->m_Thread_Result);
+ }
+ }
+ else if (*status == Thread::ThreadCallInReactor)
+ {
+ m_Thread->HandleCallInReactor();
+ return;
+ }
/* Do we have a owner? */
if (m_Thread->IsOwned() == false)
{
/* we just got to die :-S */
+ LOG("deleting thread");
+ m_Transport->loseConnection();
delete m_Thread;
}
@@ -190,7 +200,32 @@
m_Thread->m_ThreadAlive = false;
}
+void Thread::CallInReactor(Thread *thmain_obj, CallInReactorFunction_t cir_fn,
+ DataBuffer *cir_param)
+{
+ thmain_obj->m_CIRFunc = cir_fn;
+ thmain_obj->m_CIR_Param = cir_param;
+ pthread_mutex_lock(&thmain_obj->m_CallInThreadMutex);
+
+ int status = ThreadCallInReactor;
+ int ret = write(thmain_obj->m_PipeFd[1], &status, sizeof(ThreadStatus));
+ if (ret == -1)
+ {
+ ERR ("(THREAD-END) writing to pipe : %s", strerror(errno));
+ }
+
+ pthread_mutex_lock(&thmain_obj->m_CallInThreadMutex);
+ pthread_mutex_unlock(&thmain_obj->m_CallInThreadMutex);
+ return;
+}
+void Thread::HandleCallInReactor(void)
+{
+ m_CIRFunc(m_Thread_Obj, m_CIR_Param);
+ pthread_mutex_unlock(&m_CallInThreadMutex);
+}
+
+
/*
Local Variables:
mode: c++
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <joe...@us...> - 2009-04-22 14:23:48
|
Revision: 60
http://asycxx.svn.sourceforge.net/asycxx/?rev=60&view=rev
Author: joe_steeve
Date: 2009-04-22 13:39:32 +0000 (Wed, 22 Apr 2009)
Log Message:
-----------
minor cleanup and refactor of Thread.*
From: Joe Steeve <js...@hi...>
Modified Paths:
--------------
trunk/include/asycxx/Thread.h
trunk/src/Thread.cxx
Modified: trunk/include/asycxx/Thread.h
===================================================================
--- trunk/include/asycxx/Thread.h 2009-04-22 13:38:53 UTC (rev 59)
+++ trunk/include/asycxx/Thread.h 2009-04-22 13:39:32 UTC (rev 60)
@@ -17,92 +17,107 @@
#include <unistd.h>
#include <errno.h>
#include <string.h>
+#include <pthread.h>
#include "Error.h"
#include "StreamTransport.h"
#include "StreamProtocol.h"
#include "StreamProtocolFactory.h"
+#include "DataBuffer.h"
namespace asycxx
{
- typedef DataBuffer* (*ThreadFunction_t)(void* objThread, DataBuffer* obj);
- typedef void (*CallbackFunction_t)(void* obj, DataBuffer *param);
+ typedef DataBuffer* (*ThreadFunction_t)(void* obj, DataBuffer* param);
+ typedef void (*CallbackFunction_t)(void* obj, DataBuffer *result);
class Thread
{
enum ThreadStatus
+ {
+ ThreadComplete = 1,
+ ThreadKilled
+ };
+
+ public:
+ Thread(Reactor *reactor,
+ ThreadFunction_t th_fn, void *th_obj, DataBuffer *th_param,
+ CallbackFunction_t cb_fn, void *cb_obj);
+
+ pthread_t getThreadId(void) { return m_ThreadId; }
+
+ void Own (void) { m_Owned = true; }
+ void DisOwn (void);
+ bool IsOwned (void) { return m_Owned; }
+
+ private:
+ // PipeProtocol class
+ class PipeProtocol: public StreamProtocol
{
- ThreadComplete = 0,
- ThreadKilled
+ public:
+ PipeProtocol (Reactor *reactor, StreamProtocolFactory *factory,
+ StreamTransport *transport, Thread *thread);
+ virtual ~PipeProtocol () {}
+
+ virtual StreamTransport* GetTransport (void) { return m_Transport; }
+ virtual void DataAvailable (DataBuffer *data);
+
+ private:
+ Thread *m_Thread;
+ StreamTransport * m_Transport;
};
+ //PipeProtocolFactory class
+ class PipeProtocolFactory: public StreamProtocolFactory
+ {
public:
- Thread(Reactor *reactor, ThreadFunction_t thread_fn,
- void *objThread, DataBuffer *data,
- CallbackFunction_t cb_fn,
- void *objCB);
- pthread_t getThreadId(void) { return m_ThreadId; }
+ PipeProtocolFactory (Reactor *reactor, Thread *thread)
+ : StreamProtocolFactory (reactor)
+ {
+ m_Thread = thread;
+ }
+ ~PipeProtocolFactory () {}
- void SetKill(){ m_KillThread = true; }
- bool IsKillThreadSet() { return m_KillThread; }
- void Die();
+ PipeProtocol *GetProtocol (StreamTransport *trans)
+ {
+ return new PipeProtocol (m_Reactor, this, trans, m_Thread);
+ }
private:
- // PipeProtocol class
- class PipeProtocol: public StreamProtocol
- {
- public:
- PipeProtocol (Reactor *reactor,StreamProtocolFactory *factory,
- StreamTransport *transport, Thread *pthis);
+ Thread *m_Thread;
+ };
- virtual ~PipeProtocol () {}
+ private:
+ ~Thread ();
- /**
- * \brief get the current Transport
- */
- virtual StreamTransport* GetTransport (void) { return m_Transport; }
- virtual void DataAvailable(DataBuffer *data);
+ static void * ThreadFunction (void *obj);
- private:
- Thread *m_Thread;
- StreamTransport * m_Transport;
- };
+ pthread_t m_ThreadId;
+ int m_PipeFd[2];
- //PipeProtocolFactory class
- class PipeProtocolFactory:StreamProtocolFactory
- {
- public:
- PipeProtocolFactory (Reactor *reactor, Thread *pthis) :
- StreamProtocolFactory (reactor)
- {
- m_Thread = pthis;
- }
- ~PipeProtocolFactory () {}
- PipeProtocol *GetProtocol (StreamTransport *trans)
- {
- return new PipeProtocol (m_Reactor, this, trans, m_Thread);
- }
+ ThreadFunction_t m_Thread_Func;
+ void *m_Thread_Obj;
+ CallbackFunction_t m_CB_Func;
+ void *m_CB_Obj;
- private:
- Thread *m_Thread;
- };
+ DataBuffer *m_Thread_Param;
+ DataBuffer *m_Thread_Result;
- private:
- ~Thread();
- static void *ThreadFunction(void *param);
- pthread_t m_ThreadId;
- int m_PipeFd[2];
- ThreadFunction_t m_ThreadFunc;
- CallbackFunction_t m_ThreadCB;
- void *m_ObjThread;
- void *m_ObjCallBack;
- DataBuffer *m_ObjData;
- PipeProtocol *m_PipeProtocol;
- DataBuffer *m_ThreadRetDB;
- PipeProtocolFactory *m_PipeProtocolFactory;
- StreamTransport *m_StreamTransport;
- bool m_KillThread;
+ PipeProtocol *m_PipeProtocol;
+ PipeProtocolFactory *m_PipeProtocolFactory;
+ StreamTransport *m_StreamTransport;
+
+ bool m_Owned;
+ bool m_ThreadAlive;
};
}
#endif //__HIPRO_ASYCXX__THREAD_H__
+
+/*
+ Local Variables:
+ mode: c++
+ indent-tabs-mode: nil
+ tab-width: 4
+ c-file-style: "gnu"
+ End:
+*/
Modified: trunk/src/Thread.cxx
===================================================================
--- trunk/src/Thread.cxx 2009-04-22 13:38:53 UTC (rev 59)
+++ trunk/src/Thread.cxx 2009-04-22 13:39:32 UTC (rev 60)
@@ -1,3 +1,4 @@
+
/********************************************************************
* Copyright (C) 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All
* rights reserved.
@@ -22,134 +23,174 @@
#include <sys/socket.h>
#include <errno.h>
#include <fcntl.h>
+#include <pthread.h>
-
#include "asycxx-common.h"
#include <asycxx/Error.h>
#include <asycxx/Protocol.h>
#include <asycxx/Thread.h>
+#include <asycxx/DataBuffer.h>
using namespace asycxx;
-/**
- *Ctor
+
+/*
+ * Ctor
*/
-Thread::Thread(Reactor *reactor, ThreadFunction_t thread_fn,
- void *objThread, DataBuffer *data,
- CallbackFunction_t cb_fn,
- void *objCB)
+Thread::Thread(Reactor *reactor,
+ ThreadFunction_t th_fn, void * th_obj, DataBuffer *th_param,
+ CallbackFunction_t cb_fn, void *cb_obj)
{
int ret = pipe(m_PipeFd);
ASSERT((ret == 0), "Pipe creation for thread communication failed.");
- SetFDAsNonBlocking(m_PipeFd[0]);
- SetFDAsNonBlocking(m_PipeFd[1]);
+ /* setup a protocol with transport to handle the thread's completion
+ notification message over a UNIX-pipe */
m_PipeProtocolFactory = new PipeProtocolFactory(reactor, this);
-
- /* create a transport */
m_StreamTransport = new StreamTransport (reactor, m_PipeFd[0]);
m_PipeProtocol = m_PipeProtocolFactory->GetProtocol(m_StreamTransport);
m_StreamTransport->setProtocol (m_PipeProtocol);
- m_ThreadFunc = thread_fn;
- m_ThreadCB = cb_fn;
- m_ObjThread = objThread;
- m_ObjCallBack = objCB;
- m_ThreadRetDB = NULL;
- m_KillThread = false;
+ m_Thread_Func = th_fn;
+ m_Thread_Obj = th_obj;
+ m_CB_Func = cb_fn;
+ m_CB_Obj = cb_obj;
- if (data != NULL)
- {
- m_ObjData = data;
- m_ObjData->Own();
- }
- else
- m_ObjData = NULL;
+ /* take ownership of the thread's parameter */
+ m_Thread_Param = th_param;
+ if (th_param != NULL)
+ {
+ th_param->Own();
+ }
+ m_Thread_Result =NULL;
- ret = pthread_create(&m_ThreadId, NULL, ThreadFunction, (void *) this);
- ASSERT((ret == 0), "Thread creation failed")
+ /* by default we are owned by our owner */
+ m_Owned = true;
+
+ /* start the thread */
+ ret = pthread_create(&m_ThreadId, NULL, ThreadFunction, (void *)this);
+ ASSERT((ret == 0), "Thread creation failed");
+ m_ThreadAlive = true;
}
-/**
+
+/*
* Dtor
*/
Thread::~Thread()
{
- m_StreamTransport->closeReader ();
close(m_PipeFd[1]);
+ /* disown the buffers we own */
+ if (m_Thread_Result != NULL)
+ {
+ m_Thread_Result->DisOwn();
+ }
+ if (m_Thread_Param != NULL)
+ {
+ m_Thread_Param->DisOwn();
+ }
+
delete m_PipeProtocol;
delete m_PipeProtocolFactory;
delete m_StreamTransport;
}
-/**
- *\brief: Thread function to start in a thread.
- * This function will call the threadFunction which has to do the main
- * job. On successful completion of the main thread function or failure,
- * it will write the status to the pipe and quit.
+
+void Thread::DisOwn (void)
+{
+ m_Owned = false;
+ if (m_ThreadAlive == false)
+ {
+ /* we got no owners and thread is not around. So, just die */
+ delete this;
+ }
+}
+
+
+/*
+ * Thread function to start in a thread.
+ *
+ * This function will call the 'function to be called in thread' in a
+ * thread. On successful completion of the main thread function or
+ * failure, it will write the status to the pipe and quit.
*/
void*
-Thread::ThreadFunction(void *param)
+Thread::ThreadFunction (void *obj)
{
- Thread *pThis = (Thread *)param;
- int ret = -1;
- pThis->m_ThreadRetDB = pThis->m_ThreadFunc(pThis->m_ObjThread,
- pThis->m_ObjData);
+ ASSERT((obj != NULL), "bad parameter");
+
+ Thread *pThis = (Thread *)obj;
+ int ret;
+ ASSERT((pThis->m_Thread_Func != NULL), "badly constructed");
+
+ pThis->m_Thread_Result = pThis->m_Thread_Func (pThis->m_Thread_Obj,
+ pThis->m_Thread_Param);
+
+ if (pThis->m_Thread_Result != NULL)
+ {
+ pThis->m_Thread_Result->Own ();
+ }
+
int status = ThreadComplete;
+ ret = write(pThis->m_PipeFd[1], &status, sizeof(ThreadStatus));
+ if (ret == -1)
+ {
+ ERR ("(THREAD-END) writing to pipe : %s", strerror(errno));
+ }
- while (ret <= 0)
- ret = write(pThis->m_PipeFd[1], &status, sizeof(ThreadStatus));
pthread_exit(0);
}
-/**
- *\brief Ctor for PipeProtocol
+
+/*
+ * Ctor for PipeProtocol
*/
-Thread::PipeProtocol::PipeProtocol (Reactor *reactor,StreamProtocolFactory *factory,
- StreamTransport *transport, Thread *pthis):
- StreamProtocol (reactor, (StreamProtocolFactory *)factory, transport)
+Thread::PipeProtocol::PipeProtocol (Reactor *reactor,
+ StreamProtocolFactory *factory,
+ StreamTransport *transport, Thread *thread)
+ : StreamProtocol (reactor, (StreamProtocolFactory *)factory, transport)
{
- m_Thread = pthis;
+ m_Thread = thread;
m_Transport = transport;
m_Transport->startReading();
}
-/**
- *\brief Called by protocol when data is available on the pipe
+
+/*
+ * Called by protocol when data is available on the pipe
*/
-void Thread::PipeProtocol::DataAvailable(DataBuffer *data)
+void Thread::PipeProtocol::DataAvailable (DataBuffer *data)
{
- LOG("%s", __FUNCTION__);
ASSERT ((data != NULL), "DataBuffer is empty");
- pthread_t threadId = m_Thread->getThreadId();
- pthread_join(threadId, NULL);
- if (m_Thread->m_ObjData != NULL)
- m_Thread->m_ObjData->DisOwn();
- if (m_Thread->IsKillThreadSet() == true)
- {
- if (m_Thread->m_ThreadRetDB != NULL)
- m_Thread->m_ThreadRetDB->DisOwn();
- m_Thread->Die();
- return;
- }
-
Thread::ThreadStatus *status = (ThreadStatus*)data->Data();
- if ((*status == Thread::ThreadComplete))
- m_Thread->m_ThreadCB(m_Thread->m_ObjCallBack, m_Thread->m_ThreadRetDB);
- if (m_Thread->m_ThreadRetDB != NULL)
- m_Thread->m_ThreadRetDB->DisOwn();
-}
+ if (*status == Thread::ThreadComplete)
+ {
+ /* thread has completed */
+ pthread_t threadId = m_Thread->getThreadId();
+ pthread_join (threadId, NULL);
-/**
- *\brief after completion of the task call this to delete the thread object
- */
-void Thread::Die()
-{
- delete this;
+ /* Are we still owned? */
+ if ((m_Thread->IsOwned() == true) && (m_Thread->m_CB_Func != NULL))
+ {
+ m_Thread->m_CB_Func (m_Thread->m_CB_Obj, m_Thread->m_Thread_Result);
+ }
+ }
+
+ /* Do we have a owner? */
+ if (m_Thread->IsOwned() == false)
+ {
+ /* we just got to die :-S */
+ delete m_Thread;
+ }
+
+ /* mark the thread as dead so that future 'DisOwn's will delete
+ us */
+ m_Thread->m_ThreadAlive = false;
}
+
/*
Local Variables:
mode: c++
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <joe...@us...> - 2009-04-22 14:23:44
|
Revision: 59
http://asycxx.svn.sourceforge.net/asycxx/?rev=59&view=rev
Author: joe_steeve
Date: 2009-04-22 13:38:53 +0000 (Wed, 22 Apr 2009)
Log Message:
-----------
fixed a build issue. included stdint.h
From: Joe Steeve <js...@hi...>
Modified Paths:
--------------
trunk/src/RawCANTransport.cxx
Modified: trunk/src/RawCANTransport.cxx
===================================================================
--- trunk/src/RawCANTransport.cxx 2009-04-20 09:40:30 UTC (rev 58)
+++ trunk/src/RawCANTransport.cxx 2009-04-22 13:38:53 UTC (rev 59)
@@ -20,8 +20,9 @@
#include <deque>
#include <sys/socket.h>
-#include<linux/can.h>
+#include <linux/can.h>
#include <errno.h>
+#include <stdint.h>
#include "asycxx-common.h"
#include <asycxx/Error.h>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <joe...@us...> - 2009-04-22 14:22:31
|
Revision: 61
http://asycxx.svn.sourceforge.net/asycxx/?rev=61&view=rev
Author: joe_steeve
Date: 2009-04-22 13:40:03 +0000 (Wed, 22 Apr 2009)
Log Message:
-----------
fixed a build issue. inclusion of stdio.h
From: Joe Steeve <js...@hi...>
Modified Paths:
--------------
trunk/examples/threadtest/Threadtest.cxx
Modified: trunk/examples/threadtest/Threadtest.cxx
===================================================================
--- trunk/examples/threadtest/Threadtest.cxx 2009-04-22 13:39:32 UTC (rev 60)
+++ trunk/examples/threadtest/Threadtest.cxx 2009-04-22 13:40:03 UTC (rev 61)
@@ -12,6 +12,7 @@
*******************************************************************/
#include <memory>
+#include <stdio.h>
#include <asycxx/Logger.h>
#include <asycxx/Error.h>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: vivek <vi...@hi...> - 2009-04-20 09:41:08
|
-- Vivek Anand HiPro IT Solutions |
|
From: <viv...@us...> - 2009-04-20 09:40:31
|
Revision: 58
http://asycxx.svn.sourceforge.net/asycxx/?rev=58&view=rev
Author: vivekanand83
Date: 2009-04-20 09:40:30 +0000 (Mon, 20 Apr 2009)
Log Message:
-----------
Added Thread.h in install list.
Modified Paths:
--------------
trunk/include/Makefile.am
Modified: trunk/include/Makefile.am
===================================================================
--- trunk/include/Makefile.am 2009-04-20 09:28:37 UTC (rev 57)
+++ trunk/include/Makefile.am 2009-04-20 09:40:30 UTC (rev 58)
@@ -31,5 +31,7 @@
asycxx/RawCANProtocolFactory.h \
asycxx/DatagramProtocolFactory.h \
asycxx/DatagramProtocol.h \
- asycxx/DatagramTransport.h
+ asycxx/DatagramTransport.h \
+ asycxx/Thread.h
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <viv...@us...> - 2009-04-20 09:28:39
|
Revision: 57
http://asycxx.svn.sourceforge.net/asycxx/?rev=57&view=rev
Author: vivekanand83
Date: 2009-04-20 09:28:37 +0000 (Mon, 20 Apr 2009)
Log Message:
-----------
Added threading support.
Modified Paths:
--------------
trunk/configure.ac
trunk/examples/Makefile.am
trunk/examples/echoserver/Makefile.am
trunk/include/asycxx/Transport.h
trunk/src/Makefile.am
Added Paths:
-----------
trunk/examples/threadtest/
trunk/examples/threadtest/Makefile.am
trunk/examples/threadtest/Threadtest.cxx
trunk/include/asycxx/Thread.h
trunk/src/Thread.cxx
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2009-04-16 13:24:59 UTC (rev 56)
+++ trunk/configure.ac 2009-04-20 09:28:37 UTC (rev 57)
@@ -71,6 +71,7 @@
examples/Makefile
examples/echoserver/Makefile
examples/canserver/Makefile
+examples/threadtest/Makefile
asycxx-0.1.pc
])
AC_OUTPUT
Modified: trunk/examples/Makefile.am
===================================================================
--- trunk/examples/Makefile.am 2009-04-16 13:24:59 UTC (rev 56)
+++ trunk/examples/Makefile.am 2009-04-20 09:28:37 UTC (rev 57)
@@ -1,2 +1,2 @@
-SUBDIRS = echoserver #canserver
+SUBDIRS = echoserver threadtest #canserver
Modified: trunk/examples/echoserver/Makefile.am
===================================================================
--- trunk/examples/echoserver/Makefile.am 2009-04-16 13:24:59 UTC (rev 56)
+++ trunk/examples/echoserver/Makefile.am 2009-04-20 09:28:37 UTC (rev 57)
@@ -4,7 +4,7 @@
EchoServer_SOURCES = EchoServer.cxx
EchoServer_LDADD = $(top_srcdir)/src/libasycxx-0.1.la
EchoServer_CPPFLAGS = -I$(top_srcdir)/include
-EchoServer_LDFLAGS = -L$(top_srcdir)/src
+EchoServer_LDFLAGS = -L$(top_srcdir)/src -lpthread
EchoServer_debug_SOURCES = $(EchoServer_SOURCES)
EchoServer_debug_CXXFLAGS = -g $(AM_CXXFLAGS)
Added: trunk/examples/threadtest/Makefile.am
===================================================================
--- trunk/examples/threadtest/Makefile.am (rev 0)
+++ trunk/examples/threadtest/Makefile.am 2009-04-20 09:28:37 UTC (rev 57)
@@ -0,0 +1,19 @@
+
+noinst_PROGRAMS = Threadtest Threadtest.debug
+
+Threadtest_SOURCES = Threadtest.cxx
+Threadtest_LDADD = $(top_srcdir)/src/libasycxx-0.1.la -lpthread
+Threadtest_CPPFLAGS = -I$(top_srcdir)/include
+Threadtest_LDFLAGS = -L$(top_srcdir)/src
+
+Threadtest_debug_SOURCES = $(Threadtest_SOURCES)
+Threadtest_debug_CXXFLAGS = -g $(AM_CXXFLAGS)
+Threadtest_debug_LDADD = $(top_srcdir)/src/.libs/libasycxx-dbg-0.1.a -lpthread
+Threadtest_debug_CPPFLAGS = -I$(top_srcdir)/include
+#Threadtest_debug_LDFLAGS = -L$(top_srcdir)/src
+
+# Local Variables:
+# mode: makefile
+# indent-tabs-mode: nil
+# tab-width: 4
+# End:
Added: trunk/examples/threadtest/Threadtest.cxx
===================================================================
--- trunk/examples/threadtest/Threadtest.cxx (rev 0)
+++ trunk/examples/threadtest/Threadtest.cxx 2009-04-20 09:28:37 UTC (rev 57)
@@ -0,0 +1,67 @@
+
+/********************************************************************
+ * Copyright (C) 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All
+ * rights reserved.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms described in the LICENSE file which accompanies
+ * this distribution. If the LICENSE file was not attached to this
+ * distribution or for further clarifications, please contact
+ * le...@hi....
+ *
+ *******************************************************************/
+
+#include <memory>
+
+#include <asycxx/Logger.h>
+#include <asycxx/Error.h>
+#include <asycxx/SelectReactor.h>
+#include <asycxx/StreamProtocol.h>
+#include <asycxx/StreamProtocolFactory.h>
+#include <asycxx/TCPListener.h>
+#include <asycxx/Thread.h>
+#include <asycxx/DataBuffer.h>
+
+using namespace asycxx;
+
+Logger *Log;
+
+static DataBuffer* threadFunction(void *objthread, DataBuffer *obj)
+{
+ fprintf(stderr,"Thread function called!\n");
+ return NULL;
+}
+
+static void CallbackFunc(void *obj, DataBuffer *param)
+{
+ fprintf(stderr,"CallBack function called.\n");
+}
+
+
+
+int main (void)
+{
+ Reactor *reactor;
+
+ Log = new Logger();
+ Log->EnableConsole();
+
+ reactor = new SelectReactor ();
+ Thread *thread;
+ thread = new Thread(reactor, &threadFunction,
+ NULL, NULL, &CallbackFunc,
+ NULL);
+ reactor->Run ();
+ printf ("Closing reactor");
+}
+
+/*
+ Local Variables:
+ mode: c++
+ indent-tabs-mode: nil
+ tab-width: 4
+ c-file-style: "gnu"
+ End:
+*/
+
+
Added: trunk/include/asycxx/Thread.h
===================================================================
--- trunk/include/asycxx/Thread.h (rev 0)
+++ trunk/include/asycxx/Thread.h 2009-04-20 09:28:37 UTC (rev 57)
@@ -0,0 +1,108 @@
+
+/********************************************************************
+ * Copyright (C) 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All
+ * rights reserved.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms described in the LICENSE file which accompanies
+ * this distribution. If the LICENSE file was not attached to this
+ * distribution or for further clarifications, please contact
+ * le...@hi....
+ *
+ *******************************************************************/
+
+#ifndef __HIPRO_ASYCXX__THREAD_H__
+#define __HIPRO_ASYCXX__THREAD_H__
+
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+
+#include "Error.h"
+#include "StreamTransport.h"
+#include "StreamProtocol.h"
+#include "StreamProtocolFactory.h"
+
+namespace asycxx
+{
+ typedef DataBuffer* (*ThreadFunction_t)(void* objThread, DataBuffer* obj);
+ typedef void (*CallbackFunction_t)(void* obj, DataBuffer *param);
+
+ class Thread
+ {
+ enum ThreadStatus
+ {
+ ThreadComplete = 0,
+ ThreadKilled
+ };
+
+ public:
+ Thread(Reactor *reactor, ThreadFunction_t thread_fn,
+ void *objThread, DataBuffer *data,
+ CallbackFunction_t cb_fn,
+ void *objCB);
+ pthread_t getThreadId(void) { return m_ThreadId; }
+
+ void SetKill(){ m_KillThread = true; }
+ bool IsKillThreadSet() { return m_KillThread; }
+ void Die();
+
+ private:
+ // PipeProtocol class
+ class PipeProtocol: public StreamProtocol
+ {
+ public:
+ PipeProtocol (Reactor *reactor,StreamProtocolFactory *factory,
+ StreamTransport *transport, Thread *pthis);
+
+ virtual ~PipeProtocol () {}
+
+ /**
+ * \brief get the current Transport
+ */
+ virtual StreamTransport* GetTransport (void) { return m_Transport; }
+ virtual void DataAvailable(DataBuffer *data);
+
+ private:
+ Thread *m_Thread;
+ StreamTransport * m_Transport;
+ };
+
+ //PipeProtocolFactory class
+ class PipeProtocolFactory:StreamProtocolFactory
+ {
+ public:
+ PipeProtocolFactory (Reactor *reactor, Thread *pthis) :
+ StreamProtocolFactory (reactor)
+ {
+ m_Thread = pthis;
+ }
+ ~PipeProtocolFactory () {}
+ PipeProtocol *GetProtocol (StreamTransport *trans)
+ {
+ return new PipeProtocol (m_Reactor, this, trans, m_Thread);
+ }
+
+ private:
+ Thread *m_Thread;
+ };
+
+ private:
+ ~Thread();
+ static void *ThreadFunction(void *param);
+ pthread_t m_ThreadId;
+ int m_PipeFd[2];
+ ThreadFunction_t m_ThreadFunc;
+ CallbackFunction_t m_ThreadCB;
+ void *m_ObjThread;
+ void *m_ObjCallBack;
+ DataBuffer *m_ObjData;
+ PipeProtocol *m_PipeProtocol;
+ DataBuffer *m_ThreadRetDB;
+ PipeProtocolFactory *m_PipeProtocolFactory;
+ StreamTransport *m_StreamTransport;
+ bool m_KillThread;
+ };
+}
+
+#endif //__HIPRO_ASYCXX__THREAD_H__
Modified: trunk/include/asycxx/Transport.h
===================================================================
--- trunk/include/asycxx/Transport.h 2009-04-16 13:24:59 UTC (rev 56)
+++ trunk/include/asycxx/Transport.h 2009-04-20 09:28:37 UTC (rev 57)
@@ -40,22 +40,22 @@
/**
* \brief Sets the transport ready for reading
*/
- void startReading (void);
+ virtual void startReading (void);
/**
* \brief Sets the transport to stop reading
*/
- void stopReading (void);
+ virtual void stopReading (void);
/**
* \brief Sets the transport ready for writing
*/
- void startWriting (void);
+ virtual void startWriting (void);
/**
* \brief Sets the transport to stop writing
*/
- void stopWriting (void);
+ virtual void stopWriting (void);
/**
* \brief Attach the given protocol to the Transport
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2009-04-16 13:24:59 UTC (rev 56)
+++ trunk/src/Makefile.am 2009-04-20 09:28:37 UTC (rev 57)
@@ -22,7 +22,8 @@
GimpleMsgBus.cxx \
core.cxx \
RawCANTransport.cxx \
- RawCANListener.cxx
+ RawCANListener.cxx \
+ Thread.cxx
libasycxx_0_1_la_CPPFLAGS = -I$(top_srcdir)/include
Added: trunk/src/Thread.cxx
===================================================================
--- trunk/src/Thread.cxx (rev 0)
+++ trunk/src/Thread.cxx 2009-04-20 09:28:37 UTC (rev 57)
@@ -0,0 +1,160 @@
+/********************************************************************
+ * Copyright (C) 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All
+ * rights reserved.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms described in the LICENSE file which accompanies
+ * this distribution. If the LICENSE file was not attached to this
+ * distribution or for further clarifications, please contact
+ * le...@hi....
+ *
+ *******************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <asycxx-config.h>
+#endif
+
+#include <errno.h>
+#include <unistd.h>
+#include <string.h>
+#include <deque>
+
+#include <sys/socket.h>
+#include <errno.h>
+#include <fcntl.h>
+
+
+#include "asycxx-common.h"
+#include <asycxx/Error.h>
+#include <asycxx/Protocol.h>
+#include <asycxx/Thread.h>
+
+using namespace asycxx;
+/**
+ *Ctor
+ */
+Thread::Thread(Reactor *reactor, ThreadFunction_t thread_fn,
+ void *objThread, DataBuffer *data,
+ CallbackFunction_t cb_fn,
+ void *objCB)
+{
+ int ret = pipe(m_PipeFd);
+ ASSERT((ret == 0), "Pipe creation for thread communication failed.");
+
+ SetFDAsNonBlocking(m_PipeFd[0]);
+ SetFDAsNonBlocking(m_PipeFd[1]);
+ m_PipeProtocolFactory = new PipeProtocolFactory(reactor, this);
+
+ /* create a transport */
+ m_StreamTransport = new StreamTransport (reactor, m_PipeFd[0]);
+ m_PipeProtocol = m_PipeProtocolFactory->GetProtocol(m_StreamTransport);
+ m_StreamTransport->setProtocol (m_PipeProtocol);
+
+ m_ThreadFunc = thread_fn;
+ m_ThreadCB = cb_fn;
+ m_ObjThread = objThread;
+ m_ObjCallBack = objCB;
+ m_ThreadRetDB = NULL;
+ m_KillThread = false;
+
+ if (data != NULL)
+ {
+ m_ObjData = data;
+ m_ObjData->Own();
+ }
+ else
+ m_ObjData = NULL;
+
+ ret = pthread_create(&m_ThreadId, NULL, ThreadFunction, (void *) this);
+ ASSERT((ret == 0), "Thread creation failed")
+}
+
+/**
+ * Dtor
+ */
+Thread::~Thread()
+{
+ m_StreamTransport->closeReader ();
+ close(m_PipeFd[1]);
+
+ delete m_PipeProtocol;
+ delete m_PipeProtocolFactory;
+ delete m_StreamTransport;
+}
+
+/**
+ *\brief: Thread function to start in a thread.
+ * This function will call the threadFunction which has to do the main
+ * job. On successful completion of the main thread function or failure,
+ * it will write the status to the pipe and quit.
+ */
+void*
+Thread::ThreadFunction(void *param)
+{
+ Thread *pThis = (Thread *)param;
+ int ret = -1;
+ pThis->m_ThreadRetDB = pThis->m_ThreadFunc(pThis->m_ObjThread,
+ pThis->m_ObjData);
+
+ int status = ThreadComplete;
+
+ while (ret <= 0)
+ ret = write(pThis->m_PipeFd[1], &status, sizeof(ThreadStatus));
+ pthread_exit(0);
+}
+
+/**
+ *\brief Ctor for PipeProtocol
+ */
+Thread::PipeProtocol::PipeProtocol (Reactor *reactor,StreamProtocolFactory *factory,
+ StreamTransport *transport, Thread *pthis):
+ StreamProtocol (reactor, (StreamProtocolFactory *)factory, transport)
+{
+ m_Thread = pthis;
+ m_Transport = transport;
+ m_Transport->startReading();
+}
+
+/**
+ *\brief Called by protocol when data is available on the pipe
+ */
+void Thread::PipeProtocol::DataAvailable(DataBuffer *data)
+{
+ LOG("%s", __FUNCTION__);
+ ASSERT ((data != NULL), "DataBuffer is empty");
+ pthread_t threadId = m_Thread->getThreadId();
+ pthread_join(threadId, NULL);
+ if (m_Thread->m_ObjData != NULL)
+ m_Thread->m_ObjData->DisOwn();
+
+ if (m_Thread->IsKillThreadSet() == true)
+ {
+ if (m_Thread->m_ThreadRetDB != NULL)
+ m_Thread->m_ThreadRetDB->DisOwn();
+ m_Thread->Die();
+ return;
+ }
+
+ Thread::ThreadStatus *status = (ThreadStatus*)data->Data();
+ if ((*status == Thread::ThreadComplete))
+ m_Thread->m_ThreadCB(m_Thread->m_ObjCallBack, m_Thread->m_ThreadRetDB);
+ if (m_Thread->m_ThreadRetDB != NULL)
+ m_Thread->m_ThreadRetDB->DisOwn();
+}
+
+/**
+ *\brief after completion of the task call this to delete the thread object
+ */
+void Thread::Die()
+{
+ delete this;
+}
+
+/*
+ Local Variables:
+ mode: c++
+ indent-tabs-mode: nil
+ tab-width: 4
+ c-file-style: "gnu"
+ End:
+*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <viv...@us...> - 2009-04-16 13:25:04
|
Revision: 56
http://asycxx.svn.sourceforge.net/asycxx/?rev=56&view=rev
Author: vivekanand83
Date: 2009-04-16 13:24:59 +0000 (Thu, 16 Apr 2009)
Log Message:
-----------
Added Datagram support.
Modified Paths:
--------------
trunk/include/Makefile.am
trunk/include/asycxx/MsgHandler.h
trunk/src/Makefile.am
Added Paths:
-----------
trunk/include/asycxx/DatagramProtocol.h
trunk/include/asycxx/DatagramProtocolFactory.h
trunk/include/asycxx/DatagramTransport.h
trunk/include/asycxx/RawCANListener.h
trunk/include/asycxx/RawCANProtocol.h
trunk/include/asycxx/RawCANProtocolFactory.h
trunk/include/asycxx/RawCANTransport.h
trunk/src/RawCANListener.cxx
trunk/src/RawCANTransport.cxx
Removed Paths:
-------------
trunk/include/asycxx/RAWCANListener.h
trunk/include/asycxx/RAWCANTransport.h
trunk/src/RAWCANListener.cxx
trunk/src/RAWCANTransport.cxx
Modified: trunk/include/Makefile.am
===================================================================
--- trunk/include/Makefile.am 2009-04-16 13:21:54 UTC (rev 55)
+++ trunk/include/Makefile.am 2009-04-16 13:24:59 UTC (rev 56)
@@ -23,8 +23,13 @@
asycxx/MsgHandler.h \
asycxx/GimpleMsgBus.h \
asycxx/_asycxx.h \
- asycxx/asycxx.h
+ asycxx/asycxx.h \
+ asycxx/Selectable.h \
+ asycxx/RawCANTransport.h \
+ asycxx/RawCANListener.h \
+ asycxx/RawCANProtocol.h \
+ asycxx/RawCANProtocolFactory.h \
+ asycxx/DatagramProtocolFactory.h \
+ asycxx/DatagramProtocol.h \
+ asycxx/DatagramTransport.h
-# asycxx/RAWCANTransport.h \
-# asycxx/RAWCANListener.h
-
Added: trunk/include/asycxx/DatagramProtocol.h
===================================================================
--- trunk/include/asycxx/DatagramProtocol.h (rev 0)
+++ trunk/include/asycxx/DatagramProtocol.h 2009-04-16 13:24:59 UTC (rev 56)
@@ -0,0 +1,45 @@
+
+/********************************************************************
+ * Copyright (C) 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All
+ * rights reserved.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms described in the LICENSE file which accompanies
+ * this distribution. If the LICENSE file was not attached to this
+ * distribution or for further clarifications, please contact
+ * le...@hi....
+ *
+ *******************************************************************/
+
+#ifndef __HIPRO_ASYCXX__DATAGRAM_PROTOCOL_H__
+#define __HIPRO_ASYCXX__DATAGRAM_PROTOCOL_H__
+
+#include "Error.h"
+#include "Reactor.h"
+#include "DataBuffer.h"
+#include "Protocol.h"
+
+
+namespace asycxx
+{
+ class DatagramProtocolFactory;
+ class DatagramProtocol : public Protocol
+ {
+ public:
+ DatagramProtocol (Reactor *reactor, DatagramProtocolFactory *factory)
+ :Protocol(reactor, (ProtocolFactory*)factory) {}
+ virtual ~DatagramProtocol () {}
+
+ };
+}
+
+#endif /* __HIPRO_ASYCXX__DATAGRAM_PROTOCOL_H__*/
+
+/*
+ Local Variables:
+ mode: c++
+ indent-tabs-mode: nil
+ tab-width: 4
+ c-file-style: "gnu"
+ End:
+*/
Added: trunk/include/asycxx/DatagramProtocolFactory.h
===================================================================
--- trunk/include/asycxx/DatagramProtocolFactory.h (rev 0)
+++ trunk/include/asycxx/DatagramProtocolFactory.h 2009-04-16 13:24:59 UTC (rev 56)
@@ -0,0 +1,41 @@
+
+/********************************************************************
+ * Copyright (C) 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All
+ * rights reserved.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms described in the LICENSE file which accompanies
+ * this distribution. If the LICENSE file was not attached to this
+ * distribution or for further clarifications, please contact
+ * le...@hi....
+ *
+ *******************************************************************/
+
+#ifndef __HIPRO_ASYCXX__DATAGRAM_PROTOCOL_FACTORY_H__
+#define __HIPRO_ASYCXX__DATAGRAM_PROTOCOL_FACTORY_H__
+
+#include "Error.h"
+#include "Reactor.h"
+#include "ProtocolFactory.h"
+#include "DatagramProtocol.h"
+#include "DatagramTransport.h"
+
+namespace asycxx
+{
+ class DatagramProtocolFactory : public ProtocolFactory
+ {
+ public:
+ DatagramProtocolFactory (Reactor *reactor) : ProtocolFactory (reactor) {}
+ virtual ~DatagramProtocolFactory () {}
+ };
+}
+#endif /* __HIPRO_ASYCXX__DATAGRAM_PROTOCOL_FACTORY_H__ */
+
+/*
+ Local Variables:
+ mode: c++
+ indent-tabs-mode: nil
+ tab-width: 4
+ c-file-style: "gnu"
+ End:
+*/
Added: trunk/include/asycxx/DatagramTransport.h
===================================================================
--- trunk/include/asycxx/DatagramTransport.h (rev 0)
+++ trunk/include/asycxx/DatagramTransport.h 2009-04-16 13:24:59 UTC (rev 56)
@@ -0,0 +1,49 @@
+
+/********************************************************************
+ * Copyright (C) 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All
+ * rights reserved.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms described in the LICENSE file which accompanies
+ * this distribution. If the LICENSE file was not attached to this
+ * distribution or for further clarifications, please contact
+ * le...@hi....
+ *
+ *******************************************************************/
+
+#ifndef __HIPRO_ASYCXX__DATAGRAM_TRANSPORT_H__
+#define __HIPRO_ASYCXX__DATAGRAM_TRANSPORT_H__
+
+#include "Error.h"
+#include "Transport.h"
+#include "DataBuffer.h"
+#include "DatagramProtocol.h"
+
+namespace asycxx
+{
+ class DatagramTransport : public Transport
+ {
+ public:
+ /**
+ * \brief CTOR
+ *
+ * \param[in] reactor Pointer to a Reactor
+ * \param[in] fd A valid file-descriptor to build the transport on
+ */
+ DatagramTransport (Reactor *reactor, int fd)
+ : Transport (reactor, fd) {}
+
+ virtual ~DatagramTransport () {}
+ };
+}
+#endif /* __HIPRO_ASYCXX__DATAGRAM_TRANSPORT_H__*/
+
+/*
+ Local Variables:
+ mode: c++
+ indent-tabs-mode: nil
+ tab-width: 4
+ c-file-style: "gnu"
+ End:
+*/
+
Modified: trunk/include/asycxx/MsgHandler.h
===================================================================
--- trunk/include/asycxx/MsgHandler.h 2009-04-16 13:21:54 UTC (rev 55)
+++ trunk/include/asycxx/MsgHandler.h 2009-04-16 13:24:59 UTC (rev 56)
@@ -36,7 +36,7 @@
void SetMsgBus (MsgBus *bus)
{
- ASSERT ((bus != NULL), "cannot use a NULL MsgBus");
+// ASSERT ((bus != NULL), "cannot use a NULL MsgBus");
m_Bus = bus;
}
Deleted: trunk/include/asycxx/RAWCANListener.h
===================================================================
--- trunk/include/asycxx/RAWCANListener.h 2009-04-16 13:21:54 UTC (rev 55)
+++ trunk/include/asycxx/RAWCANListener.h 2009-04-16 13:24:59 UTC (rev 56)
@@ -1,57 +0,0 @@
-
-/********************************************************************
- * Copyright (C) 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All
- * rights reserved.
- *
- * This program and the accompanying materials are made available
- * under the terms described in the LICENSE file which accompanies
- * this distribution. If the LICENSE file was not attached to this
- * distribution or for further clarifications, please contact
- * le...@hi....
- *
- *******************************************************************/
-
-#ifndef __HIPRO_ASYCXX__RAW_CAN_LISTENER_H__
-#define __HIPRO_ASYCXX__RAW_CAN_LISTENER_H__
-
-
-#include <sys/types.h>
-#include <arpa/inet.h>
-#include <linux/can.h>
-#include <linux/can/raw.h>
-
-#include "Error.h"
-#include "Listener.h"
-#include "Factory.h"
-#include "Deferred.h"
-#include "Reactor.h"
-
-class RAWCANListener : public Listener
-{
- public:
-
- RAWCANListener (Reactor *reactor, Factory *factory, const char *interface);
- virtual ~RAWCANListener ();
-
- protected:
- Reactor *m_Reactor;
- Factory *m_Factory;
- Deferred *m_ReactorDeferred;
-
- int m_Socket;
- char m_Interface[8];
- bool m_bSetupNoDelay;
- protected:
- void Init (Reactor *reactor, Factory *factory, const char *interface);
-};
-
-#endif /* __HIPRO_ASYCXX__RAW_CAN_LISTENER_H__*/
-
-/*
- Local Variables:
- mode: c++
- indent-tabs-mode: nil
- tab-width: 4
- c-file-style: "gnu"
- End:
-*/
Deleted: trunk/include/asycxx/RAWCANTransport.h
===================================================================
--- trunk/include/asycxx/RAWCANTransport.h 2009-04-16 13:21:54 UTC (rev 55)
+++ trunk/include/asycxx/RAWCANTransport.h 2009-04-16 13:24:59 UTC (rev 56)
@@ -1,45 +0,0 @@
-
-/********************************************************************
- * Copyright (C), 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All
- * rights reserved.
- *
- * This program and the accompanying materials are made available
- * under the terms described in the LICENSE file which accompanies
- * this distribution. If the LICENSE file was not attached to this
- * distribution or for further clarifications, please contact
- * le...@hi....
- *
- *******************************************************************/
-
-#ifndef __HIPRO_ASYCXX__CAN_TRANSPORT_H__
-#define __HIPRO_ASYCXX__CAN_TRANSPORT_H__
-
-
-#include "Error.h"
-#include "Reactor.h"
-#include "DataBuffer.h"
-#include "Transport.h"
-
-class RAWCANTransport : public Transport
-{
- public:
- RAWCANTransport (Reactor *reactor, int fd);
- virtual ~RAWCANTransport ();
-
- protected:
- Result doWrite (void);
- Result doRead (DataBuffer *data);
- void doDisconnect (void);
-
-};
-
-#endif /* __HIPRO_ASYCXX__CAN_TRANSPORT_H__ */
-
-/*
- Local Variables:
- mode: c++
- indent-tabs-mode: nil
- tab-width: 4
- c-file-style: "gnu"
- End:
-*/
Added: trunk/include/asycxx/RawCANListener.h
===================================================================
--- trunk/include/asycxx/RawCANListener.h (rev 0)
+++ trunk/include/asycxx/RawCANListener.h 2009-04-16 13:24:59 UTC (rev 56)
@@ -0,0 +1,58 @@
+
+/********************************************************************
+ * Copyright (C) 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All
+ * rights reserved.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms described in the LICENSE file which accompanies
+ * this distribution. If the LICENSE file was not attached to this
+ * distribution or for further clarifications, please contact
+ * le...@hi....
+ *
+ *******************************************************************/
+
+#ifndef __HIPRO_ASYCXX__RAW_CAN_LISTENER_H__
+#define __HIPRO_ASYCXX__RAW_CAN_LISTENER_H__
+
+
+#include <sys/types.h>
+#include <arpa/inet.h>
+#include <linux/can.h>
+#include <linux/can/raw.h>
+
+#include "Error.h"
+#include "Listener.h"
+#include "Reactor.h"
+#include "RawCANProtocolFactory.h"
+
+namespace asycxx
+{
+ class RawCANListener : public Listener
+ {
+ public:
+ RawCANListener(Reactor *reactor, RawCANProtocolFactory *factory,
+ const char *interface);
+ virtual ~RawCANListener ();
+ virtual void Readable (void){};
+
+ virtual void Writable (void) {}
+ protected:
+ Reactor *m_Reactor;
+ RawCANProtocolFactory *m_Factory;
+ int m_Socket;
+ char m_Interface[8];
+ bool m_bSetupNoDelay;
+ protected:
+ void Init (Reactor *reactor, RawCANProtocolFactory *factory, const char *interface);
+ };
+}
+#endif /* __HIPRO_ASYCXX__RAW_CAN_LISTENER_H__*/
+
+/*
+ Local Variables:
+ mode: c++
+ indent-tabs-mode: nil
+ tab-width: 4
+ c-file-style: "gnu"
+ End:
+*/
Added: trunk/include/asycxx/RawCANProtocol.h
===================================================================
--- trunk/include/asycxx/RawCANProtocol.h (rev 0)
+++ trunk/include/asycxx/RawCANProtocol.h 2009-04-16 13:24:59 UTC (rev 56)
@@ -0,0 +1,54 @@
+/********************************************************************
+ * Copyright (C) 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All
+ * rights reserved.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms described in the LICENSE file which accompanies
+ * this distribution. If the LICENSE file was not attached to this
+ * distribution or for further clarifications, please contact
+ * le...@hi....
+ *
+ *******************************************************************/
+
+#ifndef __HIPRO_ASYCXX__RAWCAN_PROTOCOL_H__
+#define __HIPRO_ASYCXX__RAWCAN_PROTOCOL_H__
+
+#include "Error.h"
+#include "Reactor.h"
+#include "DataBuffer.h"
+#include "DatagramProtocol.h"
+#include "DatagramTransport.h"
+#include "RawCANTransport.h"
+// #include "RawCANProtocolFactory.h"
+
+namespace asycxx
+{
+ class RawCANProtocolFactory;
+ class RawCANProtocol : public DatagramProtocol
+ {
+ public:
+ RawCANProtocol (Reactor *reactor, RawCANProtocolFactory *factory,
+ RawCANTransport *transport):
+ DatagramProtocol (reactor,
+ (DatagramProtocolFactory *)factory)
+ {
+ m_Transport = transport;
+ m_Transport->startReading();
+ /*If we are not on the reactor's writers list, then add ourselves
+ to the reactor's writers list */
+ m_Transport->startWriting();
+ }
+ virtual ~RawCANProtocol () {}
+
+ /**
+ * \brief get the current Transport
+ */
+ virtual RawCANTransport* GetTransport (void) { return m_Transport; }
+ virtual void DataAvailable(DataBuffer *data) = 0;
+
+ private:
+ RawCANTransport * m_Transport;
+ };
+}
+
+#endif //__HIPRO_ASYCXX__RAWCAN_PROTOCOL_H__
Added: trunk/include/asycxx/RawCANProtocolFactory.h
===================================================================
--- trunk/include/asycxx/RawCANProtocolFactory.h (rev 0)
+++ trunk/include/asycxx/RawCANProtocolFactory.h 2009-04-16 13:24:59 UTC (rev 56)
@@ -0,0 +1,44 @@
+
+/********************************************************************
+ * Copyright (C) 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All
+ * rights reserved.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms described in the LICENSE file which accompanies
+ * this distribution. If the LICENSE file was not attached to this
+ * distribution or for further clarifications, please contact
+ * le...@hi....
+ *
+ *******************************************************************/
+
+#ifndef __HIPRO_ASYCXX__RAWCAN_PROTOCOL_FACTORY_H__
+#define __HIPRO_ASYCXX__RAWCAN_PROTOCOL_FACTORY_H__
+
+#include "Error.h"
+#include "Reactor.h"
+#include "ProtocolFactory.h"
+#include "StreamProtocol.h"
+#include "StreamTransport.h"
+#include "DatagramProtocolFactory.h"
+#include "RawCANProtocol.h"
+
+namespace asycxx
+{
+ class RawCANProtocolFactory : public DatagramProtocolFactory
+ {
+ public:
+ RawCANProtocolFactory (Reactor *reactor) : DatagramProtocolFactory (reactor) {}
+ virtual ~RawCANProtocolFactory () {}
+ virtual RawCANProtocol *GetProtocol (RawCANTransport *trans) = 0;
+ };
+}
+#endif /* __HIPRO_ASYCXX__RAWCAN_PROTOCOL_FACTORY_H__*/
+
+/*
+ Local Variables:
+ mode: c++
+ indent-tabs-mode: nil
+ tab-width: 4
+ c-file-style: "gnu"
+ End:
+*/
Added: trunk/include/asycxx/RawCANTransport.h
===================================================================
--- trunk/include/asycxx/RawCANTransport.h (rev 0)
+++ trunk/include/asycxx/RawCANTransport.h 2009-04-16 13:24:59 UTC (rev 56)
@@ -0,0 +1,70 @@
+
+/********************************************************************
+ * Copyright (C), 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All
+ * rights reserved.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms described in the LICENSE file which accompanies
+ * this distribution. If the LICENSE file was not attached to this
+ * distribution or for further clarifications, please contact
+ * le...@hi....
+ *
+ *******************************************************************/
+
+#ifndef __HIPRO_ASYCXX__CAN_TRANSPORT_H__
+#define __HIPRO_ASYCXX__CAN_TRANSPORT_H__
+
+
+#include "Error.h"
+#include "Reactor.h"
+#include "DataBuffer.h"
+#include "DatagramTransport.h"
+// #include "RawCANProtocol.h"
+
+namespace asycxx
+{
+ class RawCANProtocol;
+ class RawCANTransport : public DatagramTransport
+ {
+ public:
+ RawCANTransport (Reactor *reactor, int fd);
+ virtual ~RawCANTransport ();
+
+ /* methods to satisfy the 'Transport' interface */
+ virtual void Readable (void);
+ virtual void Writable (void);
+ virtual void Close(void) {}
+ virtual void closeReader(){}
+ virtual void closeWriter(){}
+
+ void Send (DataBuffer *data, uint32_t can_id);
+ virtual RawCANProtocol* getProtocol (void)
+ {
+ return (RawCANProtocol*) Transport::getProtocol();
+ }
+
+ /**
+ * \brief Get the currently attached protocol
+ */
+ virtual void setProtocol (RawCANProtocol *protocol)
+ {
+ Transport::setProtocol ((Protocol *)protocol);
+ }
+
+ protected:
+ std::list<DataBuffer *> m_writeBuffers;
+ RetCode doRead (DataBuffer *data);
+ RetCode doWrite (void);
+ };
+}
+
+#endif /* __HIPRO_ASYCXX__CAN_TRANSPORT_H__ */
+
+/*
+ Local Variables:
+ mode: c++
+ indent-tabs-mode: nil
+ tab-width: 4
+ c-file-style: "gnu"
+ End:
+*/
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2009-04-16 13:21:54 UTC (rev 55)
+++ trunk/src/Makefile.am 2009-04-16 13:24:59 UTC (rev 56)
@@ -20,12 +20,11 @@
StreamProtocol.cxx \
MsgBus.cxx \
GimpleMsgBus.cxx \
- core.cxx
+ core.cxx \
+ RawCANTransport.cxx \
+ RawCANListener.cxx
-# RAWCANTransport.cxx \
-# RAWCANListener.cxx
-
libasycxx_0_1_la_CPPFLAGS = -I$(top_srcdir)/include
libasycxx_0_1_la_CXXFLAGS = -O2
libasycxx_0_1_la_LDFLAGS = -version-info 0:1:0
Deleted: trunk/src/RAWCANListener.cxx
===================================================================
--- trunk/src/RAWCANListener.cxx 2009-04-16 13:21:54 UTC (rev 55)
+++ trunk/src/RAWCANListener.cxx 2009-04-16 13:24:59 UTC (rev 56)
@@ -1,156 +0,0 @@
-/********************************************************************
- * Copyright (C) 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All
- * rights reserved.
- *
- * This program and the accompanying materials are made available
- * under the terms described in the LICENSE file which accompanies
- * this distribution. If the LICENSE file was not attached to this
- * distribution or for further clarifications, please contact
- * le...@hi....
- *
- *******************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include <asycxx-config.h>
-#endif
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netinet/tcp.h>
-#include <net/if.h>
-#include <linux/can.h>
-#include <linux/can/raw.h>
-
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-
-#include "asycxx-common.h"
-#include <asycxx/Error.h>
-#include <asycxx/Factory.h>
-#include <asycxx/Protocol.h>
-#include <asycxx/RAWCANTransport.h>
-#include <asycxx/RAWCANListener.h>
-
-
-#include <sys/ioctl.h>
-
-/* At time of writing, these constants are not defined in the headers */
-#ifndef PF_CAN
-#define PF_CAN 29
-#endif
-
-#ifndef AF_CAN
-#define AF_CAN PF_CAN
-#endif
-
-/**
- * \brief ctor to put RAWCANListener on interface
- *
- * \param[in] reactor The reactor to hook to
- * \param[in] factory The factory to use to produce protocols to
- * handle new connections
- * \param[in] interface The CAN interface to listen to
- *
- * \details This constructor puts the RAWCANListener object to listen on
- * the specified interface.
- */
-RAWCANListener::RAWCANListener (Reactor *reactor, Factory *factory,
- const char *interface)
-{
- Init (reactor, factory, interface);
-}
-
-
-/*
- * \brief dtor
- */
-RAWCANListener::~RAWCANListener ()
-{
- if (m_Socket != -1)
- {
- close (m_Socket);
- }
-}
-
-
-/**
- * \brief Initialize the RAWCANListener
- *
- * \param[in] reactor The reactor to hook to
- * \param[in] factory The factory to use to produce protocols
- * \param[in] interface The CAN interface to listen to
-
- * \details This method is the backend method for all the
- * constructors. This creates a socketbinds it to the given interface and
- * hooks it up to the reactor.
- */
-void
-RAWCANListener::Init (Reactor *reactor, Factory *factory, const char *interface)
-{
- int iret;
-
- ASSERT ((factory != NULL), "checking parameters");
- ASSERT ((reactor != NULL), "checking parameters");
- ASSERT ((interface != NULL), "checking parameters");
-
- m_Factory = factory;
- m_Reactor = reactor;
- strncpy(m_Interface, interface, strlen(interface) + 1);
-
- /* Create the socket */
- m_Socket = socket( PF_CAN, SOCK_RAW, CAN_RAW );
- if (m_Socket == -1)
- {
- THROW (RunTimeError,
- "RAWCANListener: %s : creating socket to listen on %s",
- strerror (errno), m_Interface);
- }
-
- /* Locate the interface we wish to use */
- struct ifreq ifr;
- strcpy(ifr.ifr_name, m_Interface);
- iret = ioctl(m_Socket, SIOCGIFINDEX, &ifr); /* ifr.ifr_ifindex gets filled
- * with that device's index */
- if (iret < 0)
- {
- close(m_Socket);
- THROW (RunTimeError,
- "RAWCANListener: %s : locating interface (ioctl) %s",
- strerror (errno), m_Interface);
- }
-
- /* Select that CAN interface, and bind the socket to it. */
- struct sockaddr_can addr;
- addr.can_family = AF_CAN;
- addr.can_ifindex = ifr.ifr_ifindex;
-
- iret = bind(m_Socket, (struct sockaddr*)&addr, sizeof(addr));
- if (iret < 0)
- {
- close(m_Socket);
- THROW (RunTimeError,
- "RAWCANListener: %s : binding CAN to %s",
- strerror (errno), m_Interface);
- }
-
- /* register the non-blocking FD with the reactor */
- SetFDAsNonBlocking (m_Socket);
- Protocol *proto;
- /* create a protocol using the factory */
- RAWCANTransport *trans;
- trans = new RAWCANTransport (m_Reactor, m_Socket);
- proto = m_Factory->GetProtocol (trans);
- proto->BuildProtocol ();
-}
-
-/*
- Local Variables:
- mode: c++
- indent-tabs-mode: nil
- tab-width: 4
- c-file-style: "gnu"
- End:
-*/
Deleted: trunk/src/RAWCANTransport.cxx
===================================================================
--- trunk/src/RAWCANTransport.cxx 2009-04-16 13:21:54 UTC (rev 55)
+++ trunk/src/RAWCANTransport.cxx 2009-04-16 13:24:59 UTC (rev 56)
@@ -1,138 +0,0 @@
-/********************************************************************
- * Copyright (C) 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All
- * rights reserved.
- *
- * This program and the accompanying materials are made available
- * under the terms described in the LICENSE file which accompanies
- * this distribution. If the LICENSE file was not attached to this
- * distribution or for further clarifications, please contact
- * le...@hi....
- *
- *******************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include <asycxx-config.h>
-#endif
-
-#include <errno.h>
-#include <unistd.h>
-#include <string.h>
-#include <deque>
-
-#include <sys/socket.h>
-#include <errno.h>
-
-#include "asycxx-common.h"
-#include <asycxx/Error.h>
-#include <asycxx/Protocol.h>
-#include <asycxx/RAWCANTransport.h>
-
-#define RAW_CAN_FRAME_SIZE 16
-
-RAWCANTransport::RAWCANTransport (Reactor *reactor, int fd)
- : Transport (reactor, fd)
-{
- ctorLOG (__FUNCTION__);
- configureReadBufferSize (RAW_CAN_FRAME_SIZE);
-}
-
-
-RAWCANTransport::~RAWCANTransport ()
-{
- dtorLOG(__FUNCTION__);
-}
-
-
-Result
-RAWCANTransport::doRead (DataBuffer *data)
-{
- ASSERT ((data != NULL), "checking parameters");
- ssize_t rlen;
-
- __doRead__again:
- rlen = read (m_Fd, data->Data(), data->BufferLen());
- if (rlen == -1)
- {
- if (errno == EINTR)
- {
- goto __doRead__again;
- }
- else if (errno == EAGAIN)
- {
- data->Len(0);
- return Result_Success;
- }
- else
- {
- ERR ("%s: reading from fd=%d", strerror(errno), m_Fd);
- return Result_Error;
- }
- }
-
- /* check for end-of-file */
- if (rlen == 0)
- {
- ERR ("EoF on fd=%d", m_Fd);
- return Result_Error;
- }
- data->Len(rlen);
-
- return Result_Success;
-}
-
-Result
-RAWCANTransport::doWrite (void)
-{
- ssize_t wrote;
- ssize_t wlen, to_wlen;
- DataBuffer *data;
- void *bfr;
-
- wrote = 0;
- while (m_writeBuffers.size() > 0)
- {
- data = m_writeBuffers[0];
- to_wlen = data->Len() - data->Processed();
- bfr = data->UnProcessed ();
-
- wlen = write (m_Fd, bfr, to_wlen);
- if (wlen == -1)
- {
- if (errno == EINTR) { continue; }
- else if (errno == EAGAIN) { return Result_Pending; }
- else
- {
- ERR ("%s: writing DataBuffer<%p>::data<%p>,len=%d to fd=%d",
- strerror (errno), data, bfr, to_wlen, m_Fd);
- return Result_Error;
- }
- }
-
- /* update pointers */
- data->Processed((data->Processed() + wlen));
- wrote += wlen;
-
- if (data->Processed() == data->Len())
- {
- m_writeBuffers.pop_front();
- data->DisOwn();
- }
- }
-
- return Result_Success;
-}
-
-void
-RAWCANTransport::doDisconnect (void)
-{
-
-}
-
-/*
- Local Variables:
- mode: c++
- indent-tabs-mode: nil
- tab-width: 4
- c-file-style: "gnu"
- End:
-*/
Added: trunk/src/RawCANListener.cxx
===================================================================
--- trunk/src/RawCANListener.cxx (rev 0)
+++ trunk/src/RawCANListener.cxx 2009-04-16 13:24:59 UTC (rev 56)
@@ -0,0 +1,166 @@
+/********************************************************************
+ * Copyright (C) 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All
+ * rights reserved.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms described in the LICENSE file which accompanies
+ * this distribution. If the LICENSE file was not attached to this
+ * distribution or for further clarifications, please contact
+ * le...@hi....
+ *
+ *******************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <asycxx-config.h>
+#endif
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netinet/tcp.h>
+#include <net/if.h>
+#include <linux/can.h>
+#include <linux/can/raw.h>
+
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include "asycxx-common.h"
+#include <asycxx/Error.h>
+#include <asycxx/Protocol.h>
+#include <asycxx/RawCANTransport.h>
+#include <asycxx/RawCANListener.h>
+
+
+#include <sys/ioctl.h>
+
+/* At time of writing, these constants are not defined in the headers */
+#ifndef PF_CAN
+#define PF_CAN 29
+#endif
+
+#ifndef AF_CAN
+#define AF_CAN PF_CAN
+#endif
+
+using namespace asycxx;
+/**
+ * \brief ctor to put RawCANListener on interface
+ *
+ * \param[in] reactor The reactor to hook to
+ * \param[in] factory The factory to use to produce protocols to
+ * handle new connections
+ * \param[in] interface The CAN interface to listen to
+ *
+ * \details This constructor puts the RawCANListener object to listen on
+ * the specified interface.
+ */
+RawCANListener::RawCANListener (Reactor *reactor, RawCANProtocolFactory *factory,
+ const char *interface)
+{
+ Init (reactor, factory, interface);
+}
+
+
+/*
+ * \brief dtor
+ */
+RawCANListener::~RawCANListener ()
+{
+ if (m_Socket != -1)
+ {
+ close (m_Socket);
+ }
+}
+
+
+/**
+ * \brief Initialize the RawCANListener
+ *
+ * \param[in] reactor The reactor to hook to
+ * \param[in] factory The factory to use to produce protocols
+ * \param[in] interface The CAN interface to listen to
+
+ * \details This method is the backend method for all the
+ * constructors. This creates a socketbinds it to the given interface and
+ * hooks it up to the reactor.
+ */
+void
+RawCANListener::Init (Reactor *reactor, RawCANProtocolFactory *factory, const char *interface)
+{
+ LOG1("%s", __FUNCTION__);
+ int iret;
+
+ ASSERT ((factory != NULL), "checking parameters");
+ ASSERT ((reactor != NULL), "checking parameters");
+ ASSERT ((interface != NULL), "checking parameters");
+
+ m_Factory = factory;
+ m_Reactor = reactor;
+ strncpy(m_Interface, interface, strlen(interface) + 1);
+
+ /* Create the socket */
+ m_Socket = socket( PF_CAN, SOCK_RAW, CAN_RAW );
+ if (m_Socket == -1)
+ {
+ THROW (RunTimeError,
+ "RawCANListener: %s : creating socket to listen on %s",
+ strerror (errno), m_Interface);
+ }
+
+ /* Locate the interface we wish to use */
+ struct ifreq ifr;
+ strcpy(ifr.ifr_name, m_Interface);
+ iret = ioctl(m_Socket, SIOCGIFINDEX, &ifr); /* ifr.ifr_ifindex gets filled
+ * with that device's index */
+ if (iret < 0)
+ {
+ close(m_Socket);
+ THROW (RunTimeError,
+ "RawCANListener: %s : locating interface (ioctl) %s",
+ strerror (errno), m_Interface);
+ }
+
+ /* Select that CAN interface, and bind the socket to it. */
+ struct sockaddr_can addr;
+ addr.can_family = AF_CAN;
+ addr.can_ifindex = ifr.ifr_ifindex;
+
+// int newMaxBuff=512000;
+// iret = setsockopt(m_Socket, SOL_SOCKET, SO_RCVBUF, &newMaxBuff, sizeof(newMaxBuff));
+// if (iret < 0)
+// {
+// LOG1("Cannot set socket buffer size to %d", newMaxBuff);
+// }
+
+ iret = bind(m_Socket, (struct sockaddr*)&addr, sizeof(addr));
+ if (iret < 0)
+ {
+ close(m_Socket);
+ THROW (RunTimeError,
+ "RawCANListener: %s : binding CAN to %s",
+ strerror (errno), m_Interface);
+ }
+
+ /* register the non-blocking FD with the reactor */
+ SetFDAsNonBlocking (m_Socket);
+ Fd (m_Socket);
+ /* hook ourselves to the reactor */
+ RawCANProtocol *proto;
+ /* create a protocol using the factory */
+ RawCANTransport *trans;
+ trans = new RawCANTransport (m_Reactor, m_Socket);
+ proto = m_Factory->GetProtocol (trans);
+ trans->setProtocol (proto);
+}
+
+/*
+ Local Variables:
+ mode: c++
+ indent-tabs-mode: nil
+ tab-width: 4
+ c-file-style: "gnu"
+ End:
+*/
Added: trunk/src/RawCANTransport.cxx
===================================================================
--- trunk/src/RawCANTransport.cxx (rev 0)
+++ trunk/src/RawCANTransport.cxx 2009-04-16 13:24:59 UTC (rev 56)
@@ -0,0 +1,241 @@
+/********************************************************************
+ * Copyright (C) 2008,2009 HiPro IT Solutions Pvt. Ltd., Chennai. All
+ * rights reserved.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms described in the LICENSE file which accompanies
+ * this distribution. If the LICENSE file was not attached to this
+ * distribution or for further clarifications, please contact
+ * le...@hi....
+ *
+ *******************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <asycxx-config.h>
+#endif
+
+#include <errno.h>
+#include <unistd.h>
+#include <string.h>
+#include <deque>
+
+#include <sys/socket.h>
+#include<linux/can.h>
+#include <errno.h>
+
+#include "asycxx-common.h"
+#include <asycxx/Error.h>
+#include <asycxx/RawCANProtocol.h>
+#include <asycxx/RawCANTransport.h>
+
+#define RAW_CAN_FRAME_SIZE 16
+
+using namespace asycxx;
+
+RawCANTransport::RawCANTransport (Reactor *reactor, int fd)
+ : DatagramTransport (reactor, fd)
+{
+ ctorLOG (__FUNCTION__);
+}
+
+
+RawCANTransport::~RawCANTransport ()
+{
+ DataBuffer *data;
+
+ /* discard the DataBuffers in the pending queue */
+ std::list<DataBuffer *>::iterator it;
+ for (it = m_writeBuffers.begin(); it != m_writeBuffers.end(); it++)
+ {
+ data = *it;
+ ERR ("Transport<%p> dumping write-buffer <%p>, len=%d",
+ this, data->Data(), data->Len());
+ data->DisOwn ();
+ }
+}
+
+/* Method to Write a buffer. This method should queue the buffer for
+ * writing. The actual writing should happen later when the
+ * file-handle becomes writable. */
+void
+RawCANTransport::Send (DataBuffer *data, uint32_t can_id)
+{
+// LOG1("%s", __FUNCTION__);
+ ASSERT ((data != NULL), "given data-buffer is NULL");
+ ASSERT ((data->Len() <= 8),
+ "frame data greater than 8 bytes");
+ DataBuffer *canframe = new DataBuffer(sizeof(struct can_frame));
+ struct can_frame *frame= (struct can_frame *) canframe->Data();
+ memcpy((void*)frame->data, (void*) data->Data(), data->Len());
+ frame->can_dlc = data->Len();
+ frame->can_id = can_id;
+ canframe->Len(sizeof(struct can_frame));
+
+ /* add the DataBuffer to the queue */
+ m_writeBuffers.push_back (canframe);
+ /* assume ownership of the given data-buffer. we do this last so
+ that any exception in the middle does not cause a leak */
+
+}
+
+/* This method is called by the reactor when the transport becomes
+ readable */
+void
+RawCANTransport::Readable (void)
+{
+ DataBuffer *data;
+ RetCode ret;
+ RawCANProtocol *proto;
+ proto = getProtocol ();
+
+ /** \todo: should use ioctl(m_Fd, SIOCINQ) to find the amount of
+ * unread data in the socket and then construct the DataBuffer. This
+ * should be done in the 'doRead' coz, Transport does not know what
+ * kind of file-descriptor we have with us. */
+
+ /* Read till there is no more */
+ while (1)
+ {
+ data = new DataBuffer (sizeof(struct can_frame));
+
+ /* call the sub-classes read-method to fill up the
+ data-buffer */
+ ret = doRead (data);
+ if (ret != RetCode_Success)
+ {
+ /* reading from transport failed */
+ data->DisOwn ();
+ proto->ReadError ();
+ break;
+ }
+
+ if (data->Len() == 0)
+ {
+ /* If there is no more to read, then get out */
+ data->DisOwn ();
+ break;
+ }
+
+ /* give data-buffer to the protocol. after this point, the
+ Protocol takes responsibility for the data-buffer object */
+ proto->DataAvailable (data);
+ data->DisOwn ();
+ }
+ return;
+}
+
+
+/* This method is called by the reactor when a 'Selectable' becomes
+ * writable. */
+void
+RawCANTransport::Writable (void)
+{
+ DatagramProtocol *proto;
+ proto = getProtocol ();
+ RetCode ret;
+
+ /* call the base-class method to write the pending buffers */
+ ret = doWrite ();
+ if (ret == RetCode_Error)
+ {
+ /* writing to transport failed */
+ proto->WriteError ();
+ }
+ if (ret == RetCode_Success)
+ {
+ /* nothing more to write */
+ stopWriting();
+ }
+ return;
+}
+
+RetCode
+RawCANTransport::doRead (DataBuffer *data)
+{
+ ASSERT ((data != NULL), "checking parameters");
+ ssize_t rlen;
+
+ __doRead__again:
+ rlen = read (Fd(), data->Data(), data->BufferLen());
+ if (rlen == -1)
+ {
+ if (errno == EINTR)
+ {
+ goto __doRead__again;
+ }
+ else if (errno == EAGAIN)
+ {
+ data->Len(0);
+ return RetCode_Success;
+ }
+ else
+ {
+ ERR ("%s: reading from fd=%d", strerror(errno), Fd());
+ return RetCode_Error;
+ }
+ }
+
+ /* check for end-of-file */
+ if (rlen == 0)
+ {
+ ERR ("EoF on fd=%d", Fd());
+ return RetCode_Error;
+ }
+ data->Len(rlen);
+
+ return RetCode_Success;
+}
+
+RetCode
+RawCANTransport::doWrite (void)
+{
+ ssize_t wrote;
+ ssize_t wlen, to_wlen;
+ DataBuffer *data;
+ void *bfr;
+ std::list<DataBuffer *>::iterator it;
+
+ wrote = 0;
+ it = m_writeBuffers.begin();
+ while (it != m_writeBuffers.end())
+ {
+ data = *it;
+ to_wlen = data->Len() - data->Processed();
+ bfr = data->UnProcessed ();
+
+ wlen = write (Fd(), bfr, to_wlen);
+ if (wlen == -1)
+ {
+ if (errno == EINTR) { continue; }
+ else if (errno == EAGAIN) { return RetCode_Pending; }
+ else
+ {
+ ERR ("%s: writing DataBuffer<%p>::data<%p>,len=%d to fd=%d",
+ strerror (errno), data, bfr, to_wlen, Fd());
+ return RetCode_Error;
+ }
+ }
+
+ /* update pointers */
+ data->Processed((data->Processed() + wlen));
+ wrote += wlen;
+
+ if (data->Processed() == data->Len())
+ {
+ it = m_writeBuffers.erase(it);
+ data->DisOwn();
+ }
+ }
+
+ return RetCode_Success;
+}
+
+
+/*
+ Local Variables:
+ mode: c++
+ indent-tabs-mode: nil
+ tab-width: 4
+ c-file-style: "gnu"
+ End:
+*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <viv...@us...> - 2009-04-16 13:22:03
|
Revision: 55
http://asycxx.svn.sourceforge.net/asycxx/?rev=55&view=rev
Author: vivekanand83
Date: 2009-04-16 13:21:54 +0000 (Thu, 16 Apr 2009)
Log Message:
-----------
Reflecting changes from r53 [ticket:11]GMB complains bad signature. [Fixed]
Modified Paths:
--------------
trunk/src/GimpleMsgBus.cxx
Modified: trunk/src/GimpleMsgBus.cxx
===================================================================
--- trunk/src/GimpleMsgBus.cxx 2009-04-16 13:14:18 UTC (rev 54)
+++ trunk/src/GimpleMsgBus.cxx 2009-04-16 13:21:54 UTC (rev 55)
@@ -77,7 +77,6 @@
ASSERT ((dleft != 0), "got an empty DataBuffer??");
ASSERT ((data_ptr != NULL), "DataBuffer has a NULL buffer");
-
/* loop till we have bytes left to process */
while (dleft != 0)
{
@@ -90,7 +89,7 @@
getTransport()->loseConnection ();
return;
}
- data_ptr = (void *)((unsigned int)data->Data() + processed);
+ data_ptr = (void *)((unsigned int)data_ptr + processed);
dleft -= processed;
break;
@@ -101,7 +100,7 @@
getTransport()->loseConnection ();
return;
}
- data_ptr = (void *)((unsigned int)data->Data() + processed);
+ data_ptr = (void *)((unsigned int)data_ptr + processed);
dleft -= processed;
break;
};
@@ -149,13 +148,13 @@
if (memcmp ((void *)&sign, (void *)&m_Hdr.signature, 4) != 0)
{
processed = 0;
- ERR ("bad signature");
+ ERR ("bad signature in header '%c', '%c', '%c', %c", m_Hdr.signature[0],
+ m_Hdr.signature[1], m_Hdr.signature[2], m_Hdr.signature[3]);
return RetCode_Error;
}
/* converting byte-order from network to host */
m_Hdr.len = ntohl (m_Hdr.len);
-
/* setup the next state */
m_State = GMB_MsgHarvestInProgress;
m_Payload = new DataBuffer (m_Hdr.len);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <viv...@us...> - 2009-04-16 13:14:21
|
Revision: 54
http://asycxx.svn.sourceforge.net/asycxx/?rev=54&view=rev
Author: vivekanand83
Date: 2009-04-16 13:14:18 +0000 (Thu, 16 Apr 2009)
Log Message:
-----------
removed reference of asycxx-config.h from StreamProtocol*.h
Modified Paths:
--------------
trunk/include/asycxx/StreamProtocol.h
trunk/include/asycxx/StreamProtocolFactory.h
Modified: trunk/include/asycxx/StreamProtocol.h
===================================================================
--- trunk/include/asycxx/StreamProtocol.h 2009-04-08 11:28:12 UTC (rev 53)
+++ trunk/include/asycxx/StreamProtocol.h 2009-04-16 13:14:18 UTC (rev 54)
@@ -14,9 +14,6 @@
#ifndef __HIPRO_ASYCXX__STREAM_PROTOCOL_H__
#define __HIPRO_ASYCXX__STREAM_PROTOCOL_H__
-#ifdef HAVE_CONFIG_H
-#include <asycxx-config.h>
-#endif
#include "Error.h"
#include "Reactor.h"
Modified: trunk/include/asycxx/StreamProtocolFactory.h
===================================================================
--- trunk/include/asycxx/StreamProtocolFactory.h 2009-04-08 11:28:12 UTC (rev 53)
+++ trunk/include/asycxx/StreamProtocolFactory.h 2009-04-16 13:14:18 UTC (rev 54)
@@ -14,10 +14,6 @@
#ifndef __HIPRO_ASYCXX__STREAM_PROTOCOL_FACTORY_H__
#define __HIPRO_ASYCXX__STREAM_PROTOCOL_FACTORY_H__
-#ifdef HAVE_CONFIG_H
-#include <asycxx-config.h>
-#endif
-
#include "Error.h"
#include "Reactor.h"
#include "ProtocolFactory.h"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: vivek <vi...@hi...> - 2009-04-16 12:37:04
|
-- Vivek Anand HiPro IT Solutions |
|
From: <viv...@us...> - 2009-04-08 11:28:27
|
Revision: 53
http://asycxx.svn.sourceforge.net/asycxx/?rev=53&view=rev
Author: vivekanand83
Date: 2009-04-08 11:28:12 +0000 (Wed, 08 Apr 2009)
Log Message:
-----------
[ticket:11]GMB complains bad signature. [Fixed]
Modified Paths:
--------------
tags/releases/0.1.1/src/GimpleMsgBus.cxx
Modified: tags/releases/0.1.1/src/GimpleMsgBus.cxx
===================================================================
--- tags/releases/0.1.1/src/GimpleMsgBus.cxx 2009-04-08 07:50:14 UTC (rev 52)
+++ tags/releases/0.1.1/src/GimpleMsgBus.cxx 2009-04-08 11:28:12 UTC (rev 53)
@@ -89,7 +89,7 @@
m_Transport->LoseConnection ();
return;
}
- data_ptr = (void *)((unsigned int)data->Data() + processed);
+ data_ptr = (void *)((unsigned int)data_ptr + processed);
dleft -= processed;
break;
@@ -100,7 +100,7 @@
m_Transport->LoseConnection ();
return;
}
- data_ptr = (void *)((unsigned int)data->Data() + processed);
+ data_ptr = (void *)((unsigned int)data_ptr + processed);
dleft -= processed;
break;
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <joe...@us...> - 2009-04-08 07:50:16
|
Revision: 52
http://asycxx.svn.sourceforge.net/asycxx/?rev=52&view=rev
Author: joe_steeve
Date: 2009-04-08 07:50:14 +0000 (Wed, 08 Apr 2009)
Log Message:
-----------
removed CAN related files fromt the build
CAN related code is not ported to the changes in other parts of asycxx
yet. Hence disabling it for now.
From: Joe Steeve <js...@hi...>
Modified Paths:
--------------
trunk/examples/Makefile.am
trunk/include/Makefile.am
trunk/src/Makefile.am
Modified: trunk/examples/Makefile.am
===================================================================
--- trunk/examples/Makefile.am 2009-04-08 07:49:25 UTC (rev 51)
+++ trunk/examples/Makefile.am 2009-04-08 07:50:14 UTC (rev 52)
@@ -1,2 +1,2 @@
-SUBDIRS = echoserver canserver
+SUBDIRS = echoserver #canserver
Modified: trunk/include/Makefile.am
===================================================================
--- trunk/include/Makefile.am 2009-04-08 07:49:25 UTC (rev 51)
+++ trunk/include/Makefile.am 2009-04-08 07:50:14 UTC (rev 52)
@@ -23,7 +23,8 @@
asycxx/MsgHandler.h \
asycxx/GimpleMsgBus.h \
asycxx/_asycxx.h \
- asycxx/asycxx.h \
- asycxx/RAWCANTransport.h \
- asycxx/RAWCANListener.h
+ asycxx/asycxx.h
+# asycxx/RAWCANTransport.h \
+# asycxx/RAWCANListener.h
+
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2009-04-08 07:49:25 UTC (rev 51)
+++ trunk/src/Makefile.am 2009-04-08 07:50:14 UTC (rev 52)
@@ -20,11 +20,12 @@
StreamProtocol.cxx \
MsgBus.cxx \
GimpleMsgBus.cxx \
- core.cxx \
- RAWCANTransport.cxx \
- RAWCANListener.cxx
+ core.cxx
+# RAWCANTransport.cxx \
+# RAWCANListener.cxx
+
libasycxx_0_1_la_CPPFLAGS = -I$(top_srcdir)/include
libasycxx_0_1_la_CXXFLAGS = -O2
libasycxx_0_1_la_LDFLAGS = -version-info 0:1:0
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <joe...@us...> - 2009-04-08 07:49:27
|
Revision: 51
http://asycxx.svn.sourceforge.net/asycxx/?rev=51&view=rev
Author: joe_steeve
Date: 2009-04-08 07:49:25 +0000 (Wed, 08 Apr 2009)
Log Message:
-----------
added Timer.* to the build system
From: Joe Steeve <js...@hi...>
Modified Paths:
--------------
trunk/include/Makefile.am
trunk/src/Makefile.am
Modified: trunk/include/Makefile.am
===================================================================
--- trunk/include/Makefile.am 2009-04-08 07:48:45 UTC (rev 50)
+++ trunk/include/Makefile.am 2009-04-08 07:49:25 UTC (rev 51)
@@ -3,6 +3,7 @@
pkginclude_HEADERS = \
asycxx/Logger.h \
asycxx/Error.h \
+ asycxx/Timer.h \
asycxx/RefCounter.h \
asycxx/DataBuffer.h \
asycxx/Reactor.h \
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2009-04-08 07:48:45 UTC (rev 50)
+++ trunk/src/Makefile.am 2009-04-08 07:49:25 UTC (rev 51)
@@ -8,6 +8,7 @@
Error.cxx \
DataBuffer.cxx \
Reactor.cxx \
+ Timer.cxx \
SelectReactor.cxx \
Transport.cxx \
StreamTransport.cxx \
@@ -24,8 +25,6 @@
RAWCANListener.cxx
-# Timer.cxx
-
libasycxx_0_1_la_CPPFLAGS = -I$(top_srcdir)/include
libasycxx_0_1_la_CXXFLAGS = -O2
libasycxx_0_1_la_LDFLAGS = -version-info 0:1:0
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <joe...@us...> - 2009-04-08 07:48:50
|
Revision: 50
http://asycxx.svn.sourceforge.net/asycxx/?rev=50&view=rev
Author: joe_steeve
Date: 2009-04-08 07:48:45 +0000 (Wed, 08 Apr 2009)
Log Message:
-----------
updated Reactor to update the timer manager
From: Joe Steeve <js...@hi...>
Modified Paths:
--------------
trunk/src/Reactor.cxx
Modified: trunk/src/Reactor.cxx
===================================================================
--- trunk/src/Reactor.cxx 2009-04-08 07:48:12 UTC (rev 49)
+++ trunk/src/Reactor.cxx 2009-04-08 07:48:45 UTC (rev 50)
@@ -22,6 +22,7 @@
#include <asycxx/Reactor.h>
#include <asycxx/Selectable.h>
#include <asycxx/Error.h>
+#include <asycxx/Timer.h>
using namespace asycxx;
@@ -33,6 +34,7 @@
Reactor::Reactor ()
{
m_LastAwokenTS = GetCurrentTimeStamp();
+ Timer::Init (this);
}
@@ -153,7 +155,7 @@
ProcessEvents ();
/* update the timer so that it can fire timeouts */
- /* TODO: update the timer here */
+ Timer::CheckAndFireTimers ();
/* cleanup the event lists of dead 'Selectable's */
CleanupEventLists ();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <joe...@us...> - 2009-04-08 07:48:14
|
Revision: 49
http://asycxx.svn.sourceforge.net/asycxx/?rev=49&view=rev
Author: joe_steeve
Date: 2009-04-08 07:48:12 +0000 (Wed, 08 Apr 2009)
Log Message:
-----------
fixed class:Timer to not use Deferreds
The timer is now fired directly from the reactor
From: Joe Steeve <js...@hi...>
Modified Paths:
--------------
trunk/include/asycxx/Timer.h
trunk/src/Timer.cxx
Modified: trunk/include/asycxx/Timer.h
===================================================================
--- trunk/include/asycxx/Timer.h 2009-04-08 07:47:28 UTC (rev 48)
+++ trunk/include/asycxx/Timer.h 2009-04-08 07:48:12 UTC (rev 49)
@@ -15,70 +15,131 @@
#define __HIPRO_ASYCXX__TIMER_H__
-#include <vector>
+#include <list>
#include "Reactor.h"
+namespace asycxx
+{
+ /**
+ * \brief Timer's callback function type
+ *
+ * \param[in] obj The context-object to use for the callback
+ * \param[in] excess_time The number of milli-seconds elapsed after
+ * the configured timeout period. Consult the documentation of Timer
+ * for more information on this.
+ */
+ typedef void (*cbTimerCallback_t)(void *obj, asycxx_msecs_t excess_time);
-/**
- * \brief Timer's callback function type
- *
- * \param[in] obj The context-object to use for the callback
- * \param[in] excess_time The number of milli-seconds elapsed after the
- * configured timeout period. Consult the documentation of Timer for
- * more information on this.
- */
-typedef void (*cbTimerCallback_t)(void *obj, h_msecs_t excess_time);
-
#define ASYCXX_TIMER_RESOLUTION 200
-class Timer
-{
-public:
-
/**
- * \brief Timer type
+ * \class Timer
+ * \brief A timer that fires on a configured timeout.
*
- * \detail The timer-type changes the behaviour of the
- * timer. Consult the documentation of Timer class for more
- * information.
+ * \details The Timer fires when its configured timeout-time
+ * elapses. This class hooks itself with the reactor to keep track
+ * of time. On successful creation, when the timeout-time elapses,
+ * it calls a callback. A timer can be either active or
+ * in-active. This can be controlled using the Timer::StartTimer and
+ * Timer::StopTimer methods.
+ *
+ * There are two types of timers supported by this class and are
+ * defined in the enumeration Timer::TimerType.
+ *
+ * (1) Timer_OneShot: This fires exactly one-time and then goes to
+ * inactive mode. This can be brought back to active mode using
+ * Timer::StartTimer
+ *
+ * (2) Timer_Periodic: This fires every time the timeout occurs.
+ *
+ * The callback function is of the type cbTimerCallback_t. It takes
+ * two parameters. The 'excess_time' parameter in the callback
+ * contains the number of milli-seconds that exceeded the timeout.
*/
- enum TimerType
- {
- Timer_OneShot, /**< A one-shot timer. Fires only once */
- Timer_Periodic, /**< A periodic timer. Fires periodically */
- };
- static void Init (Reactor *reactor);
- static void UpdateTimers (h_timestamp_t currentTS);
-
- Timer (h_msecs_t timeoutTime, TimerType type,
- cbTimerCallback_t cb_fn, void * cb_obj);
- ~Timer ();
- void StartTimer (void);
- void StopTimer (void);
+ class Timer
+ {
+ public:
-private:
- static Reactor *m_Reactor;
- static std::vector<Timer *> m_Timers;
- static h_timestamp_t m_LastUpdatedTS;
- static Deferred *m_ReactorDeferred;
- static void RegisterTimer (Timer *timer);
- static void UnRegisterTimer (Timer *timer);
- static void CheckAndFireTimers (void *obj, h_msecs_t excess_time);
+ /**
+ * \brief Timer type
+ *
+ * \detail The timer-type changes the behaviour of the
+ * timer. Consult the documentation of Timer class for more
+ * information.
+ */
+ enum TimerType
+ {
+ Timer_OneShot, /**< A one-shot timer. Fires only once */
+ Timer_Periodic, /**< A periodic timer. Fires periodically */
+ };
+
+ Timer (asycxx_msecs_t timeoutTime, TimerType type,
+ cbTimerCallback_t cb_fn, void * cb_obj);
+ ~Timer ();
- enum TimerType m_Type;
- bool m_bTimerActive;
- h_msecs_t m_TimeoutTime;
- h_timestamp_t m_LastTriggerTS;
- h_timestamp_t m_NextTriggerTS;
+ /**
+ * \brief Puts the timer in active mode
+ *
+ * \detail This method puts the timer in active mode. When in
+ * active mode, the timer fires when a timeout happens.
+ */
+ void StartTimer (void);
- cbTimerCallback_t m_cbFunction;
- void * m_cbObject;
-};
+ /**
+ * \brief Puts the timer in in-active mode
+ *
+ * \detail This method puts the timer in in-active mode. All
+ * timeouts are lost.
+ */
+ void StopTimer (void);
+ /**
+ * \brief One time timer initialization method
+ *
+ * \param[in] reactor The reactor object to hook to
+ *
+ * \details This method is a static method which Initializes the
+ * 'Timer' class. This should be called before creating any timer
+ * objects.
+ */
+ static void Init (Reactor *reactor);
+ /**
+ * \brief Check for expired timers and fire them
+ *
+ * \details This method iterates through the global list of timers
+ * and fires the ones that have expired
+ */
+ static void CheckAndFireTimers (void);
+
+ private:
+ /* static data and methods */
+ static Reactor *m_Reactor;
+ static std::list<Timer *> m_Timers;
+ static asycxx_timestamp_t m_LastUpdatedTS;
+
+ /* convenience methods to register/unregister a timer from the
+ global list of timers */
+ static void RegisterTimer (Timer *timer);
+ static void UnRegisterTimer (Timer *timer);
+
+ private:
+ /* non-static data */
+ enum TimerType m_Type;
+ bool m_bTimerActive;
+
+ asycxx_msecs_t m_TimeoutTime;
+ asycxx_timestamp_t m_LastTriggerTS;
+ asycxx_timestamp_t m_NextTriggerTS;
+
+ cbTimerCallback_t m_cbFunction;
+ void * m_cbObject;
+ };
+}
+
#endif /* __HIPRO_ASYCXX__TIMER_H__ */
/*
Modified: trunk/src/Timer.cxx
===================================================================
--- trunk/src/Timer.cxx 2009-04-08 07:47:28 UTC (rev 48)
+++ trunk/src/Timer.cxx 2009-04-08 07:48:12 UTC (rev 49)
@@ -11,120 +11,72 @@
*
*******************************************************************/
-/**
- * \author Joe Steeve, jo...@hi...
- * \class Timer
- * \brief A timer that fires on a configured timeout.
- *
- * \details The Timer fires when its configured timeout-time
- * elapses. This class hooks itself with the reactor to keep track of
- * time. On successful creation, when the timeout-time elapses, it
- * calls a callback. A timer can be either active or in-active. This
- * can be controlled using the Timer::StartTimer and Timer::StopTimer
- * methods.
- *
- * There are two types of timers supported by this class and are
- * defined in the enumeration Timer::TimerType.
- *
- * (1) Timer_OneShot: This fires exactly one-time and then goes to
- * inactive mode. This can be brought back to active mode using
- * Timer::StartTimer
- *
- * (2) Timer_Periodic: This fires every time the timeout occurs.
- *
- * The callback function is of the type cbTimerCallback_t. It takes
- * two parameters. The 'excess_time' parameter in the callback
- * contains the number of milli-seconds that exceeded the timeout.
- */
#ifdef HAVE_CONFIG_H
#include <asycxx-config.h>
#endif
-#include <vector>
+#include <list>
#include "asycxx-common.h"
#include <asycxx/Error.h>
#include <asycxx/Timer.h>
-/*****************************************************************************/
+using namespace asycxx;
+
Reactor * Timer::m_Reactor = NULL;
-std::vector<Timer *> Timer::m_Timers;
-h_timestamp_t Timer::m_LastUpdatedTS = 0LL;
-Deferred * Timer::m_ReactorDeferred = NULL;
+std::list<Timer *> Timer::m_Timers;
+asycxx_timestamp_t Timer::m_LastUpdatedTS = 0LL;
-/**
- * \brief Initialize the Timer class.
- *
- * \param[in] reactor The reactor object to hook to
- *
- * \details This method is a static method which Initializes the
- * 'Timer' class. This should be called before creating any timer
- * objects.
- */
+/* this must be called from the reactor at the time of
+ * initialization */
void
Timer::Init (Reactor *reactor)
{
- if (reactor == NULL)
- { THROW (DevError, "cannot marry a <NULL> reactor. :("); }
-
+ ASSERT ((reactor != NULL), "cannot marry a <NULL> reactor. :(");
m_Reactor = reactor;
m_LastUpdatedTS = m_Reactor->CurrentTS();
-
- /* Register with the reactor */
- m_ReactorDeferred = m_Reactor->OnTimeElapsed (ASYCXX_TIMER_RESOLUTION);
- m_ReactorDeferred->OnTimeout (CheckAndFireTimers, NULL);
}
-/**
- * \brief Registers a timer with the global list of timers
- *
- * \param[in] timer The timer object that should be registered
- *
- * \details This method adds the given timer (if it does not exist
- * already) to the global list of timers. A timer object will recieve
- * a 'trigger' only when it is registered. This should be called from
- * the ctor of the timer-object.
- */
+/* This method adds the given timer (if it does not exist already) to
+ * the global list of timers. A timer object will recieve a 'trigger'
+ * only when it is registered. This should be called from the ctor of
+ * the timer-object. */
void
Timer::RegisterTimer (Timer *timer)
{
- size_t i;
-
+ /* we should tell the user if the timeout-time is is less than our
+ resolution */
if (timer->m_TimeoutTime < ASYCXX_TIMER_RESOLUTION)
{
ERR ("given timeout-time(%lld) < ASYCXX_TIMER_RESOLUTION(%lld)",
timer->m_TimeoutTime, ASYCXX_TIMER_RESOLUTION);
}
- for (i=0; i<m_Timers.size(); i++)
+ /* check if this timer is not already activated */
+ std::list<Timer *>::iterator it;
+ for (it = m_Timers.begin(); it != m_Timers.end(); it++)
{
- if (m_Timers[i] == timer) { return; }
+ if (*it == timer) { return; }
}
+ /* add the timer to the list */
m_Timers.push_back (timer);
}
-/**
- * \brief Un-registers a timer from the global list of timers
- *
- * \param[in] timer The timer object that should be un-registered
- *
- * \details This method removes the given timer from the global list
- * of timers. This should be called from the dtor of the timer-object.
- */
+/* This method removes the given timer from the global list of
+ * timers. This should be called from the dtor of the timer-object. */
void
Timer::UnRegisterTimer (Timer *timer)
{
- size_t i;
-
- for (i=0; i<m_Timers.size(); i++)
+ std::list<Timer *>::iterator it;
+ for (it = m_Timers.begin(); it != m_Timers.end(); it++)
{
- if (m_Timers[i] == timer)
+ if (*it == timer)
{
- m_Timers.erase (m_Timers.begin()+i);
+ m_Timers.erase (it);
return;
}
}
@@ -133,70 +85,57 @@
}
-/**
- * \brief Callback hooked into the reactor
- *
- * \detail This method is registered with the reactor to recieve
- * notifications on timeout of ASYCXX_TIMER_RESOLUTION milliseconds.
- */
+/* This method is registered with the reactor to recieve notifications
+ * on timeout of ASYCXX_TIMER_RESOLUTION milliseconds. */
void
-Timer::CheckAndFireTimers (void *obj, h_msecs_t excess_time)
+Timer::CheckAndFireTimers (void)
{
- h_msecs_t diffTime;
- h_timestamp_t currentTS;
- size_t i;
+ asycxx_msecs_t diffTime;
+ asycxx_timestamp_t currentTS;
+ std::list<Timer *>::iterator it;
currentTS = m_Reactor->CurrentTS();
- if (currentTS < m_LastUpdatedTS)
- {
- THROW (DevError, "Timer hooked to Reactor<%p>, "
- "current-TimeStamp(%lld) < last-updated-TimeStamp(%lld)",
- m_Reactor, currentTS, m_LastUpdatedTS);
- }
+ ASSERT ((currentTS >= m_LastUpdatedTS),
+ "Timer hooked to Reactor<%p>, "
+ "current-TimeStamp(%lld) < last-updated-TimeStamp(%lld)",
+ m_Reactor, currentTS, m_LastUpdatedTS);
/* Look through the list of timers and fire the ones that are ready
to be fired */
Timer *t;
- for (i=0; i<m_Timers.size(); i++)
+ for (it = m_Timers.begin(); it != m_Timers.end(); it++)
{
- t = m_Timers[i];
+ t = *it;
/* If trigger-time not yet arrived, go on to the next one */
- if (t->m_NextTriggerTS > currentTS)
- {
- continue;
- }
+ if (t->m_NextTriggerTS > currentTS) { continue; }
/* Fire the timer's callbacks */
diffTime = currentTS - t->m_NextTriggerTS;
t->m_cbFunction (t->m_cbObject, diffTime);
+
/* Update the timer */
t->m_LastTriggerTS = currentTS;
t->m_NextTriggerTS = currentTS + t->m_TimeoutTime;
+
/* stop a one-shot timer after firing once */
- if (t->m_Type == Timer_OneShot)
- {
- t->StopTimer ();
- }
+ if (t->m_Type == Timer_OneShot) { t->StopTimer (); }
}
m_LastUpdatedTS = currentTS;
}
+
/*****************************************************************************/
-/**
- * \brief Constructor
- *
- */
-Timer::Timer (h_msecs_t timeoutTime, TimerType type,
+
+/* ctor */
+Timer::Timer (asycxx_msecs_t timeoutTime, TimerType type,
cbTimerCallback_t cb_fn, void * cb_obj)
{
- if (timeoutTime == 0)
- { THROW (DevError, "timeoutTime=0. wait indefinitely??"); }
- if ((type < Timer::Timer_OneShot) || (type > Timer::Timer_Periodic))
- { THROW (DevError, "i dont know a timer of type=%d", type); }
- if (cb_fn == NULL)
- { THROW (DevError, "callback-function is NULL."); }
+ ASSERT ((timeoutTime != 0), "timeoutTime=0. wait indefinitely??");
+ ASSERT (((type >= Timer::Timer_OneShot) && (type <= Timer::Timer_Periodic)),
+ "i dont know a timer of type=%d", type);
+ ASSERT ((cb_fn != NULL), "callback-function is NULL.");
/* initialize the timer variables */
m_TimeoutTime = timeoutTime;
@@ -212,22 +151,14 @@
}
-/**
- * \brief Destructor
- *
- */
+/* dtor */
Timer::~Timer ()
{
StopTimer ();
}
-/**
- * \brief Puts the timer in active mode
- *
- * \detail This method puts the timer in active mode. When in active
- * mode, the timer fires when a timeout happens.
- */
+/* activate the timer */
void
Timer::StartTimer (void)
{
@@ -248,12 +179,7 @@
}
-/**
- * \brief Puts the timer in in-active mode
- *
- * \detail This method puts the timer in in-active mode. All timeouts
- * are lost.
- */
+/* de-activate the timer */
void
Timer::StopTimer (void)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <joe...@us...> - 2009-04-08 07:47:29
|
Revision: 48
http://asycxx.svn.sourceforge.net/asycxx/?rev=48&view=rev
Author: joe_steeve
Date: 2009-04-08 07:47:28 +0000 (Wed, 08 Apr 2009)
Log Message:
-----------
removed commented Timer related code
From: Joe Steeve <js...@hi...>
Modified Paths:
--------------
trunk/examples/echoserver/EchoServer.cxx
Modified: trunk/examples/echoserver/EchoServer.cxx
===================================================================
--- trunk/examples/echoserver/EchoServer.cxx 2009-04-08 07:46:47 UTC (rev 47)
+++ trunk/examples/echoserver/EchoServer.cxx 2009-04-08 07:47:28 UTC (rev 48)
@@ -15,7 +15,6 @@
#include <asycxx/Logger.h>
#include <asycxx/Error.h>
-// #include <asycxx/Timer.h>
#include <asycxx/SelectReactor.h>
#include <asycxx/StreamProtocol.h>
#include <asycxx/StreamProtocolFactory.h>
@@ -65,8 +64,6 @@
Log->EnableConsole();
reactor = new SelectReactor ();
-// Timer::Init (reactor);
-
EchoServerProtocolFactory echofactory (reactor);
TCPListener echolistener (reactor, &echofactory, (char *)"0.0.0.0",
10000);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <joe...@us...> - 2009-04-08 07:46:48
|
Revision: 47
http://asycxx.svn.sourceforge.net/asycxx/?rev=47&view=rev
Author: joe_steeve
Date: 2009-04-08 07:46:47 +0000 (Wed, 08 Apr 2009)
Log Message:
-----------
updated EchoServer to accomodate asycxx refactor
* EchoServer now uses the StreamProtocol and StreamProtocolFactory.
* Added a debug build in EchoServer's build.
From: Joe Steeve <js...@hi...>
Modified Paths:
--------------
trunk/examples/echoserver/EchoServer.cxx
trunk/examples/echoserver/Makefile.am
Modified: trunk/examples/echoserver/EchoServer.cxx
===================================================================
--- trunk/examples/echoserver/EchoServer.cxx 2009-04-08 07:46:06 UTC (rev 46)
+++ trunk/examples/echoserver/EchoServer.cxx 2009-04-08 07:46:47 UTC (rev 47)
@@ -15,37 +15,41 @@
#include <asycxx/Logger.h>
#include <asycxx/Error.h>
-#include <asycxx/Timer.h>
+// #include <asycxx/Timer.h>
#include <asycxx/SelectReactor.h>
-#include <asycxx/Protocol.h>
-#include <asycxx/Factory.h>
+#include <asycxx/StreamProtocol.h>
+#include <asycxx/StreamProtocolFactory.h>
#include <asycxx/TCPListener.h>
+using namespace asycxx;
+
Logger *Log;
-class EchoServerProtocol : public Protocol
+class EchoServerProtocol : public StreamProtocol
{
public:
- EchoServerProtocol (Reactor *reactor, Factory *factory, Transport *transport)
- : Protocol (reactor, factory, transport)
+ EchoServerProtocol (Reactor *reactor, StreamProtocolFactory *factory,
+ StreamTransport *transport)
+ : StreamProtocol (reactor, factory, transport)
{}
~EchoServerProtocol () {}
void DataAvailable (DataBuffer *data)
{
- m_Transport->Write (data);
+ getTransport()->Write (data);
}
};
-class EchoServerProtocolFactory : public Factory
+class EchoServerProtocolFactory : public StreamProtocolFactory
{
public:
- EchoServerProtocolFactory (Reactor *reactor) : Factory (reactor)
+ EchoServerProtocolFactory (Reactor *reactor)
+ : StreamProtocolFactory (reactor)
{}
~EchoServerProtocolFactory () {}
- EchoServerProtocol * GetProtocol (Transport *trans)
+ EchoServerProtocol * GetProtocol (StreamTransport *trans)
{
return new EchoServerProtocol (m_Reactor, this, trans);
}
@@ -61,7 +65,7 @@
Log->EnableConsole();
reactor = new SelectReactor ();
- Timer::Init (reactor);
+// Timer::Init (reactor);
EchoServerProtocolFactory echofactory (reactor);
TCPListener echolistener (reactor, &echofactory, (char *)"0.0.0.0",
Modified: trunk/examples/echoserver/Makefile.am
===================================================================
--- trunk/examples/echoserver/Makefile.am 2009-04-08 07:46:06 UTC (rev 46)
+++ trunk/examples/echoserver/Makefile.am 2009-04-08 07:46:47 UTC (rev 47)
@@ -1,11 +1,16 @@
-noinst_PROGRAMS = EchoServer
+noinst_PROGRAMS = EchoServer EchoServer.debug
EchoServer_SOURCES = EchoServer.cxx
EchoServer_LDADD = $(top_srcdir)/src/libasycxx-0.1.la
EchoServer_CPPFLAGS = -I$(top_srcdir)/include
EchoServer_LDFLAGS = -L$(top_srcdir)/src
+EchoServer_debug_SOURCES = $(EchoServer_SOURCES)
+EchoServer_debug_CXXFLAGS = -g $(AM_CXXFLAGS)
+EchoServer_debug_LDADD = $(top_srcdir)/src/.libs/libasycxx-dbg-0.1.a
+EchoServer_debug_CPPFLAGS = -I$(top_srcdir)/include
+#EchoServer_debug_LDFLAGS = -L$(top_srcdir)/src
# Local Variables:
# mode: makefile
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <joe...@us...> - 2009-04-08 07:46:13
|
Revision: 46
http://asycxx.svn.sourceforge.net/asycxx/?rev=46&view=rev
Author: joe_steeve
Date: 2009-04-08 07:46:06 +0000 (Wed, 08 Apr 2009)
Log Message:
-----------
we use 'asycxx' namespace by default now
From: Joe Steeve <js...@hi...>
Modified Paths:
--------------
trunk/src/core.cxx
Modified: trunk/src/core.cxx
===================================================================
--- trunk/src/core.cxx 2009-04-08 07:45:28 UTC (rev 45)
+++ trunk/src/core.cxx 2009-04-08 07:46:06 UTC (rev 46)
@@ -24,17 +24,16 @@
#include "asycxx-common.h"
#include <asycxx/Error.h>
-h_msecs_t
+using namespace asycxx;
+
+asycxx_msecs_t
GetCurrentTimeStamp (void)
{
int ret;
struct timeval currentTime;
ret = gettimeofday (¤tTime, NULL);
- if (ret != 0)
- {
- THROW (RunTimeError, "%s: reading current system time", strerror(errno));
- }
+ ASSERT ((ret == 0), "%s: reading current system time", strerror(errno));
return ((currentTime.tv_sec * 1000) + (currentTime.tv_usec / 1000));
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <joe...@us...> - 2009-04-08 07:45:29
|
Revision: 45
http://asycxx.svn.sourceforge.net/asycxx/?rev=45&view=rev
Author: joe_steeve
Date: 2009-04-08 07:45:28 +0000 (Wed, 08 Apr 2009)
Log Message:
-----------
added new files into build system. removed Timer.* from build.
Timer is still broken. So, until it is fixed, it cannot be put into the
build system.
From: Joe Steeve <js...@hi...>
Modified Paths:
--------------
trunk/include/Makefile.am
trunk/src/Makefile.am
Modified: trunk/include/Makefile.am
===================================================================
--- trunk/include/Makefile.am 2009-04-08 07:44:37 UTC (rev 44)
+++ trunk/include/Makefile.am 2009-04-08 07:45:28 UTC (rev 45)
@@ -3,7 +3,6 @@
pkginclude_HEADERS = \
asycxx/Logger.h \
asycxx/Error.h \
- asycxx/Deferred.h \
asycxx/RefCounter.h \
asycxx/DataBuffer.h \
asycxx/Reactor.h \
@@ -11,11 +10,14 @@
asycxx/Timer.h \
asycxx/Transport.h \
asycxx/Listener.h \
+ asycxx/StreamTransport.h \
asycxx/TCPTransport.h \
asycxx/TCPListener.h \
asycxx/TCPLLTransport.h \
asycxx/Protocol.h \
- asycxx/Factory.h \
+ asycxx/StreamProtocol.h \
+ asycxx/ProtocolFactory.h \
+ asycxx/StreamProtocolFactory.h \
asycxx/MsgBus.h \
asycxx/MsgHandler.h \
asycxx/GimpleMsgBus.h \
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2009-04-08 07:44:37 UTC (rev 44)
+++ trunk/src/Makefile.am 2009-04-08 07:45:28 UTC (rev 45)
@@ -1,31 +1,36 @@
# -*- mode: makefile; indent-tabs-mode: nil; tab-width: 4; -*-
-lib_LTLIBRARIES = libasycxx-0.1.la
+lib_LTLIBRARIES = libasycxx-0.1.la libasycxx-dbg-0.1.la
libasycxx_0_1_la_SOURCES = \
Logger.cxx \
+ RefCounter.cxx \
Error.cxx \
- Deferred.cxx \
- RefCounter.cxx \
DataBuffer.cxx \
Reactor.cxx \
SelectReactor.cxx \
- Timer.cxx \
Transport.cxx \
- Listener.cxx \
+ StreamTransport.cxx \
+ ProtocolFactory.cxx \
TCPTransport.cxx \
TCPListener.cxx \
TCPLLTransport.cxx \
Protocol.cxx \
- Factory.cxx \
+ StreamProtocol.cxx \
MsgBus.cxx \
- MsgHandler.cxx \
GimpleMsgBus.cxx \
core.cxx \
RAWCANTransport.cxx \
RAWCANListener.cxx
+# Timer.cxx
+
libasycxx_0_1_la_CPPFLAGS = -I$(top_srcdir)/include
libasycxx_0_1_la_CXXFLAGS = -O2
libasycxx_0_1_la_LDFLAGS = -version-info 0:1:0
+
+libasycxx_dbg_0_1_la_SOURCES = $(libasycxx_0_1_la_SOURCES)
+libasycxx_dbg_0_1_la_CPPFLAGS = -I$(top_srcdir)/include
+libasycxx_dbg_0_1_la_CXXFLAGS = -g
+libasycxx_dbg_0_1_la_LDFLAGS = -version-info 0:1:0
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|