Skip to content

Commit

Permalink
Remove the inline modifier of the built-in function of the class, tha…
Browse files Browse the repository at this point in the history
…t is redundant
  • Loading branch information
matyhtf committed Jun 26, 2023
1 parent a2c46af commit 492419b
Show file tree
Hide file tree
Showing 17 changed files with 204 additions and 204 deletions.
8 changes: 4 additions & 4 deletions include/swoole_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ struct Channel {
Lock *lock;
Pipe *notify_pipe;

inline bool empty() {
bool empty() {
return num == 0;
}
inline bool full() {
bool full() {
return ((head == tail && tail_tag != head_tag) || (bytes + sizeof(int) * num == size));
}
int pop(void *out_buf, int buffer_length);
Expand All @@ -66,10 +66,10 @@ struct Channel {
int notify();
void destroy();
void print();
inline int count() {
int count() {
return num;
}
inline int get_bytes() {
int get_bytes() {
return bytes;
}
static Channel *make(size_t size, size_t maxlen, int flags);
Expand Down
2 changes: 1 addition & 1 deletion include/swoole_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class Stream {
int send(const char *data, size_t length);
void set_max_length(uint32_t max_length);

inline static Stream *create(const char *dst_host, int dst_port, SocketType type) {
static inline Stream *create(const char *dst_host, int dst_port, SocketType type) {
Stream *stream = new Stream(dst_host, dst_port, type);
if (!stream->connected) {
delete stream;
Expand Down
34 changes: 17 additions & 17 deletions include/swoole_coroutine.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Coroutine {

typedef void (*SwapCallback)(void *);
typedef std::function<void(void)> BailoutCallback;
typedef std::function<bool(swoole::Coroutine*)> CancelFunc;
typedef std::function<bool(swoole::Coroutine *)> CancelFunc;

void resume();
void yield();
Expand All @@ -79,31 +79,31 @@ class Coroutine {

bool yield_ex(double timeout = -1);

inline enum State get_state() const {
enum State get_state() const {
return state;
}

inline long get_init_msec() const {
long get_init_msec() const {
return init_msec;
}

inline long get_cid() const {
long get_cid() const {
return cid;
}

inline Coroutine *get_origin() {
Coroutine *get_origin() {
return origin;
}

inline long get_origin_cid() {
long get_origin_cid() {
return sw_likely(origin) ? origin->get_cid() : -1;
}

inline void *get_task() {
void *get_task() {
return task;
}

inline bool is_end() {
bool is_end() {
return ctx.is_end();
}

Expand All @@ -119,15 +119,15 @@ class Coroutine {
return state == STATE_WAITING;
}

inline void set_task(void *_task) {
void set_task(void *_task) {
task = _task;
}

void set_cancel_fn(CancelFunc *cancel_fn) {
cancel_fn_ = cancel_fn;
}

inline long get_execute_usec() const {
long get_execute_usec() const {
return time<seconds_type>(true) - switch_usec + execute_usec;
}

Expand All @@ -149,7 +149,7 @@ class Coroutine {
#ifdef SW_USE_THREAD_CONTEXT
try {
return (new Coroutine(fn, args))->run();
} catch (const std::system_error& e) {
} catch (const std::system_error &e) {
swoole_set_last_error(e.code().value());
swoole_warning("failed to create coroutine, Error: %s[%d]", e.what(), swoole_get_last_error());
return -1;
Expand Down Expand Up @@ -245,9 +245,9 @@ class Coroutine {
static long last_cid;
static uint64_t peak_num;
static size_t stack_size;
static SwapCallback on_yield; /* before yield */
static SwapCallback on_resume; /* before resume */
static SwapCallback on_close; /* before close */
static SwapCallback on_yield; /* before yield */
static SwapCallback on_resume; /* before resume */
static SwapCallback on_close; /* before close */
static BailoutCallback on_bailout; /* when bailout */
static bool activated;

Expand All @@ -270,11 +270,11 @@ class Coroutine {
}
}

Coroutine(long _cid, const CoroutineFunc &fn, void *private_data): ctx(stack_size, fn, private_data) {
Coroutine(long _cid, const CoroutineFunc &fn, void *private_data) : ctx(stack_size, fn, private_data) {
cid = _cid;
}

inline long run() {
long run() {
long cid = this->cid;
origin = current;
current = this;
Expand All @@ -285,7 +285,7 @@ class Coroutine {
return cid;
}

inline void check_end() {
void check_end() {
if (ctx.is_end()) {
close();
} else if (sw_unlikely(on_bailout)) {
Expand Down
20 changes: 10 additions & 10 deletions include/swoole_coroutine_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,31 +73,31 @@ class Channel {
}
}

inline bool is_closed() {
bool is_closed() {
return closed;
}

inline bool is_empty() {
bool is_empty() {
return data_queue.size() == 0;
}

inline bool is_full() {
bool is_full() {
return data_queue.size() == capacity;
}

inline size_t length() {
size_t length() {
return data_queue.size();
}

inline size_t consumer_num() {
size_t consumer_num() {
return consumer_queue.size();
}

inline size_t producer_num() {
size_t producer_num() {
return producer_queue.size();
}

inline void *pop_data() {
void *pop_data() {
if (data_queue.size() == 0) {
return nullptr;
}
Expand All @@ -122,15 +122,15 @@ class Channel {

void yield(enum Opcode type);

inline void consumer_remove(Coroutine *co) {
void consumer_remove(Coroutine *co) {
consumer_queue.remove(co);
}

inline void producer_remove(Coroutine *co) {
void producer_remove(Coroutine *co) {
producer_queue.remove(co);
}

inline Coroutine *pop_coroutine(enum Opcode type) {
Coroutine *pop_coroutine(enum Opcode type) {
Coroutine *co;
if (type == PRODUCER) {
co = producer_queue.front();
Expand Down
2 changes: 1 addition & 1 deletion include/swoole_coroutine_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Context {
#if !defined(SW_USE_THREAD_CONTEXT) && defined(SW_CONTEXT_DETECT_STACK_USAGE)
ssize_t get_stack_usage();
#endif
inline bool is_end() const {
bool is_end() const {
return end_;
}

Expand Down
Loading

0 comments on commit 492419b

Please sign in to comment.