Format codes.

This commit is contained in:
zhengshuxin 2024-11-10 11:01:40 +08:00
parent 9abb5f5073
commit 655ba1b664
42 changed files with 345 additions and 469 deletions

View File

@ -1,38 +1,32 @@
#pragma once
#include "../acl_cpp_define.hpp"
namespace acl
{
namespace acl {
// internal functions being used
void* atomic_new(void);
void* atomic_new();
void atomic_free(void*);
void atomic_set(void*, void*);
void* atomic_cas(void*, void*, void*);
void* atomic_xchg(void*, void*);
template<typename T>
class ACL_CPP_API atomic
{
class ACL_CPP_API atomic {
public:
atomic(T* t)
{
atomic(T* t) {
atomic_ = atomic_new();
atomic_set(atomic_, t);
}
virtual ~atomic(void)
{
virtual ~atomic() {
atomic_free(atomic_);
}
T* cas(T* cmp, T* val)
{
T* cas(T* cmp, T* val) {
return (T*) atomic_cas(atomic_, cmp, val);
}
T* xchg(T* val)
{
T* xchg(T* val) {
return (T*) atomic_xchg(atomic_, val);
}
@ -43,76 +37,63 @@ private:
atomic(const atomic&);
};
class ACL_CPP_API atomic_long : public atomic<long long>
{
class ACL_CPP_API atomic_long : public atomic<long long> {
public:
atomic_long(long long n = 0);
atomic_long(const atomic_long& n);
~atomic_long(void) {}
~atomic_long() {}
void set(long long n);
long long cas(long long cmp, long long n);
long long fetch_add(long long n);
long long add_fetch(long long n);
operator long long() const
{
operator long long() const {
return n_;
}
long long value(void) const
{
long long value() const {
return n_;
}
void operator=(long long n)
{
void operator=(long long n) {
set(n);
}
void operator=(const atomic_long& n)
{
void operator=(const atomic_long& n) {
set(n.n_);
}
long long operator++()
{
long long operator++() {
return add_fetch(1);
}
long long operator++(int)
{
long long operator++(int) {
return fetch_add(1);
}
long long operator--()
{
long long operator--() {
return add_fetch(-1);
}
long long operator--(int)
{
long long operator--(int) {
return fetch_add(-1);
}
long long operator+=(long long n)
{
long long operator+=(long long n) {
return add_fetch(n);
}
long long operator+=(int n)
{
long long operator+=(int n) {
return add_fetch(n);
}
long long operator-=(long long n)
{
long long operator-=(long long n) {
return add_fetch(-n);
}
long long operator-=(int n)
{
long long operator-=(int n) {
return add_fetch(-n);
}
@ -122,16 +103,14 @@ private:
#include "thread.hpp"
class atomic_long_test
{
class atomic_long_test {
private:
atomic_long count_;
public:
atomic_long_test(void) {}
~atomic_long_test(void) {}
atomic_long_test() {}
~atomic_long_test() {}
void run(void)
{
void run() {
long long n = count_++;
printf(">>n=%lld\r\n", n);
@ -164,13 +143,12 @@ public:
printf(">>n=%lld\r\n", n);
}
class mythread : public thread
{
class mythread : public thread {
public:
mythread(atomic_long_test& at) : at_(at) {}
~mythread(void) {}
~mythread() {}
protected:
void* run(void)
void* run()
{
for (size_t i = 0; i < 100; i++)
at_.run();
@ -180,8 +158,7 @@ public:
atomic_long_test& at_;
};
static void test(void)
{
static void test() {
atomic_long_test at;
mythread thr1(at), thr2(at), thr3(at);
thr1.set_detachable(false);

View File

@ -3,8 +3,7 @@
namespace acl {
class bitmap : public noncopyable
{
class bitmap : public noncopyable {
public:
/**
*
@ -19,7 +18,7 @@ public:
*/
bitmap(size_t len);
~bitmap(void);
~bitmap();
/**
*
@ -67,31 +66,31 @@ public:
*
* @return {size_t}
*/
size_t size(void) const;
size_t size() const;
/**
*
*/
size_t space(void) const;
size_t space() const;
/**
*
* @return {size_t}
*/
size_t count(void) const;
size_t count() const;
/**
* bitmap是否已满
* @return {bool}
*/
bool full(void) const;
bool full() const;
public:
const unsigned char* get_bmp(void) const {
const unsigned char* get_bmp() const {
return bmp_;
}
unsigned char* get_bmp(void) {
unsigned char* get_bmp() {
return bmp_;
}
@ -101,7 +100,7 @@ private:
size_t count_;
//从新统计count数量
void recount(void);
void recount();
};
} // namespace acl

View File

@ -13,12 +13,12 @@ typedef enum {
template <typename T>
class box : public noncopyable {
public:
box(void) {}
virtual ~box(void) {}
box() {}
virtual ~box() {}
virtual bool push(T* o, bool notify_first = true) = 0;
virtual T* pop(int wait_ms = -1, bool* bound = NULL) = 0;
virtual bool has_null(void) const = 0;
virtual bool has_null() const = 0;
};
} // namespace acl

View File

@ -8,11 +8,10 @@ struct ACL_VSTRING;
namespace acl {
class ACL_CPP_API charset_conv : public pipe_stream
{
class ACL_CPP_API charset_conv : public pipe_stream {
public:
charset_conv(void);
~charset_conv(void);
charset_conv();
~charset_conv();
/**
*
@ -37,13 +36,13 @@ public:
* ,
* @return {const char*}
*/
const char* serror(void) const;
const char* serror() const;
/**
* , 便使, 使
* set(from, to)
*/
void reset(void);
void reset();
/* 流式分析过程update_begin->update->update ... ->update_finish */

View File

@ -4,19 +4,17 @@
#include <vector>
#include "noncopyable.hpp"
namespace acl
{
namespace acl {
class diff_object;
/**
*
*/
class diff_manager : public noncopyable
{
class diff_manager : public noncopyable {
public:
diff_manager(long long range_from = -1, long long range_to = -1);
~diff_manager(void);
~diff_manager();
/**
*
@ -24,7 +22,7 @@ public:
* diff_manager diff_manager
*
*/
dbuf_guard& get_dbuf(void);
dbuf_guard& get_dbuf();
/**
*
@ -40,8 +38,7 @@ public:
*
* @return {std::vector<diff_object*>&}
*/
const std::vector<diff_object*>& get_new(void) const
{
const std::vector<diff_object*>& get_new() const {
return objs_new_;
}
@ -50,8 +47,7 @@ public:
*
* @return {std::vector<diff_object*>&}
*/
const std::vector<diff_object*>& get_deleted(void) const
{
const std::vector<diff_object*>& get_deleted() const {
return objs_del_;
}
@ -73,8 +69,7 @@ public:
* (*cit).second->get_val());
*/
const std::vector<std::pair<diff_object*, diff_object*> >&
get_updated(void) const
{
get_updated() const {
return objs_upd_;
}
@ -82,8 +77,7 @@ public:
* diff_manger
* @return {std::vector<diff_object*>&}
*/
const std::vector<diff_object*>& get_same(void) const
{
const std::vector<diff_object*>& get_same() const {
return objs_equ_;
}
@ -91,8 +85,7 @@ public:
*
* @return {const std::vector<diff_object*>&}
*/
const std::vector<diff_object*>& get_extra_added(void) const
{
const std::vector<diff_object*>& get_extra_added() const {
return objs_new_extra_;
}
@ -100,8 +93,7 @@ public:
*
* @return {const std::vector<diff_object*>&}
*/
const std::vector<diff_object*>& get_extra_deleted(void) const
{
const std::vector<diff_object*>& get_extra_deleted() const {
return objs_del_extra_;
}
@ -110,8 +102,7 @@ public:
* @return {const std::vector<diff_object*>&}
*/
const std::vector<std::pair<diff_object*, diff_object*> >&
get_extra_updated(void) const
{
get_extra_updated() const {
return objs_upd_extra_;
}
@ -119,7 +110,7 @@ public:
* 使 diff_manager
*
*/
void reset(void);
void reset();
private:
dbuf_guard dbuf_;

View File

@ -2,8 +2,7 @@
#include "../acl_cpp_define.hpp"
#include "dbuf_pool.hpp"
namespace acl
{
namespace acl {
class diff_manager;
@ -11,8 +10,7 @@ class diff_manager;
*
* dbuf_obj 便 dbuf_guard
*/
class diff_object : public dbuf_obj
{
class diff_object : public dbuf_obj {
public:
/**
*
@ -20,19 +18,19 @@ public:
*/
diff_object(diff_manager& manager);
virtual ~diff_object(void) {}
virtual ~diff_object() {}
/**
*
* @return {const char*}
*/
virtual const char* get_key(void) const = 0;
virtual const char* get_key() const = 0;
/**
*
* @return {const char*}
*/
virtual const char* get_val(void) const = 0;
virtual const char* get_val() const = 0;
/**
*
@ -47,8 +45,7 @@ public:
* @param range_to {long long}
* @return {bool}
*/
virtual bool check_range(long long range_from, long long range_to) const
{
virtual bool check_range(long long range_from, long long range_to) const {
(void) range_from;
(void) range_to;
return false;

View File

@ -2,11 +2,9 @@
#include "../acl_cpp_define.hpp"
#include "diff_object.hpp"
namespace acl
{
namespace acl {
class diff_string : public diff_object
{
class diff_string : public diff_object {
public:
/**
*
@ -26,17 +24,16 @@ public:
*
* @return {long long}
*/
long long get_range(void) const
{
long long get_range() const {
return range_;
}
public:
// override: 基类纯虚函数的实现
const char* get_key(void) const;
const char* get_key() const;
// override: 基类纯虚函数的实现
const char* get_val(void) const;
const char* get_val() const;
// override: 基类纯函数的实现
bool operator== (const diff_object& obj) const;
@ -50,7 +47,7 @@ private:
long long range_;
// 析构函数声明为私有的,从而要求动态创建本类对象
~diff_string(void);
~diff_string();
};
} // namespace acl

View File

@ -6,11 +6,9 @@
#include "../stream/aio_delay_free.hpp"
#include "string.hpp"
namespace acl
{
namespace acl {
class ACL_CPP_API dns_res
{
class ACL_CPP_API dns_res {
public:
dns_res(const char* domain) : domain_(domain) {}
~dns_res() { ips_.clear(); }
@ -21,8 +19,7 @@ protected:
private:
};
class ACL_CPP_API dns_result_callback
{
class ACL_CPP_API dns_result_callback {
public:
dns_result_callback(const char* domain) : domain_(domain) {}
@ -32,7 +29,7 @@ public:
* delete this
*
*/
virtual void destroy(void) {}
virtual void destroy() {}
/**
* res.ips_.size() == 0

View File

@ -15,15 +15,13 @@ private:
};
#else
template <typename T>
class identity
{
class identity {
public:
typedef T me;
};
template<typename TDerive, typename TProvider>
class final_tpl_base
{
class final_tpl_base {
friend class identity<TDerive>::me;
friend class identity<TProvider>::me;
private:
@ -46,8 +44,7 @@ private:
*/
template<typename TFinalClass>
class final_tpl : virtual public final_tpl_base<TFinalClass,
final_tpl<TFinalClass> >
{
final_tpl<TFinalClass> > {
public:
final_tpl() {}
~final_tpl() {}

View File

@ -19,8 +19,7 @@ namespace acl {
/**
* 线
*/
class ACL_CPP_API locker : public noncopyable
{
class ACL_CPP_API locker : public noncopyable {
public:
/**
*

View File

@ -81,7 +81,7 @@ public:
/**
* 退
*/
static void close(void);
static void close();
/**
*
@ -147,7 +147,7 @@ public:
#ifndef ACL_LOGGER_MACRO_OFF
static void logger_test1(void) {
static void logger_test1() {
# define DEBUG_TEST_BASE 100
# define DEBUG_TEST1 (DEBUG_TEST_BASE + 1)
# define DEBUG_TEST2 (DEBUG_TEST_BASE + 2)
@ -197,7 +197,7 @@ public:
logger_close();
}
static void logger_test2(void) {
static void logger_test2() {
logger("logger ok!");
logger_warn("logger_warn ok!");
logger_error("logger_error ok!");

View File

@ -21,10 +21,10 @@ size_t mbox_nread(void*);
*
* class myobj {
* public:
* myobj(void) {}
* ~myobj(void) {}
* myobj() {}
* ~myobj() {}
*
* void run(void)
* void run()
* {
* printf("hello world!\r\n");
* }
@ -32,13 +32,13 @@ size_t mbox_nread(void*);
*
* acl::mbox<myobj> mbox;
*
* void thread_producer(void)
* void thread_producer()
* {
* myobj* o = new myobj;
* mbox.push(o);
* }
*
* void thread_consumer(void)
* void thread_consumer()
* {
* myobj* o = mbox.pop();
* o->run();
@ -62,8 +62,7 @@ public:
assert(mbox_);
}
~mbox(void)
{
~mbox() {
mbox_free(mbox_, free_obj_ ? mbox_free_fn : NULL);
}
@ -74,8 +73,7 @@ public:
* @return {bool}
* @override
*/
bool push(T* t, bool dummy = false)
{
bool push(T* t, bool dummy = false) {
(void) dummy;
return mbox_send(mbox_, t);
}
@ -89,8 +87,7 @@ public:
* success
* @override
*/
T* pop(int timeout = -1, bool* success = NULL)
{
T* pop(int timeout = -1, bool* success = NULL) {
return (T*) mbox_read(mbox_, timeout, success);
}
@ -99,7 +96,7 @@ public:
* @return {bool}
* @override
*/
bool has_null(void) const {
bool has_null() const {
return false;
}
@ -107,8 +104,7 @@ public:
*
* @return {size_t}
*/
size_t push_count(void) const
{
size_t push_count() const {
return mbox_nsend(mbox_);
}
@ -116,8 +112,7 @@ public:
*
* @return {size_t}
*/
size_t pop_count(void) const
{
size_t pop_count() const {
return mbox_nread(mbox_);
}
@ -125,8 +120,7 @@ private:
void* mbox_;
bool free_obj_;
static void mbox_free_fn(void* o)
{
static void mbox_free_fn(void* o) {
T* t = (T*) o;
delete t;
}

View File

@ -8,8 +8,8 @@ class istream;
class ACL_CPP_API md5 : public noncopyable {
public:
md5(void);
~md5(void);
md5();
~md5();
/**
* md5
@ -23,13 +23,13 @@ public:
* md5
* @return {md5&}
*/
md5& finish(void);
md5& finish();
/**
* md5 使 md5
* @return {md5&}
*/
md5& reset(void);
md5& reset();
/**
* md5

View File

@ -3,8 +3,7 @@
namespace acl {
class ACL_CPP_API noncopyable
{
class ACL_CPP_API noncopyable {
protected:
noncopyable() {}
~noncopyable() {}

View File

@ -3,16 +3,14 @@
struct ACL_SCAN_DIR;
namespace acl
{
namespace acl {
class string;
class ACL_CPP_API scan_dir : public noncopyable
{
class ACL_CPP_API scan_dir : public noncopyable {
public:
scan_dir(void);
virtual ~scan_dir(void);
scan_dir();
virtual ~scan_dir();
/**
*
@ -34,7 +32,7 @@ public:
/**
*
*/
void close(void);
void close();
/**
* () open
@ -157,8 +155,7 @@ public:
static bool get_cwd(string& out);
public:
ACL_SCAN_DIR* get_scan_dir(void) const
{
ACL_SCAN_DIR* get_scan_dir() const {
return scan_;
}

View File

@ -24,11 +24,9 @@
#pragma once
#include "noncopyable.hpp"
namespace acl
{
namespace acl {
class sha1 : public noncopyable
{
class sha1 : public noncopyable {
public:
sha1();
virtual ~sha1();

View File

@ -66,16 +66,13 @@ namespace acl {
// attempt to retieve a mutable instances while locked will
// generate a assertion if compiled for debug.
class singleton_module : public noncopyable
{
class singleton_module : public noncopyable {
public:
static void lock()
{
static void lock() {
get_lock() = true;
}
static void unlock()
{
static void unlock() {
get_lock() = false;
}
@ -83,20 +80,17 @@ public:
return get_lock();
}
private:
static bool& get_lock()
{
static bool& get_lock() {
static bool lock_ = false;
return lock_;
}
};
template<class T>
class singleton_wrapper : public T
{
class singleton_wrapper : public T {
public:
static bool destroyed_;
~singleton_wrapper()
{
~singleton_wrapper() {
destroyed_ = true;
}
};
@ -110,16 +104,14 @@ bool singleton_wrapper< T >::destroyed_ = false;
* 线
* main .
* 使
* class singleton_test : public acl::singleton<singlegon_test>
* {
* class singleton_test : public acl::singleton<singlegon_test> {
* public:
* singleton_test() {}
* ~singleton_test() {}
* singleton_test& init() { return *this; }
* };
* int main()
* {
* int main() {
* singleton_test& test = singleton_test::get_instance();
* test.init();
* ...
@ -127,11 +119,9 @@ bool singleton_wrapper< T >::destroyed_ = false;
* }
*/
template <class T>
class singleton : public singleton_module
{
class singleton : public singleton_module {
public:
static T& get_instance()
{
static T& get_instance() {
static singleton_wrapper< T > t;
// refer to instance, causing it to be instantiated (and
// initialized at startup on working compilers)
@ -140,8 +130,7 @@ public:
return static_cast<T &>(t);
}
static bool is_destroyed()
{
static bool is_destroyed() {
return singleton_wrapper< T >::destroyed_;
}
@ -160,16 +149,14 @@ T& singleton< T >::instance_ = singleton< T >::get_instance();
* VC2003 release
* main VC2003 线
* 使
* class singleton_test
* {
* class singleton_test {
* public:
* singleton_test() {}
* ~singleton_test() {}
* singleton_test& init() { return *this; }
* };
* int main()
* {
* int main() {
* singleton_test& test = acl::singleton2<singleton_test>::get_instance();
* test.init();
* ...
@ -178,11 +165,9 @@ T& singleton< T >::instance_ = singleton< T >::get_instance();
*
*/
template <typename T>
struct singleton2
{
struct singleton2 {
private:
struct object_creator
{
struct object_creator {
object_creator() { singleton2<T>::get_instance(); }
inline void do_nothing() const {};
};
@ -190,8 +175,7 @@ private:
public:
typedef T object_type;
static object_type & get_instance()
{
static object_type & get_instance() {
static object_type obj;
create_object.do_nothing();
return obj;

View File

@ -49,8 +49,7 @@ public:
tbox(bool free_obj = true)
: size_(0), free_obj_(free_obj), cond_(&lock_) {}
~tbox(void)
{
~tbox() {
clear(free_obj_);
}
@ -58,8 +57,7 @@ public:
*
* @param free_obj {bool} delete
*/
void clear(bool free_obj = false)
{
void clear(bool free_obj = false) {
if (free_obj) {
for (typename std::list<T*>::iterator it =
tbox_.begin(); it != tbox_.end(); ++it) {
@ -78,26 +76,25 @@ public:
* @return {bool}
* @override
*/
bool push(T* t, bool notify_first = true)
{
if (lock_.lock() == false) {
bool push(T* t, bool notify_first = true) {
if (! lock_.lock()) {
abort();
}
tbox_.push_back(t);
size_++;
if (notify_first) {
if (cond_.notify() == false) {
if (! cond_.notify()) {
abort();
}
if (lock_.unlock() == false) {
if (! lock_.unlock()) {
abort();
}
} else {
if (lock_.unlock() == false) {
if (! lock_.unlock()) {
abort();
}
if (cond_.notify() == false) {
if (! cond_.notify()) {
abort();
}
}
@ -119,17 +116,16 @@ public:
*
* @override
*/
T* pop(int wait_ms = -1, bool* found = NULL)
{
T* pop(int wait_ms = -1, bool* found = NULL) {
long long n = ((long long) wait_ms) * 1000;
bool found_flag;
if (lock_.lock() == false) {
if (! lock_.lock()) {
abort();
}
while (true) {
T* t = peek(found_flag);
if (found_flag) {
if (lock_.unlock() == false) {
if (! lock_.unlock()) {
abort();
}
if (found) {
@ -140,7 +136,7 @@ public:
// 注意调用顺序,必须先调用 wait 再判断 wait_ms
if (!cond_.wait(n, true) && wait_ms >= 0) {
if (lock_.unlock() == false) {
if (! lock_.unlock()) {
abort();
}
if (found) {
@ -156,7 +152,7 @@ public:
* @return {bool}
* @override
*/
bool has_null(void) const {
bool has_null() const {
return true;
}
@ -164,22 +160,19 @@ public:
*
* @return {size_t}
*/
size_t size(void) const
{
size_t size() const {
return size_;
}
public:
void lock(void)
{
if (lock_.lock() == false) {
void lock() {
if (! lock_.lock()) {
abort();
}
}
void unlock(void)
{
if (lock_.unlock() == false) {
void unlock() {
if (! lock_.unlock()) {
abort();
}
}
@ -191,8 +184,7 @@ private:
thread_mutex lock_;
thread_cond cond_;
T* peek(bool& found_flag)
{
T* peek(bool& found_flag) {
typename std::list<T*>::iterator it = tbox_.begin();
if (it == tbox_.end()) {
found_flag = false;

View File

@ -61,7 +61,7 @@ public:
* @override
*/
bool push(T t, bool notify_first = true) {
if (lock_.lock() == false) {
if (! lock_.lock()) {
abort();
}
@ -69,17 +69,17 @@ public:
size_++;
if (notify_first) {
if (cond_.notify() == false) {
if (!cond_.notify()) {
abort();
}
if (lock_.unlock() == false) {
if (!lock_.unlock()) {
abort();
}
} else {
if (lock_.unlock() == false) {
if (!lock_.unlock()) {
abort();
}
if (cond_.notify() == false) {
if (!cond_.notify()) {
abort();
}
}
@ -97,12 +97,12 @@ public:
*/
bool pop(T& t, int wait_ms = -1) {
long long n = ((long long) wait_ms) * 1000;
if (lock_.lock() == false) {
if (!lock_.lock()) {
abort();
}
while (true) {
if (peek(t)) {
if (lock_.unlock() == false) {
if (!lock_.unlock()) {
abort();
}
return true;
@ -110,7 +110,7 @@ public:
// 注意调用顺序,必须先调用 wait 再判断 wait_ms
if (!cond_.wait(n, true) && wait_ms >= 0) {
if (lock_.unlock() == false) {
if (!lock_.unlock()) {
abort();
}
return false;
@ -128,13 +128,13 @@ public:
public:
void lock() {
if (lock_.lock() == false) {
if (!lock_.lock()) {
abort();
}
}
void unlock() {
if (lock_.unlock() == false) {
if (!lock_.unlock()) {
abort();
}
}

View File

@ -57,8 +57,7 @@ public:
array_ = (T**) malloc(sizeof(T*) * capacity_);
}
~tbox_array(void)
{
~tbox_array() {
clear(free_obj_);
free(array_);
}
@ -67,8 +66,7 @@ public:
*
* @param free_obj {bool} delete
*/
void clear(bool free_obj = false)
{
void clear(bool free_obj = false) {
if (free_obj) {
for (size_t i = off_curr_; i < off_next_; i++) {
delete array_[i];
@ -84,9 +82,8 @@ public:
* @return {bool}
* @override
*/
bool push(T* t, bool notify_first = false)
{
if (lock_.lock() == false) {
bool push(T* t, bool notify_first = false) {
if (! lock_.lock()) {
abort();
}
@ -112,17 +109,17 @@ public:
array_[off_next_++] = t;
if (notify_first) {
if (cond_.notify() == false) {
if (! cond_.notify()) {
abort();
}
if (lock_.unlock() == false) {
if (! lock_.unlock()) {
abort();
}
} else {
if (lock_.unlock() == false) {
if (! lock_.unlock()) {
abort();
}
if (cond_.notify() == false) {
if (! cond_.notify()) {
abort();
}
}
@ -144,18 +141,17 @@ public:
*
* @override
*/
T* pop(int wait_ms = -1, bool* found = NULL)
{
T* pop(int wait_ms = -1, bool* found = NULL) {
long long n = ((long long) wait_ms) * 1000;
bool found_flag;
if (lock_.lock() == false) {
if (! lock_.lock()) {
abort();
}
while (true) {
T* t = peek(found_flag);
if (found_flag) {
if (lock_.unlock() == false) {
if (! lock_.unlock()) {
abort();
}
if (found) {
@ -168,7 +164,7 @@ public:
waiters_++;
if (!cond_.wait(n, true) && wait_ms >= 0) {
waiters_--;
if (lock_.unlock() == false) {
if (! lock_.unlock()) {
abort();
}
if (found) {
@ -185,7 +181,7 @@ public:
* @return {bool}
* @override
*/
bool has_null(void) const {
bool has_null() const {
return true;
}
@ -193,22 +189,19 @@ public:
*
* @return {size_t}
*/
size_t size(void) const
{
size_t size() const {
return off_next_ - off_curr_;
}
public:
void lock(void)
{
if (lock_.lock() == false) {
void lock() {
if (! lock_.lock()) {
abort();
}
}
void unlock(void)
{
if (lock_.unlock() == false) {
void unlock() {
if (! lock_.unlock()) {
abort();
}
}
@ -223,8 +216,7 @@ private:
thread_mutex lock_;
thread_cond cond_;
T* peek(bool& found_flag)
{
T* peek(bool& found_flag) {
if (off_curr_ == off_next_) {
found_flag = false;
if (off_curr_ > 0) {

View File

@ -2,30 +2,28 @@
#include "../acl_cpp_define.hpp"
#include "noncopyable.hpp"
namespace acl
{
namespace acl {
/**
* 线 run 线
*/
class ACL_CPP_API thread_job : public noncopyable
{
class ACL_CPP_API thread_job : public noncopyable {
public:
thread_job(void) {}
virtual ~thread_job(void) {}
thread_job() {}
virtual ~thread_job() {}
/**
* 线
* @return {void*} 线退
*/
virtual void* run(void) = 0;
virtual void* run() = 0;
/**
* 线 run()
* 线线线
* 线 start() 线
*/
virtual void init(void) {}
virtual void init() {}
};
template<typename T> class tbox;
@ -35,11 +33,10 @@ class atomic_long;
* 线 Java
* 使 thread::start() 线
*/
class ACL_CPP_API thread : public thread_job
{
class ACL_CPP_API thread : public thread_job {
public:
thread(void);
virtual ~thread(void);
thread();
virtual ~thread();
/**
* 线
@ -79,15 +76,14 @@ public:
* start 线 id
* @return {unsigned long}
*/
unsigned long thread_id(void) const;
unsigned long thread_id() const;
/**
* 线线 id
* @return {unsigned long}
*/
static unsigned long thread_self(void);
static unsigned long self(void)
{
static unsigned long thread_self();
static unsigned long self() {
return thread_self();
}
@ -107,7 +103,7 @@ private:
void* return_arg_;
static void* thread_run(void* arg);
void wait_for_running(void);
void wait_for_running();
};
} // namespace acl

View File

@ -18,8 +18,7 @@ class thread_mutex;
/**
* 线
*/
class ACL_CPP_API thread_cond : public noncopyable
{
class ACL_CPP_API thread_cond : public noncopyable {
public:
/**
*
@ -27,7 +26,7 @@ public:
* 线线
*/
thread_cond(thread_mutex* mutex = NULL);
~thread_cond(void);
~thread_cond();
/**
* 线
@ -46,25 +45,25 @@ public:
* 线线
* @return {bool} false
*/
bool notify(void);
bool notify();
/**
* 线线
* @return {bool} false
*/
bool notify_all(void);
bool notify_all();
/**
* 线线
* @return {thread_mutex&}
*/
thread_mutex& get_mutex(void) const;
thread_mutex& get_mutex() const;
/**
* 线
* @return {acl_pthread_cond_t*}
*/
acl_pthread_cond_t* get_cond(void) const;
acl_pthread_cond_t* get_cond() const;
private:
thread_mutex* mutex_;

View File

@ -16,39 +16,38 @@ namespace acl {
/**
* 线
*/
class ACL_CPP_API thread_mutex : public noncopyable
{
class ACL_CPP_API thread_mutex : public noncopyable {
public:
/**
*
* @param recursive {bool}
*/
thread_mutex(bool recursive = true);
~thread_mutex(void);
~thread_mutex();
/**
* 线()
* @return {bool} false 线
*/
bool lock(void);
bool lock();
/**
*
* @return {bool} true false
*/
bool try_lock(void);
bool try_lock();
/**
* 线
* @return {bool} false
*/
bool unlock(void);
bool unlock();
/**
* acl C 线
* @return {acl_pthread_mutex_t*}
*/
acl_pthread_mutex_t* get_mutex(void) const;
acl_pthread_mutex_t* get_mutex() const;
private:
acl_pthread_mutex_t* mutex_;
@ -61,7 +60,7 @@ class ACL_CPP_API thread_mutex_guard : public noncopyable
{
public:
thread_mutex_guard(thread_mutex& mutex);
~thread_mutex_guard(void);
~thread_mutex_guard();
private:
thread_mutex& mutex_;

View File

@ -4,11 +4,9 @@
struct ACL_AQUEUE;
namespace acl
{
namespace acl {
class ACL_CPP_API thread_qitem : public noncopyable
{
class ACL_CPP_API thread_qitem : public noncopyable {
public:
thread_qitem() {}
virtual ~thread_qitem() {}

View File

@ -14,20 +14,18 @@ namespace acl {
*
*/
template <typename T>
class trigger_item : public noncopyable
{
class trigger_item : public noncopyable {
public:
typedef std::map<long long, trigger_item<T>*> trigger_items_t;
trigger_item(trigger_items_t& items) : items_(items) {}
~trigger_item(void) {}
~trigger_item() {}
/**
*
* @pararm o {T*}
*/
void add(T* o)
{
void add(T* o) {
objs_.push_back(o);
}
@ -37,8 +35,7 @@ public:
* @return {int} >= 0
* -1
*/
int del(T* o)
{
int del(T* o) {
for (typename std::vector<T*>::iterator it = objs_.begin();
it != objs_.end(); ++it) {
@ -54,8 +51,7 @@ public:
*
* @return {std::vector<T*>&}
*/
std::vector<T*>& get_objs(void)
{
std::vector<T*>& get_objs() {
return objs_;
}
@ -68,40 +64,36 @@ private:
*
* T 便
*
* bool on_trigger(void); // 定时时间到期时的回调方法,返回值表示
* bool on_trigger(); // 定时时间到期时的回调方法,返回值表示
* // 是否需要再次触发该定时任务
* int get_ttl(void) const; // 定时任务到达时的时间间隔(毫秒)
* int get_ttl() const; // 定时任务到达时的时间间隔(毫秒)
* void set_key(long long key); // 触发器设置与该定时任务关联的键
* long long get_key(void) const; // 获得由 set_key 设置的键
* long long get_key() const; // 获得由 set_key 设置的键
*
* T
* class mytask
* {
* public:
* mytask(void) {}
* ~mytask(void) {}
* mytask() {}
* ~mytask() {}
*
* // @override
* bool on_trigger(void)
* {
* bool on_trigger() {
* return true;
* }
*
* // @override
* int get_ttl(void) const
* {
* int get_ttl() const {
* return 1000;
* }
*
* // @override
* void set_key(long long key)
* {
* void set_key(long long key) {
* key_ = key;
* }
*
* // @override
* long long get_key(void) const
* {
* long long get_key() const {
* return key_;
* }
*
@ -110,21 +102,19 @@ private:
* };
*/
template <typename T>
class timer_trigger : public noncopyable
{
class timer_trigger : public noncopyable {
public:
typedef std::map<long long, trigger_item<T>*> trigger_items_t;
typedef typename trigger_items_t::iterator trigger_iter_t;
timer_trigger(void) {}
~timer_trigger(void) {}
timer_trigger() {}
~timer_trigger() {}
/**
*
* @pararm o {T*}
*/
void add(T* o)
{
void add(T* o) {
int ttl = o->get_ttl();
long long key = get_curr_stamp() + ttl;
@ -144,13 +134,13 @@ public:
* @pararm o {T*}
* @return {int} >= 0 -1
*/
int del(T* o)
{
int del(T* o) {
long long key = o->get_key();
trigger_iter_t it = items_.find(key);
if (it == items_.end())
if (it == items_.end()) {
return -1;
}
if (it->second->del(o) == 0) {
delete it->second;
items_.erase(it);
@ -163,14 +153,14 @@ public:
* @return {long long} -1
*
*/
long long trigger(void)
{
long long trigger() {
long long key = get_curr_stamp();
std::vector<trigger_item<T>*> items;
trigger_iter_t iter;
for (iter = items_.begin(); iter != items_.end();) {
if (iter->first > key)
if (iter->first > key) {
break;
}
items.push_back(iter->second);
items_.erase(iter++);
@ -184,8 +174,9 @@ public:
}
iter = items_.begin();
if (iter == items_.end())
if (iter == items_.end()) {
return -1;
}
return iter->first;
}
@ -196,14 +187,14 @@ private:
*
* @pararm item {trigger_item<T>*}
*/
void trigger(trigger_item<T>* item)
{
void trigger(trigger_item<T>* item) {
std::vector<T*>& objs = item->get_objs();
for (typename std::vector<T*>::iterator it = objs.begin();
it != objs.end(); ++it) {
if (!(*it)->on_trigger())
if (!(*it)->on_trigger()) {
continue;
}
int ttl = (*it)->get_ttl();
long long key = get_curr_stamp() + ttl;
@ -212,8 +203,9 @@ private:
if (iter == items_.end()) {
item = new trigger_item<T>(items_);
items_[key] = item;
} else
} else {
item = iter->second;
}
item->add(*it);
(*it)->set_key(key);
@ -226,23 +218,21 @@ private:
*
*/
template <typename T>
class thread_trigger : public thread
{
class thread_trigger : public thread {
public:
thread_trigger(void)
thread_trigger()
: delay_(100) // 初始化时的超时等待时间(毫秒)
, stop_(false) // 是否停止线程
{
}
virtual ~thread_trigger(void) {}
virtual ~thread_trigger() {}
/**
*
* @pararm o {T*}
*/
void add(T* o)
{
void add(T* o) {
mbox_.push(o);
}
@ -250,42 +240,39 @@ public:
*
* @pararm o {T*}
*/
void del(T* o)
{
void del(T* o) {
lock_.lock();
timer_del_.push_back(o);
lock_.unlock();
}
timer_trigger<T>& get_trigger(void)
{
timer_trigger<T>& get_trigger() {
return timer_;
}
private:
// @override
void* run(void)
{
void* run() {
while (!stop_) {
T* o = mbox_.pop(delay_);
if (o)
if (o) {
timer_.add(o);
}
long long next = timer_.trigger();
long long curr = get_curr_stamp();
if (next == -1)
if (next == -1) {
delay_ = 100;
else {
} else {
delay_ = next - curr;
if (delay_ < 0)
if (delay_ < 0) {
delay_ = 1;
}
}
lock_.lock();
typename std::vector<T*>::iterator it;
for (it = timer_del_.begin();
it != timer_del_.end(); ++it) {
for (it = timer_del_.begin(); it != timer_del_.end(); ++it) {
timer_.del(*it);
}
timer_del_.clear();

View File

@ -7,8 +7,7 @@ namespace acl {
class string;
struct URL_NV
{
struct URL_NV {
char* name;
char* value;
};

View File

@ -1,14 +1,13 @@
#pragma once
#include "../acl_cpp_define.hpp"
namespace acl
{
namespace acl {
/**
*
* @return {int}
*/
ACL_CPP_API int last_error(void);
ACL_CPP_API int last_error();
/**
*
@ -21,7 +20,7 @@ ACL_CPP_API void set_error(int errnum);
* 使
* @return {const char *}
*/
ACL_CPP_API const char* last_serror(void);
ACL_CPP_API const char* last_serror();
/**
*
@ -44,7 +43,7 @@ ACL_CPP_API const char* string_error(int errnum, char* buf, size_t size);
ACL_CPP_API int strncasecmp_(const char *s1, const char *s2, size_t n);
ACL_CPP_API void assert_(bool n);
ACL_CPP_API void meter_time(const char *filename, int line, const char *info);
ACL_CPP_API long long get_curr_stamp(void);
ACL_CPP_API long long get_curr_stamp();
ACL_CPP_API double stamp_sub(const struct timeval& from,
const struct timeval& sub);

View File

@ -22,28 +22,27 @@ class xml;
class xml_node;
class istream;
class ACL_CPP_API xml_attr : public dbuf_obj
{
class ACL_CPP_API xml_attr : public dbuf_obj {
public:
/**
*
* @return {const char*}
* "\0"
*/
virtual const char* get_name(void) const = 0;
virtual const char* get_name() const = 0;
/**
*
* @return {const char*}
* "\0"
*/
virtual const char* get_value(void) const = 0;
virtual const char* get_value() const = 0;
protected:
friend class xml_node;
xml_attr(xml_node* node) : node_(node) {}
virtual ~xml_attr(void) {}
virtual ~xml_attr() {}
xml_node* node_;
};
@ -56,19 +55,19 @@ public:
* @return {const char*} XML
* xxxx
*/
virtual const char* tag_name(void) const = 0;
virtual const char* tag_name() const = 0;
/**
* XML ID
* @return {const char*} ID
*/
virtual const char* id(void) const = 0;
virtual const char* id() const = 0;
/**
* XML
* @return {const char*}
*/
virtual const char* text(void) const = 0;
virtual const char* text() const = 0;
/**
* XML
@ -89,14 +88,14 @@ public:
* @return {const xml_attr*}
*
*/
virtual const xml_attr* first_attr(void) const = 0;
virtual const xml_attr* first_attr() const = 0;
/**
*
* @return {const xml_attr*}
*
*/
virtual const xml_attr* next_attr(void) const = 0;
virtual const xml_attr* next_attr() const = 0;
/**
* XML
@ -246,7 +245,7 @@ public:
*
* @return {xml_node&}
*/
virtual xml_node& get_parent(void) const = 0;
virtual xml_node& get_parent() const = 0;
/**
*
@ -259,37 +258,37 @@ public:
* xml xml
* @return {int}
*/
virtual int detach(void) = 0;
virtual int detach() = 0;
/**
*
* @return {xml_node*}
*/
virtual xml_node* first_child(void) = 0;
virtual xml_node* first_child() = 0;
/**
*
* @return {xml_node*}
*/
virtual xml_node* next_child(void) = 0;
virtual xml_node* next_child() = 0;
/**
* XML XML
* @return {int}
*/
virtual int depth(void) const = 0;
virtual int depth() const = 0;
/**
* xml root
* @return {bool}
*/
virtual bool is_root(void) const = 0;
virtual bool is_root() const = 0;
/**
* xml
* @return {int} >= 0
*/
virtual int children_count(void) const = 0;
virtual int children_count() const = 0;
/**
* xml xml_node
@ -297,13 +296,13 @@ public:
* first_child/next_child xml_node
* 访
*/
void clear(void);
void clear();
/**
* xml
* @return {xml&}
*/
xml& get_xml(void) const;
xml& get_xml() const;
protected:
friend class xml;
@ -318,7 +317,7 @@ protected:
/**
*
*/
virtual ~xml_node(void);
virtual ~xml_node();
protected:
xml* xml_;
@ -336,7 +335,7 @@ public:
* @param dbuf_capacity {size_t} dbuf_guard
*/
xml(size_t dbuf_nblock = 2, size_t dbuf_capacity = 100);
virtual ~xml(void);
virtual ~xml();
/**
* '/'
@ -390,14 +389,14 @@ public:
* 使 XML
* XML
*/
virtual void reset(void) = 0;
virtual void reset() = 0;
/**
* XML
* @return {const string&}
*
*/
virtual const string& getText(void);
virtual const string& getText();
/**
* XML
@ -515,7 +514,7 @@ public:
* xml
* @return {xml_node&}
*/
virtual xml_node& get_root(void) = 0;
virtual xml_node& get_root() = 0;
/**
* xml
@ -523,7 +522,7 @@ public:
*
*
*/
virtual xml_node* first_node(void) = 0;
virtual xml_node* first_node() = 0;
/**
* xml xml
@ -531,7 +530,7 @@ public:
*
*
*/
virtual xml_node* next_node(void) = 0;
virtual xml_node* next_node() = 0;
/**
* xml
@ -550,24 +549,24 @@ public:
* xml
* @return {size_t}
*/
virtual size_t space(void) const = 0;
virtual size_t space() const = 0;
/**
* xml 0
*/
virtual void space_clear(void) = 0;
virtual void space_clear() = 0;
/**
* xml xml
* @return {size_t}
*/
virtual size_t node_count(void) const = 0;
virtual size_t node_count() const = 0;
/**
* xml xml
* @return {size_t}
*/
virtual size_t attr_count(void) const = 0;
virtual size_t attr_count() const = 0;
public:
// pipe_stream 虚函数重载
@ -575,7 +574,7 @@ public:
virtual int push_pop(const char* in, size_t len,
string* out, size_t max = 0);
virtual int pop_end(string* out, size_t max = 0);
virtual void clear(void);
virtual void clear();
protected:
dbuf_guard dbuf_;

View File

@ -27,7 +27,7 @@ bitmap::bitmap(size_t len)
memset(bmp_, 0, (len + 7) / 8);
}
bitmap::~bitmap(void)
bitmap::~bitmap()
{
delete[] bmp_;
}
@ -84,33 +84,33 @@ bool bitmap::frombuf(const void* buf, size_t len)
return false;
}
void bitmap::reset(void)
void bitmap::reset()
{
memset(bmp_, 0, (size_ + 7) / 8);
count_ = 0;
}
size_t bitmap::size(void) const
size_t bitmap::size() const
{
return size_;
}
size_t bitmap::space(void) const
size_t bitmap::space() const
{
return (size_ + 7) / 8;
}
size_t bitmap::count(void) const
size_t bitmap::count() const
{
return count_;
}
bool bitmap::full(void) const
bool bitmap::full() const
{
return size_ == count_;
}
void bitmap::recount(void)
void bitmap::recount()
{
count_ = 0;
for (size_t i = 0; i < size_; ++i) {

View File

@ -48,7 +48,7 @@ static ACL_DLL_HANDLE __iconv_dll = NULL;
// 程序退出时释放动态加载的 iconv.dll 库
#ifndef HAVE_NO_ATEXIT
static void __iconv_dll_unload(void)
static void __iconv_dll_unload()
{
if (__iconv_dll != NULL) {
acl_dlclose(__iconv_dll);
@ -59,7 +59,7 @@ static void __iconv_dll_unload(void)
#endif
// 动态加载 iconv.dll 库
static void __iconv_dll_load(void)
static void __iconv_dll_load()
{
const char* path = "iconv.dll";

View File

@ -4,8 +4,7 @@
#include "acl_cpp/stdlib/diff_manager.hpp"
#endif
namespace acl
{
namespace acl {
diff_manager::diff_manager(long long range_from /* = -1 */,
long long range_to /* = -1 */)
@ -22,16 +21,16 @@ diff_manager::diff_manager(long long range_from /* = -1 */,
}
}
diff_manager::~diff_manager(void)
diff_manager::~diff_manager()
{
}
acl::dbuf_guard& diff_manager::get_dbuf(void)
acl::dbuf_guard& diff_manager::get_dbuf()
{
return dbuf_;
}
void diff_manager::reset(void)
void diff_manager::reset()
{
objs_new_.clear();
objs_del_.clear();

View File

@ -4,8 +4,7 @@
#include "acl_cpp/stdlib/diff_object.hpp"
#endif
namespace acl
{
namespace acl {
diff_object::diff_object(diff_manager& manager)
: dbuf_obj(&manager.get_dbuf())

View File

@ -4,8 +4,7 @@
#include "acl_cpp/stdlib/diff_string.hpp"
#endif
namespace acl
{
namespace acl {
diff_string::diff_string(diff_manager& manager, const char* key, const char* val)
: diff_object(manager)
@ -16,16 +15,16 @@ diff_string::diff_string(diff_manager& manager, const char* key, const char* val
val_ = dbuf.dbuf_strdup(val);
}
diff_string::~diff_string(void)
diff_string::~diff_string()
{
}
const char* diff_string::get_val(void) const
const char* diff_string::get_val() const
{
return val_;
}
const char* diff_string::get_key(void) const
const char* diff_string::get_key() const
{
return key_;
}
@ -34,7 +33,7 @@ bool diff_string::operator== (const diff_object& obj) const
{
const diff_string& o = (const diff_string&) obj;
return strcmp(o.val_, val_) == 0 ? true : false;
return strcmp(o.val_, val_) == 0;
}
bool diff_string::check_range(long long range_from, long long range_to) const

View File

@ -127,19 +127,18 @@ static void transform(unsigned int buf[4], unsigned int const in[16])
buf[3] += d;
}
namespace acl
{
namespace acl {
/*
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
* initialization constants.
*/
md5::md5(void)
md5::md5()
{
reset();
}
md5::~md5(void) {}
md5::~md5() {}
md5& md5::reset()
{
@ -240,12 +239,12 @@ md5& md5::finish()
return *this;
}
const char* md5::get_digest(void) const
const char* md5::get_digest() const
{
return (const char*) digest_;
}
const char* md5::get_string(void) const
const char* md5::get_string() const
{
const_cast<md5*>(this)->hex_encode(digest_, 16,
(char*) digest_s_, sizeof(digest_s_));

View File

@ -17,10 +17,9 @@
# endif
#endif
namespace acl
{
namespace acl {
scan_dir::scan_dir(void)
scan_dir::scan_dir()
: path_(NULL)
, scan_(NULL)
, path_buf_(NULL)
@ -28,14 +27,14 @@ scan_dir::scan_dir(void)
{
}
scan_dir::~scan_dir(void)
scan_dir::~scan_dir()
{
close();
delete path_buf_;
delete file_buf_;
}
void scan_dir::close(void)
void scan_dir::close()
{
if (path_) {
acl_myfree(path_);
@ -233,7 +232,7 @@ const char* scan_dir::next(bool full /* = false */, bool* is_file /* = NULL */)
return file_buf_->c_str();
}
const char* scan_dir::curr_path(void)
const char* scan_dir::curr_path()
{
if (scan_ == NULL) {
return NULL;
@ -314,7 +313,7 @@ const char* scan_dir::curr_file(bool full /* = false */)
return file_buf_->c_str();
}
size_t scan_dir::dir_count(void) const
size_t scan_dir::dir_count() const
{
if (scan_ == NULL) {
return 0;
@ -322,7 +321,7 @@ size_t scan_dir::dir_count(void) const
return acl_scan_dir_ndirs(scan_);
}
size_t scan_dir::file_count(void) const
size_t scan_dir::file_count() const
{
if (scan_ == NULL) {
return 0;
@ -330,7 +329,7 @@ size_t scan_dir::file_count(void) const
return acl_scan_dir_nfiles(scan_);
}
acl_uint64 scan_dir::scaned_size(void) const
acl_uint64 scan_dir::scaned_size() const
{
if (scan_ == NULL) {
return 0;

View File

@ -42,8 +42,7 @@
#include "acl_cpp/stdlib/sha1.hpp"
#endif
namespace acl
{
namespace acl {
/*
* sha1

View File

@ -11,10 +11,9 @@
#include <pthread_np.h>
#endif
namespace acl
{
namespace acl {
thread::thread(void)
thread::thread()
: detachable_(false)
, stack_size_(0)
, thread_id_(0)
@ -27,7 +26,7 @@ thread::thread(void)
lock_ = NEW atomic_long;
}
thread::~thread(void)
thread::~thread()
{
#ifdef ACL_WINDOWS
acl_myfree(thread_);
@ -48,7 +47,7 @@ thread& thread::set_stacksize(size_t size)
return *this;
}
void thread::wait_for_running(void)
void thread::wait_for_running()
{
if (lock_->cas(0, 1) == 0) {
if (thread_id_ == 0) {
@ -188,7 +187,7 @@ bool thread::wait(void** out /* = NULL */)
return true;
}
unsigned long thread::thread_id(void) const
unsigned long thread::thread_id() const
{
const_cast<thread*>(this)->wait_for_running();
@ -200,7 +199,7 @@ unsigned long thread::thread_id(void) const
return thread_id_;
}
unsigned long thread::thread_self(void)
unsigned long thread::thread_self()
{
#ifdef ACL_FREEBSD
#if defined(__FreeBSD__) && (__FreeBSD__ >= 9)

View File

@ -23,19 +23,19 @@ thread_cond::thread_cond(thread_mutex* mutex)
acl_pthread_cond_init(cond_, NULL);
}
thread_cond::~thread_cond(void)
thread_cond::~thread_cond()
{
acl_pthread_cond_destroy(cond_);
acl_myfree(cond_);
delete mutex_internal_;
}
bool thread_cond::notify(void)
bool thread_cond::notify()
{
return acl_pthread_cond_signal(cond_) == 0;
}
bool thread_cond::notify_all(void)
bool thread_cond::notify_all()
{
return acl_pthread_cond_broadcast(cond_) == 0;
}
@ -122,15 +122,15 @@ bool thread_cond::timed_wait(long long microseconds, bool locked)
return false;
}
return ret == 0 ? true : false;
return ret == 0;
}
thread_mutex& thread_cond::get_mutex(void) const
thread_mutex& thread_cond::get_mutex() const
{
return *mutex_;
}
acl_pthread_cond_t* thread_cond::get_cond(void) const
acl_pthread_cond_t* thread_cond::get_cond() const
{
return cond_;
}

View File

@ -47,7 +47,7 @@ thread_mutex::thread_mutex(bool recursive /* = true */)
#endif
}
thread_mutex::~thread_mutex(void)
thread_mutex::~thread_mutex()
{
#ifndef ACL_WINDOWS
(void) pthread_mutexattr_destroy(&mutex_attr_);
@ -56,12 +56,12 @@ thread_mutex::~thread_mutex(void)
acl_myfree(mutex_);
}
acl_pthread_mutex_t* thread_mutex::get_mutex(void) const
acl_pthread_mutex_t* thread_mutex::get_mutex() const
{
return mutex_;
}
bool thread_mutex::lock(void)
bool thread_mutex::lock()
{
int ret = acl_pthread_mutex_lock(mutex_);
if (ret) {
@ -74,12 +74,12 @@ bool thread_mutex::lock(void)
return true;
}
bool thread_mutex::try_lock(void)
bool thread_mutex::try_lock()
{
return acl_pthread_mutex_trylock(mutex_) == 0;
}
bool thread_mutex::unlock(void)
bool thread_mutex::unlock()
{
int ret = acl_pthread_mutex_unlock(mutex_);
if (ret) {
@ -102,7 +102,7 @@ thread_mutex_guard::thread_mutex_guard(thread_mutex& mutex)
}
}
thread_mutex_guard::~thread_mutex_guard(void)
thread_mutex_guard::~thread_mutex_guard()
{
if (!mutex_.unlock()) {
logger_fatal("unlock error=%s", last_serror());

View File

@ -3,10 +3,9 @@
#include "acl_cpp/stdlib/thread_queue.hpp"
#endif
namespace acl
{
namespace acl {
thread_queue::thread_queue(void)
thread_queue::thread_queue()
{
queue_ = (ACL_AQUEUE*) acl_aqueue_new();
}
@ -17,7 +16,7 @@ static void free_qitem(void* item)
delete qitem;
}
thread_queue::~thread_queue(void)
thread_queue::~thread_queue()
{
acl_aqueue_free(queue_, free_qitem);
}
@ -35,7 +34,7 @@ thread_qitem* thread_queue::pop(int wait_ms /* = -1 */)
queue_, wait_sec, wait_usec);
}
int thread_queue::qlen(void) const
int thread_queue::qlen() const
{
return acl_aqueue_qlen(queue_);
}

View File

@ -5,10 +5,9 @@
#include "acl_cpp/stdlib/trigger.hpp"
namespace acl
{
namespace acl {
int last_error(void)
int last_error()
{
return acl_last_error();
}
@ -18,7 +17,7 @@ void set_error(int errnum)
acl_set_error(errnum);
}
const char* last_serror(void)
const char* last_serror()
{
return acl_last_serror();
}
@ -40,7 +39,7 @@ int strncasecmp_(const char *s1, const char *s2, size_t n)
void assert_(bool n)
{
if (n == false) {
if (! n) {
abort();
}
}
@ -50,7 +49,7 @@ void meter_time(const char *filename, int line, const char *info)
acl_meter_time(filename, line, info);
}
long long get_curr_stamp(void)
long long get_curr_stamp()
{
struct timeval now;
gettimeofday(&now, NULL);

View File

@ -9,19 +9,19 @@
namespace acl {
xml_node::xml_node(xml* xml_ptr)
: xml_(xml_ptr)
: xml_(xml_ptr)
{
if (xml_ptr == NULL) {
abort();
}
}
xml_node::~xml_node(void)
xml_node::~xml_node()
{
clear();
}
void xml_node::clear(void)
void xml_node::clear()
{
std::vector<xml_node*>::iterator it = nodes_tmp_.begin();
for (; it != nodes_tmp_.end(); ++it) {
@ -36,7 +36,7 @@ void xml_node::clear(void)
attrs_tmp_.clear();
}
xml& xml_node::get_xml(void) const
xml& xml_node::get_xml() const
{
return *xml_;
}
@ -131,7 +131,7 @@ xml::xml(size_t dbuf_nblock /* = 2 */, size_t dbuf_capacity /* = 100 */)
m_pTokenTree = NULL;
}
xml::~xml(void)
xml::~xml()
{
clear();
@ -141,7 +141,7 @@ xml::~xml(void)
}
}
void xml::clear(void)
void xml::clear()
{
if (buf_) {
buf_->clear();
@ -160,7 +160,7 @@ void xml::clear(void)
dbuf_.dbuf_reset();
}
const acl::string& xml::getText(void)
const acl::string& xml::getText()
{
if (buf_ == NULL)
buf_ = NEW string();