mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 03:53:09 +00:00
remove unused skynet_context_init
This commit is contained in:
@@ -49,7 +49,6 @@ skynet_handle_register(struct skynet_context *ctx) {
|
||||
rwlock_wunlock(&s->lock);
|
||||
|
||||
handle |= s->harbor;
|
||||
skynet_context_init(ctx, handle);
|
||||
return handle;
|
||||
}
|
||||
}
|
||||
@@ -67,8 +66,9 @@ skynet_handle_register(struct skynet_context *ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
skynet_handle_retire(uint32_t handle) {
|
||||
int ret = 0;
|
||||
struct handle_storage *s = H;
|
||||
|
||||
rwlock_wlock(&s->lock);
|
||||
@@ -79,6 +79,7 @@ skynet_handle_retire(uint32_t handle) {
|
||||
if (ctx != NULL && skynet_context_handle(ctx) == handle) {
|
||||
skynet_context_release(ctx);
|
||||
s->slot[hash] = NULL;
|
||||
ret = 1;
|
||||
int i;
|
||||
int j=0, n=s->name_count;
|
||||
for (i=0; i<n; ++i) {
|
||||
@@ -94,6 +95,8 @@ skynet_handle_retire(uint32_t handle) {
|
||||
}
|
||||
|
||||
rwlock_wunlock(&s->lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -105,10 +108,14 @@ skynet_handle_retireall() {
|
||||
for (i=0;i<s->slot_size;i++) {
|
||||
rwlock_rlock(&s->lock);
|
||||
struct skynet_context * ctx = s->slot[i];
|
||||
uint32_t handle = 0;
|
||||
if (ctx)
|
||||
handle = skynet_context_handle(ctx);
|
||||
rwlock_runlock(&s->lock);
|
||||
if (ctx != NULL) {
|
||||
++n;
|
||||
skynet_handle_retire(skynet_context_handle(ctx));
|
||||
if (handle != 0) {
|
||||
if (skynet_handle_retire(handle)) {
|
||||
++n;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (n==0)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
struct skynet_context;
|
||||
|
||||
uint32_t skynet_handle_register(struct skynet_context *);
|
||||
void skynet_handle_retire(uint32_t handle);
|
||||
int skynet_handle_retire(uint32_t handle);
|
||||
struct skynet_context * skynet_handle_grab(uint32_t handle);
|
||||
void skynet_handle_retireall();
|
||||
|
||||
|
||||
@@ -132,6 +132,8 @@ skynet_context_new(const char * name, const char *param) {
|
||||
|
||||
ctx->init = false;
|
||||
ctx->endless = false;
|
||||
// Should set to 0 first to avoid skynet_handle_retireall get an uninitialized handle
|
||||
ctx->handle = 0;
|
||||
ctx->handle = skynet_handle_register(ctx);
|
||||
struct message_queue * queue = ctx->queue = skynet_mq_create(ctx->handle);
|
||||
// init function maybe use ctx->handle, so it must init at last
|
||||
@@ -646,11 +648,6 @@ skynet_context_handle(struct skynet_context *ctx) {
|
||||
return ctx->handle;
|
||||
}
|
||||
|
||||
void
|
||||
skynet_context_init(struct skynet_context *ctx, uint32_t handle) {
|
||||
ctx->handle = handle;
|
||||
}
|
||||
|
||||
void
|
||||
skynet_callback(struct skynet_context * context, void *ud, skynet_cb cb) {
|
||||
context->cb = cb;
|
||||
|
||||
@@ -12,7 +12,6 @@ struct skynet_context * skynet_context_new(const char * name, const char * parm)
|
||||
void skynet_context_grab(struct skynet_context *);
|
||||
struct skynet_context * skynet_context_release(struct skynet_context *);
|
||||
uint32_t skynet_context_handle(struct skynet_context *);
|
||||
void skynet_context_init(struct skynet_context *, uint32_t handle);
|
||||
int skynet_context_push(uint32_t handle, struct skynet_message *message);
|
||||
void skynet_context_send(struct skynet_context * context, void * msg, size_t sz, uint32_t source, int type, int session);
|
||||
int skynet_context_newsession(struct skynet_context *);
|
||||
|
||||
Reference in New Issue
Block a user