test only

This commit is contained in:
zhengshuxin 2017-09-01 18:59:42 +08:00
parent 25d33da4de
commit 5291cd0c7a
10 changed files with 63 additions and 47 deletions

View File

@ -8,7 +8,7 @@ CFLAGS = -c -g -W -Wall -Wcast-qual -Wcast-align \
###########################################################
#Check system:
# Linux, SunOS, Solaris, BSD variants, AIX, HP-UX
SYSLIB = -lpthread -lz
SYSLIB = -lpthread -lz -ldl
CHECKSYSRES = @echo "Unknow system type!";exit 1
UNIXNAME = $(shell uname -s)
OSTYPE = $(shell uname -m)

View File

@ -8,7 +8,7 @@ CFLAGS = -c -g -W -Wall -Wcast-qual -Wcast-align \
###########################################################
#Check system:
# Linux, SunOS, Solaris, BSD variants, AIX, HP-UX
SYSLIB = -lpthread -lz
SYSLIB = -lpthread -lz -ldl
CHECKSYSRES = @echo "Unknow system type!";exit 1
UNIXNAME = $(shell uname -s)
OSTYPE = $(shell uname -m)

View File

@ -84,9 +84,13 @@ ifneq ($(SYSPATH),)
endif
###########################################################
CFLAGS += -I../../../../lib_acl/include -I../../../../lib_protocol/include -I../../../../lib_acl_cpp/include
CFLAGS += -I../../../../../../lib_acl/include \
-I../../../../../../lib_protocol/include \
-I../../../../../../lib_acl_cpp/include
EXTLIBS =
LDFLAGS = -L../../../../lib_acl_cpp/lib -lacl_cpp -L../../../../lib_protocol/lib -lprotocol -L../../../../lib_acl/lib -lacl \
LDFLAGS = -L../../../../../../lib_acl_cpp/lib -lacl_cpp \
-L../../../../../../lib_protocol/lib -lprotocol \
-L../../../../../../lib_acl/lib -lacl \
$(EXTLIBS) $(SYSLIB)
COMPILE = $(CC) $(CFLAGS)

View File

@ -10,8 +10,8 @@
// TODO: 在此处引用程序要求的附加头文件
#include "acl_cpp/lib_acl.hpp"
#include "lib_acl.h"
#include "acl_cpp/lib_acl.hpp"
#ifdef WIN32
#define snprintf _snprintf

View File

@ -82,16 +82,16 @@ ifneq ($(SYSPATH),)
endif
###########################################################
CFLAGS += -I../../../lib_acl/include \
-I../../../lib_protocol/include \
-I../../../lib_acl_cpp/include \
-I../../../lib_fiber/c/include \
-I../../../lib_fiber/cpp/include
CFLAGS += -I../../../../../lib_acl/include \
-I../../../../../lib_protocol/include \
-I../../../../../lib_acl_cpp/include \
-I../../../../../lib_fiber/c/include \
-I../../../../../lib_fiber/cpp/include
EXTLIBS =
LDFLAGS = -L../../../lib_fiber/lib -lfiber_cpp -lfiber \
-L../../../lib_acl_cpp/lib -lacl_cpp \
-L../../../lib_protocol/lib -lprotocol \
-L../../../lib_acl/lib -lacl \
LDFLAGS = -L../../../../../lib_fiber/lib -lfiber_cpp -lfiber \
-L../../../../../lib_acl_cpp/lib -lacl_cpp \
-L../../../../../lib_protocol/lib -lprotocol \
-L../../../../../lib_acl/lib -lacl \
$(EXTLIBS) $(SYSLIB)
COMPILE = $(CC) $(CFLAGS)

View File

@ -4,6 +4,7 @@
#include "stdlib/acl_define.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef ACL_BCB_COMPILER
#pragma hdrstop
@ -60,6 +61,7 @@ void acl_debug_init2(const char *str, int max_debug_level)
__debug_levels[i] = 0;
for (i = 0; i < tokens->argc; i++) {
size_t n;
char* ptr = tokens->argv[i];
ACL_ARGV* pair = acl_argv_split(ptr, ":");
if (pair->argc != 2) {
@ -73,6 +75,10 @@ void acl_debug_init2(const char *str, int max_debug_level)
continue;
}
ptr = pair->argv[0];
n = strcspn(ptr, "->|,;.@{}[]<>#$%^&()+*!");
ptr[n] = 0;
section = atoi(pair->argv[0]);
level = atoi(pair->argv[1]);

View File

@ -7,35 +7,36 @@ struct ACL_MBOX;
namespace acl
{
class ACL_CPP_API mobj
{
public:
mobj(void) {}
virtual ~mobj(void) {}
};
class ACL_CPP_API mbox : public noncopyable
//class ACL_CPP_API mbox : public noncopyable
template<typename T>
class mbox
{
public:
mbox(void);
~mbox(void);
~mbox(void) {}
/**
*
* @param o {mobj*}
* @param t {T*}
* @return {bool}
*/
bool push(mobj* o);
bool push(T* t)
{
return push_one((void*) t);
}
/**
*
* @param timeout {int} 0 ()
*
* @param success {bool*}
* @return {mobj*} NULL NULL
* @return {T*} NULL NULL
* success
*/
mobj* pop(int timeout = 0, bool* success = NULL);
T* pop(int timeout = 0, bool* success = NULL)
{
return (T*) pop_one(timeout, success);
}
/**
*
@ -51,6 +52,9 @@ public:
private:
ACL_MBOX* mbox_;
bool push_one(void* o);
void* pop_one(int timeout, bool* success);
};
} // namespace acl

View File

@ -3,7 +3,8 @@
int main(void)
{
logger_open("test.log", "logger", "all:1");
acl::log::stdout_open(true);
logger_open("test.log", "logger", "101->DEBUG_TEST1:1");
logger("logger opened!");
acl::log::logger_test1();

View File

@ -8,42 +8,42 @@
namespace acl
{
static void free_callback(void *ctx)
{
mbox* o = (mbox*) ctx;
delete o;
}
mbox::mbox(void)
template<typename T>
mbox<T>::mbox(void)
{
mbox_ = acl_mbox_create();
}
mbox::~mbox(void)
template<typename T>
mbox<T>::~mbox(void)
{
acl_mbox_free(mbox_, free_callback);
acl_mbox_free(mbox_, NULL);
}
bool mbox::push(mobj* o)
template<typename T>
bool mbox<T>::push_one(void* o)
{
return acl_mbox_send(mbox_, o) == 0;
}
mobj* mbox::pop(int timeout /* = 0 */, bool* success /* = NULL */)
template<typename T>
void* mbox<T>::pop_one(int timeout /* = 0 */, bool* success /* = NULL */)
{
int ok;
mobj* o = (mobj*) acl_mbox_read(mbox_, timeout, &ok);
void* o = (void*) acl_mbox_read(mbox_, timeout, &ok);
if (success)
*success = ok ? true : false;
return o;
}
size_t mbox::push_count(void) const
template<typename T>
size_t mbox<T>::push_count(void) const
{
return acl_mbox_nsend(mbox_);
}
size_t mbox::pop_count(void) const
template<typename T>
size_t mbox<T>::pop_count(void) const
{
return acl_mbox_nread(mbox_);
}

View File

@ -2,7 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
class myobj : public acl::mobj
class myobj
{
public:
myobj(void) : n_(0) {}
@ -31,7 +31,7 @@ private:
class mythread : public acl::thread
{
public:
mythread(acl::mbox& mb, myobj& o) : mb_(mb), o_(o) {}
mythread(acl::mbox<myobj>& mb, myobj& o) : mb_(mb), o_(o) {}
~mythread(void) {}
protected:
@ -44,7 +44,7 @@ protected:
}
private:
acl::mbox& mb_;
acl::mbox<myobj>& mb_;
myobj& o_;
};
@ -64,7 +64,8 @@ protected:
mythread thr(mb_, mo);
thr.start();
myobj* o = (myobj*) mb_.pop();
myobj* o = mb_.pop();
// myobj* o = (myobj*) mb_.pop();
assert(o == &mo);
printf("fiber-%u: result = %d\r\n", get_id(), o->get_result());
@ -73,7 +74,7 @@ protected:
}
private:
acl::mbox mb_;
acl::mbox<myobj> mb_;
acl::fiber_sem& sem_;
};