#ifndef _WORKER_HPP_ #define _WORKER_HPP_ #include struct task { uint32_t m_cmd_code; uint32_t m_hash_id; char m_d[1]; void destroy() { free(this); } template const T&body()const { const void*x=&m_d[0]; return *(T*)x; } template T&body() { void*x=&m_d[0]; return *(T*)x; } static size_t align(size_t n) { return (n+31)&~0x1F; } template static task*alloc() { return (task*)malloc(align(sizeof(T)+sizeof(task))); } }; struct area_business; struct message_change_business { int area_id; std::atomic ref_count; std::vector del_list,add_list,new_list; }; struct worker { virtual void stop()=0; virtual void request(task*tk)=0; virtual void broadcast(task*tk) { } virtual int num_thread() { return 1; } static worker*instance(); }; #endif