Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: yayanyang <yayanyang@gmail.com>
  • Loading branch information
yayanyang committed Aug 30, 2012
1 parent c6dfd2d commit 0b624ba
Show file tree
Hide file tree
Showing 19 changed files with 888 additions and 410 deletions.
2 changes: 2 additions & 0 deletions sys/thread.cpp
Expand Up @@ -92,6 +92,8 @@ LEMON_SYS_API LemonMutex LemonCreateMutex(__lemon_inout LemonErrorInfo* errorCod


LEMON_SYS_API void LemonReleaseMutex(__lemon_in LemonMutex mutex){ LEMON_SYS_API void LemonReleaseMutex(__lemon_in LemonMutex mutex){
DeleteCriticalSection((CRITICAL_SECTION*)mutex); DeleteCriticalSection((CRITICAL_SECTION*)mutex);

delete (CRITICAL_SECTION*)mutex;
} }


LEMON_SYS_API void LemonMutexLock(__lemon_in LemonMutex mutex,__lemon_inout LemonErrorInfo * errorCode){ LEMON_SYS_API void LemonMutexLock(__lemon_in LemonMutex mutex,__lemon_inout LemonErrorInfo * errorCode){
Expand Down
312 changes: 312 additions & 0 deletions trace/abi.cpp
@@ -1 +1,313 @@
#include <lemon/trace/abi.h> #include <lemon/trace/abi.h>
#include <lemon/trace/object.hpp>

#include <lemon/trace/local/provider.hpp>
#include <lemon/trace/local/controller.hpp>

using namespace lemon;
using namespace lemon::trace;

LEMON_TRACE_API
LemonTraceService
LemonCreateTraceService(
__lemon_in const char * url,
__lemon_inout LemonErrorInfo * errorCode)
{
try
{
LEMON_RESET_ERRORINFO(*errorCode);

return reinterpret_cast<LemonTraceService>( CreateTraceService(url) );
}
catch(const error_info & e)
{
*errorCode = e;

return LEMON_HANDLE_NULL_VALUE;
}
}

LEMON_TRACE_API
void
LemonCloseTraceService(
__lemon_free LemonTraceService service)
{
delete reinterpret_cast<IService*>(service);
}


//////////////////////////////////////////////////////////////////////////

LEMON_TRACE_API
LemonTraceController
LemonCreateTraceController(
__lemon_in LemonTraceService service,
__lemon_inout LemonErrorInfo * errorCode)
{
try
{
LEMON_RESET_ERRORINFO(*errorCode);

return reinterpret_cast<LemonTraceController>(new Controller(reinterpret_cast<IService*>(service)));
}
catch(const error_info & e)
{
*errorCode = e;

return LEMON_HANDLE_NULL_VALUE;
}
}

LEMON_TRACE_API
LemonTraceController
LemonCreateRemoteTraceController(
__lemon_in const char * serviceurl,
__lemon_inout LemonErrorInfo * errorCode);

LEMON_TRACE_API
void
LemonCloseTraceController(
__lemon_free LemonTraceController controller)
{
delete reinterpret_cast<IController*>(controller);
}

LEMON_TRACE_API
LemonTraceConsumer
LemonCreateTraceConsumer(
__lemon_in LemonTraceController controller,
__lemon_in LemonTraceProc proc,
__lemon_in void * userdata,
__lemon_inout LemonErrorInfo *errorCode)
{
try
{
LEMON_RESET_ERRORINFO(*errorCode);

return reinterpret_cast<LemonTraceConsumer>(new Consumer(reinterpret_cast<IController*>(controller),proc,userdata));
}
catch(const error_info & e)
{
*errorCode = e;

return LEMON_HANDLE_NULL_VALUE;
}
}

LEMON_TRACE_API
void
LemonCloseTraceConsumer(
__lemon_free LemonTraceConsumer consumer)
{
delete reinterpret_cast<Consumer*>(consumer);
}

LEMON_TRACE_API
void LemonOpenTrace(
__lemon_in LemonTraceController controller,
__lemon_in const LemonUuid * provider,
__lemon_in lemon_trace_flag flag,
__lemon_inout LemonErrorInfo *errorCode)
{
try
{
LEMON_RESET_ERRORINFO(*errorCode);

reinterpret_cast<IController*>(controller)->OpenTrace(provider,flag);
}
catch(const error_info & e)
{
*errorCode = e;
}
}

LEMON_TRACE_API
void LemonCloseTrace(
__lemon_in LemonTraceController controller,
__lemon_in const LemonUuid * provider,
__lemon_in lemon_trace_flag flag,
__lemon_inout LemonErrorInfo *errorCode)
{
try
{
LEMON_RESET_ERRORINFO(*errorCode);

reinterpret_cast<IController*>(controller)->CloseTrace(provider,flag);
}
catch(const error_info & e)
{
*errorCode = e;
}
}

//////////////////////////////////////////////////////////////////////////


LEMON_TRACE_API
LemonTraceProvider
LemonCreateTraceProvider(
__lemon_in LemonTraceService service,
__lemon_in const LemonUuid * uuid,
__lemon_inout LemonErrorInfo * errorCode)
{
try
{
LEMON_RESET_ERRORINFO(*errorCode);

return reinterpret_cast<LemonTraceProvider>(new Provider(reinterpret_cast<IService*>(service),uuid));
}
catch(const error_info & e)
{
*errorCode = e;

return LEMON_HANDLE_NULL_VALUE;
}

}

LEMON_TRACE_API
LemonTraceProvider
LemonCreateRemoteTraceProvider(
__lemon_in const char * serviceurl,
__lemon_in const LemonUuid * uuid,
__lemon_inout LemonErrorInfo * errorCode);

LEMON_TRACE_API
void
LemonCloseTraceProvider(
__lemon_free LemonTraceProvider provider)
{
delete reinterpret_cast<IProvider*>(provider);
}

LEMON_TRACE_API
LemonTraceMessage
LemonNewTraceMessage(
__lemon_in LemonTraceProvider provider,
__lemon_in lemon_trace_flag flag)
{
return reinterpret_cast<LemonTraceMessage>(reinterpret_cast<IProvider*>(provider)->NewMessage(flag));
}

LEMON_TRACE_API
void LemonTrace(
__lemon_in LemonTraceProvider provider,
__lemon_in LemonTraceMessage message,
__lemon_inout LemonErrorInfo * errorCode)
{
try
{
LEMON_RESET_ERRORINFO(*errorCode);

reinterpret_cast<IProvider*>(provider)->Trace(reinterpret_cast<Message*>(message));
}
catch(const error_info & e)
{
*errorCode = e;
}
}

//////////////////////////////////////////////////////////////////////////

LEMON_TRACE_API
void LemonGetTraceDescription(
__lemon_in LemonTraceMessage message,
__lemon_inout LemonTraceDescription * description)
{
reinterpret_cast<Message*>(message)->Description(description);
}

LEMON_TRACE_API
size_t LemonTraceWrite(
__lemon_in LemonTraceMessage message,
__lemon_in const void * data,
__lemon_in size_t length,
__lemon_inout LemonErrorInfo * errorCode)
{
try
{
LEMON_RESET_ERRORINFO(*errorCode);

return reinterpret_cast<Message*>(message)->Write(data,length);
}
catch(const error_info & e)
{
*errorCode = e;

return (size_t)-1;
}
}

LEMON_TRACE_API
size_t LemonTraceRead(
__lemon_in LemonTraceMessage message,
__lemon_in void * data,
__lemon_in size_t length,
__lemon_inout LemonErrorInfo * errorCode)
{
try
{
LEMON_RESET_ERRORINFO(*errorCode);

return reinterpret_cast<Message*>(message)->Read(data,length);
}
catch(const error_info & e)
{
*errorCode = e;

return (size_t)-1;
}
}

LEMON_TRACE_API
size_t LemonTraceSeek(
__lemon_in LemonTraceMessage message,
__lemon_in int offset,
__lemon_in size_t position)
{
return reinterpret_cast<Message*>(message)->Seek(offset,(lemon::io::seek::Value)position);
}

LEMON_TRACE_API
size_t LemonTraceDump(
__lemon_in LemonTraceMessage message,
__lemon_in LemonIoWriter writer,
__lemon_inout LemonErrorInfo * errorCode)
{
try
{
LEMON_RESET_ERRORINFO(*errorCode);

io::c_writer wrapper(writer);

return reinterpret_cast<Message*>(message)->Dump(wrapper);
}
catch(const error_info & e)
{
*errorCode = e;

return (size_t)-1;
}
}

LEMON_TRACE_API
size_t LemonTraceLoad(
__lemon_in LemonTraceMessage message,
__lemon_in LemonIoReader reader,
__lemon_inout LemonErrorInfo * errorCode)
{
try
{
LEMON_RESET_ERRORINFO(*errorCode);

io::c_reader wrapper(reader);

return reinterpret_cast<Message*>(message)->Load(wrapper);
}
catch(const error_info & e)
{
*errorCode = e;

return (size_t)-1;
}
}
12 changes: 8 additions & 4 deletions trace/abi.h
Expand Up @@ -33,6 +33,8 @@


#define LEMON_TRACE_MESSAGE_MAX_LENGTH 1024 #define LEMON_TRACE_MESSAGE_MAX_LENGTH 1024


#define LEMON_TRACE_MESSAGE_MAX_CACHE 1024 * 1024

typedef lemon_uint64_t lemon_trace_flag; typedef lemon_uint64_t lemon_trace_flag;


#define LEMON_MAKE_TRACE_FLAG(level,catalog)\ #define LEMON_MAKE_TRACE_FLAG(level,catalog)\
Expand Down Expand Up @@ -98,13 +100,15 @@ LEMON_TRACE_API
void LemonOpenTrace( void LemonOpenTrace(
__lemon_in LemonTraceController controller, __lemon_in LemonTraceController controller,
__lemon_in const LemonUuid * provider, __lemon_in const LemonUuid * provider,
__lemon_in lemon_trace_flag flag); __lemon_in lemon_trace_flag flag,
__lemon_inout LemonErrorInfo *errorCode);


LEMON_TRACE_API LEMON_TRACE_API
void LemonCloseTrace( void LemonCloseTrace(
__lemon_in LemonTraceController controller, __lemon_in LemonTraceController controller,
__lemon_in const LemonUuid * provider, __lemon_in const LemonUuid * provider,
__lemon_in lemon_trace_flag flag); __lemon_in lemon_trace_flag flag,
__lemon_inout LemonErrorInfo *errorCode);




////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -156,15 +160,15 @@ typedef union LemonTraceNodeName


typedef struct LemonTraceDescription{ typedef struct LemonTraceDescription{


struct sockaddr *Node; const struct sockaddr *Node;


lemon_pid_t ProcessId; lemon_pid_t ProcessId;


lemon_tid_t ThreadId; lemon_tid_t ThreadId;


lemon_trace_flag Flag; lemon_trace_flag Flag;


LemonUuid *Uuid; const LemonUuid *Uuid;


lemon_uint32_t Length; lemon_uint32_t Length;


Expand Down

0 comments on commit 0b624ba

Please sign in to comment.