server_wrap_mt_common.h 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
  1. /*************************************************************************/
  2. /* server_wrap_mt_common.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #define FUNC0R(m_r, m_type) \
  31. virtual m_r m_type() { \
  32. if (Thread::get_caller_id() != server_thread) { \
  33. m_r ret; \
  34. command_queue.push_and_ret(server_name, &ServerName::m_type, &ret); \
  35. SYNC_DEBUG \
  36. return ret; \
  37. } else { \
  38. return server_name->m_type(); \
  39. } \
  40. }
  41. #define FUNCRID(m_type) \
  42. List<RID> m_type##_id_pool; \
  43. int m_type##allocn() { \
  44. for (int i = 0; i < pool_max_size; i++) { \
  45. m_type##_id_pool.push_back(server_name->m_type##_create()); \
  46. } \
  47. return 0; \
  48. } \
  49. void m_type##_free_cached_ids() { \
  50. while (m_type##_id_pool.size()) { \
  51. free(m_type##_id_pool.front()->get()); \
  52. m_type##_id_pool.pop_front(); \
  53. } \
  54. } \
  55. virtual RID m_type##_create() { \
  56. if (Thread::get_caller_id() != server_thread) { \
  57. RID rid; \
  58. alloc_mutex->lock(); \
  59. if (m_type##_id_pool.size() == 0) { \
  60. int ret; \
  61. command_queue.push_and_ret(this, &ServerNameWrapMT::m_type##allocn, &ret); \
  62. SYNC_DEBUG \
  63. } \
  64. rid = m_type##_id_pool.front()->get(); \
  65. m_type##_id_pool.pop_front(); \
  66. alloc_mutex->unlock(); \
  67. return rid; \
  68. } else { \
  69. return server_name->m_type##_create(); \
  70. } \
  71. }
  72. #define FUNC1RID(m_type, m_arg1) \
  73. int m_type##allocn() { \
  74. for (int i = 0; i < m_type##_pool_max_size; i++) { \
  75. m_type##_id_pool.push_back(server_name->m_type##_create()); \
  76. } \
  77. return 0; \
  78. } \
  79. void m_type##_free_cached_ids() { \
  80. while (m_type##_id_pool.size()) { \
  81. free(m_type##_id_pool.front()->get()); \
  82. m_type##_id_pool.pop_front(); \
  83. } \
  84. } \
  85. virtual RID m_type##_create(m_arg1 p1) { \
  86. if (Thread::get_caller_id() != server_thread) { \
  87. RID rid; \
  88. alloc_mutex->lock(); \
  89. if (m_type##_id_pool.size() == 0) { \
  90. int ret; \
  91. command_queue.push_and_ret(this, &ServerNameWrapMT::m_type##allocn, p1, &ret); \
  92. SYNC_DEBUG \
  93. } \
  94. rid = m_type##_id_pool.front()->get(); \
  95. m_type##_id_pool.pop_front(); \
  96. alloc_mutex->unlock(); \
  97. return rid; \
  98. } else { \
  99. return server_name->m_type##_create(p1); \
  100. } \
  101. }
  102. #define FUNC2RID(m_type, m_arg1, m_arg2) \
  103. int m_type##allocn() { \
  104. for (int i = 0; i < m_type##_pool_max_size; i++) { \
  105. m_type##_id_pool.push_back(server_name->m_type##_create()); \
  106. } \
  107. return 0; \
  108. } \
  109. void m_type##_free_cached_ids() { \
  110. while (m_type##_id_pool.size()) { \
  111. free(m_type##_id_pool.front()->get()); \
  112. m_type##_id_pool.pop_front(); \
  113. } \
  114. } \
  115. virtual RID m_type##_create(m_arg1 p1, m_arg2 p2) { \
  116. if (Thread::get_caller_id() != server_thread) { \
  117. RID rid; \
  118. alloc_mutex->lock(); \
  119. if (m_type##_id_pool.size() == 0) { \
  120. int ret; \
  121. command_queue.push_and_ret(this, &ServerNameWrapMT::m_type##allocn, p1, p2, &ret); \
  122. SYNC_DEBUG \
  123. } \
  124. rid = m_type##_id_pool.front()->get(); \
  125. m_type##_id_pool.pop_front(); \
  126. alloc_mutex->unlock(); \
  127. return rid; \
  128. } else { \
  129. return server_name->m_type##_create(p1, p2); \
  130. } \
  131. }
  132. #define FUNC3RID(m_type, m_arg1, m_arg2, m_arg3) \
  133. int m_type##allocn() { \
  134. for (int i = 0; i < m_type##_pool_max_size; i++) { \
  135. m_type##_id_pool.push_back(server_name->m_type##_create()); \
  136. } \
  137. return 0; \
  138. } \
  139. void m_type##_free_cached_ids() { \
  140. while (m_type##_id_pool.size()) { \
  141. free(m_type##_id_pool.front()->get()); \
  142. m_type##_id_pool.pop_front(); \
  143. } \
  144. } \
  145. virtual RID m_type##_create(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
  146. if (Thread::get_caller_id() != server_thread) { \
  147. RID rid; \
  148. alloc_mutex->lock(); \
  149. if (m_type##_id_pool.size() == 0) { \
  150. int ret; \
  151. command_queue.push_and_ret(this, &ServerNameWrapMT::m_type##allocn, p1, p2, p3, &ret); \
  152. SYNC_DEBUG \
  153. } \
  154. rid = m_type##_id_pool.front()->get(); \
  155. m_type##_id_pool.pop_front(); \
  156. alloc_mutex->unlock(); \
  157. return rid; \
  158. } else { \
  159. return server_name->m_type##_create(p1, p2, p3); \
  160. } \
  161. }
  162. #define FUNC4RID(m_type, m_arg1, m_arg2, m_arg3, m_arg4) \
  163. int m_type##allocn() { \
  164. for (int i = 0; i < m_type##_pool_max_size; i++) { \
  165. m_type##_id_pool.push_back(server_name->m_type##_create()); \
  166. } \
  167. return 0; \
  168. } \
  169. void m_type##_free_cached_ids() { \
  170. while (m_type##_id_pool.size()) { \
  171. free(m_type##_id_pool.front()->get()); \
  172. m_type##_id_pool.pop_front(); \
  173. } \
  174. } \
  175. virtual RID m_type##_create(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
  176. if (Thread::get_caller_id() != server_thread) { \
  177. RID rid; \
  178. alloc_mutex->lock(); \
  179. if (m_type##_id_pool.size() == 0) { \
  180. int ret; \
  181. command_queue.push_and_ret(this, &ServerNameWrapMT::m_type##allocn, p1, p2, p3, p4, &ret); \
  182. SYNC_DEBUG \
  183. } \
  184. rid = m_type##_id_pool.front()->get(); \
  185. m_type##_id_pool.pop_front(); \
  186. alloc_mutex->unlock(); \
  187. return rid; \
  188. } else { \
  189. return server_name->m_type##_create(p1, p2, p3, p4); \
  190. } \
  191. }
  192. #define FUNC5RID(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5) \
  193. int m_type##allocn() { \
  194. for (int i = 0; i < m_type##_pool_max_size; i++) { \
  195. m_type##_id_pool.push_back(server_name->m_type##_create()); \
  196. } \
  197. return 0; \
  198. } \
  199. void m_type##_free_cached_ids() { \
  200. while (m_type##_id_pool.size()) { \
  201. free(m_type##_id_pool.front()->get()); \
  202. m_type##_id_pool.pop_front(); \
  203. } \
  204. } \
  205. virtual RID m_type##_create(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
  206. if (Thread::get_caller_id() != server_thread) { \
  207. RID rid; \
  208. alloc_mutex->lock(); \
  209. if (m_type##_id_pool.size() == 0) { \
  210. int ret; \
  211. command_queue.push_and_ret(this, &ServerNameWrapMT::m_type##allocn, p1, p2, p3, p4, p5, &ret); \
  212. SYNC_DEBUG \
  213. } \
  214. rid = m_type##_id_pool.front()->get(); \
  215. m_type##_id_pool.pop_front(); \
  216. alloc_mutex->unlock(); \
  217. return rid; \
  218. } else { \
  219. return server_name->m_type##_create(p1, p2, p3, p4, p5); \
  220. } \
  221. }
  222. #define FUNC0RC(m_r, m_type) \
  223. virtual m_r m_type() const { \
  224. if (Thread::get_caller_id() != server_thread) { \
  225. m_r ret; \
  226. command_queue.push_and_ret(server_name, &ServerName::m_type, &ret); \
  227. SYNC_DEBUG \
  228. return ret; \
  229. } else { \
  230. return server_name->m_type(); \
  231. } \
  232. }
  233. #define FUNC0(m_type) \
  234. virtual void m_type() { \
  235. if (Thread::get_caller_id() != server_thread) { \
  236. command_queue.push(server_name, &ServerName::m_type); \
  237. } else { \
  238. server_name->m_type(); \
  239. } \
  240. }
  241. #define FUNC0C(m_type) \
  242. virtual void m_type() const { \
  243. if (Thread::get_caller_id() != server_thread) { \
  244. command_queue.push(server_name, &ServerName::m_type); \
  245. } else { \
  246. server_name->m_type(); \
  247. } \
  248. }
  249. #define FUNC0S(m_type) \
  250. virtual void m_type() { \
  251. if (Thread::get_caller_id() != server_thread) { \
  252. command_queue.push_and_sync(server_name, &ServerName::m_type); \
  253. SYNC_DEBUG \
  254. } else { \
  255. server_name->m_type(); \
  256. } \
  257. }
  258. #define FUNC0SC(m_type) \
  259. virtual void m_type() const { \
  260. if (Thread::get_caller_id() != server_thread) { \
  261. command_queue.push_and_sync(server_name, &ServerName::m_type); \
  262. SYNC_DEBUG \
  263. } else { \
  264. server_name->m_type(); \
  265. } \
  266. }
  267. ///////////////////////////////////////////////
  268. #define FUNC1R(m_r, m_type, m_arg1) \
  269. virtual m_r m_type(m_arg1 p1) { \
  270. if (Thread::get_caller_id() != server_thread) { \
  271. m_r ret; \
  272. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, &ret); \
  273. SYNC_DEBUG \
  274. return ret; \
  275. } else { \
  276. return server_name->m_type(p1); \
  277. } \
  278. }
  279. #define FUNC1RC(m_r, m_type, m_arg1) \
  280. virtual m_r m_type(m_arg1 p1) const { \
  281. if (Thread::get_caller_id() != server_thread) { \
  282. m_r ret; \
  283. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, &ret); \
  284. SYNC_DEBUG \
  285. return ret; \
  286. } else { \
  287. return server_name->m_type(p1); \
  288. } \
  289. }
  290. #define FUNC1S(m_type, m_arg1) \
  291. virtual void m_type(m_arg1 p1) { \
  292. if (Thread::get_caller_id() != server_thread) { \
  293. command_queue.push_and_sync(server_name, &ServerName::m_type, p1); \
  294. SYNC_DEBUG \
  295. } else { \
  296. server_name->m_type(p1); \
  297. } \
  298. }
  299. #define FUNC1SC(m_type, m_arg1) \
  300. virtual void m_type(m_arg1 p1) const { \
  301. if (Thread::get_caller_id() != server_thread) { \
  302. command_queue.push_and_sync(server_name, &ServerName::m_type, p1); \
  303. SYNC_DEBUG \
  304. } else { \
  305. server_name->m_type(p1); \
  306. } \
  307. }
  308. #define FUNC1(m_type, m_arg1) \
  309. virtual void m_type(m_arg1 p1) { \
  310. if (Thread::get_caller_id() != server_thread) { \
  311. command_queue.push(server_name, &ServerName::m_type, p1); \
  312. } else { \
  313. server_name->m_type(p1); \
  314. } \
  315. }
  316. #define FUNC1C(m_type, m_arg1) \
  317. virtual void m_type(m_arg1 p1) const { \
  318. if (Thread::get_caller_id() != server_thread) { \
  319. command_queue.push(server_name, &ServerName::m_type, p1); \
  320. } else { \
  321. server_name->m_type(p1); \
  322. } \
  323. }
  324. #define FUNC2R(m_r, m_type, m_arg1, m_arg2) \
  325. virtual m_r m_type(m_arg1 p1, m_arg2 p2) { \
  326. if (Thread::get_caller_id() != server_thread) { \
  327. m_r ret; \
  328. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, &ret); \
  329. SYNC_DEBUG \
  330. return ret; \
  331. } else { \
  332. return server_name->m_type(p1, p2); \
  333. } \
  334. }
  335. #define FUNC2RC(m_r, m_type, m_arg1, m_arg2) \
  336. virtual m_r m_type(m_arg1 p1, m_arg2 p2) const { \
  337. if (Thread::get_caller_id() != server_thread) { \
  338. m_r ret; \
  339. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, &ret); \
  340. SYNC_DEBUG \
  341. return ret; \
  342. } else { \
  343. return server_name->m_type(p1, p2); \
  344. } \
  345. }
  346. #define FUNC2S(m_type, m_arg1, m_arg2) \
  347. virtual void m_type(m_arg1 p1, m_arg2 p2) { \
  348. if (Thread::get_caller_id() != server_thread) { \
  349. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2); \
  350. SYNC_DEBUG \
  351. } else { \
  352. server_name->m_type(p1, p2); \
  353. } \
  354. }
  355. #define FUNC2SC(m_type, m_arg1, m_arg2) \
  356. virtual void m_type(m_arg1 p1, m_arg2 p2) const { \
  357. if (Thread::get_caller_id() != server_thread) { \
  358. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2); \
  359. SYNC_DEBUG \
  360. } else { \
  361. server_name->m_type(p1, p2); \
  362. } \
  363. }
  364. #define FUNC2(m_type, m_arg1, m_arg2) \
  365. virtual void m_type(m_arg1 p1, m_arg2 p2) { \
  366. if (Thread::get_caller_id() != server_thread) { \
  367. command_queue.push(server_name, &ServerName::m_type, p1, p2); \
  368. } else { \
  369. server_name->m_type(p1, p2); \
  370. } \
  371. }
  372. #define FUNC2C(m_type, m_arg1, m_arg2) \
  373. virtual void m_type(m_arg1 p1, m_arg2 p2) const { \
  374. if (Thread::get_caller_id() != server_thread) { \
  375. command_queue.push(server_name, &ServerName::m_type, p1, p2); \
  376. } else { \
  377. server_name->m_type(p1, p2); \
  378. } \
  379. }
  380. #define FUNC3R(m_r, m_type, m_arg1, m_arg2, m_arg3) \
  381. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
  382. if (Thread::get_caller_id() != server_thread) { \
  383. m_r ret; \
  384. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, &ret); \
  385. SYNC_DEBUG \
  386. return ret; \
  387. } else { \
  388. return server_name->m_type(p1, p2, p3); \
  389. } \
  390. }
  391. #define FUNC3RC(m_r, m_type, m_arg1, m_arg2, m_arg3) \
  392. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
  393. if (Thread::get_caller_id() != server_thread) { \
  394. m_r ret; \
  395. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, &ret); \
  396. SYNC_DEBUG \
  397. return ret; \
  398. } else { \
  399. return server_name->m_type(p1, p2, p3); \
  400. } \
  401. }
  402. #define FUNC3S(m_type, m_arg1, m_arg2, m_arg3) \
  403. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
  404. if (Thread::get_caller_id() != server_thread) { \
  405. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3); \
  406. SYNC_DEBUG \
  407. } else { \
  408. server_name->m_type(p1, p2, p3); \
  409. } \
  410. }
  411. #define FUNC3SC(m_type, m_arg1, m_arg2, m_arg3) \
  412. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
  413. if (Thread::get_caller_id() != server_thread) { \
  414. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3); \
  415. SYNC_DEBUG \
  416. } else { \
  417. server_name->m_type(p1, p2, p3); \
  418. } \
  419. }
  420. #define FUNC3(m_type, m_arg1, m_arg2, m_arg3) \
  421. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
  422. if (Thread::get_caller_id() != server_thread) { \
  423. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3); \
  424. } else { \
  425. server_name->m_type(p1, p2, p3); \
  426. } \
  427. }
  428. #define FUNC3C(m_type, m_arg1, m_arg2, m_arg3) \
  429. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
  430. if (Thread::get_caller_id() != server_thread) { \
  431. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3); \
  432. } else { \
  433. server_name->m_type(p1, p2, p3); \
  434. } \
  435. }
  436. #define FUNC4R(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4) \
  437. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
  438. if (Thread::get_caller_id() != server_thread) { \
  439. m_r ret; \
  440. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, &ret); \
  441. SYNC_DEBUG \
  442. return ret; \
  443. } else { \
  444. return server_name->m_type(p1, p2, p3, p4); \
  445. } \
  446. }
  447. #define FUNC4RC(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4) \
  448. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
  449. if (Thread::get_caller_id() != server_thread) { \
  450. m_r ret; \
  451. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, &ret); \
  452. SYNC_DEBUG \
  453. return ret; \
  454. } else { \
  455. return server_name->m_type(p1, p2, p3, p4); \
  456. } \
  457. }
  458. #define FUNC4S(m_type, m_arg1, m_arg2, m_arg3, m_arg4) \
  459. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
  460. if (Thread::get_caller_id() != server_thread) { \
  461. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4); \
  462. SYNC_DEBUG \
  463. } else { \
  464. server_name->m_type(p1, p2, p3, p4); \
  465. } \
  466. }
  467. #define FUNC4SC(m_type, m_arg1, m_arg2, m_arg3, m_arg4) \
  468. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
  469. if (Thread::get_caller_id() != server_thread) { \
  470. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4); \
  471. SYNC_DEBUG \
  472. } else { \
  473. server_name->m_type(p1, p2, p3, p4); \
  474. } \
  475. }
  476. #define FUNC4(m_type, m_arg1, m_arg2, m_arg3, m_arg4) \
  477. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
  478. if (Thread::get_caller_id() != server_thread) { \
  479. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4); \
  480. } else { \
  481. server_name->m_type(p1, p2, p3, p4); \
  482. } \
  483. }
  484. #define FUNC4C(m_type, m_arg1, m_arg2, m_arg3, m_arg4) \
  485. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
  486. if (Thread::get_caller_id() != server_thread) { \
  487. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4); \
  488. } else { \
  489. server_name->m_type(p1, p2, p3, p4); \
  490. } \
  491. }
  492. #define FUNC5R(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5) \
  493. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
  494. if (Thread::get_caller_id() != server_thread) { \
  495. m_r ret; \
  496. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, &ret); \
  497. SYNC_DEBUG \
  498. return ret; \
  499. } else { \
  500. return server_name->m_type(p1, p2, p3, p4, p5); \
  501. } \
  502. }
  503. #define FUNC5RC(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5) \
  504. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
  505. if (Thread::get_caller_id() != server_thread) { \
  506. m_r ret; \
  507. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, &ret); \
  508. SYNC_DEBUG \
  509. return ret; \
  510. } else { \
  511. return server_name->m_type(p1, p2, p3, p4, p5); \
  512. } \
  513. }
  514. #define FUNC5S(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5) \
  515. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
  516. if (Thread::get_caller_id() != server_thread) { \
  517. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5); \
  518. SYNC_DEBUG \
  519. } else { \
  520. server_name->m_type(p1, p2, p3, p4, p5); \
  521. } \
  522. }
  523. #define FUNC5SC(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5) \
  524. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
  525. if (Thread::get_caller_id() != server_thread) { \
  526. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5); \
  527. SYNC_DEBUG \
  528. } else { \
  529. server_name->m_type(p1, p2, p3, p4, p5); \
  530. } \
  531. }
  532. #define FUNC5(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5) \
  533. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
  534. if (Thread::get_caller_id() != server_thread) { \
  535. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5); \
  536. } else { \
  537. server_name->m_type(p1, p2, p3, p4, p5); \
  538. } \
  539. }
  540. #define FUNC5C(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5) \
  541. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
  542. if (Thread::get_caller_id() != server_thread) { \
  543. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5); \
  544. } else { \
  545. server_name->m_type(p1, p2, p3, p4, p5); \
  546. } \
  547. }
  548. #define FUNC6R(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6) \
  549. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
  550. if (Thread::get_caller_id() != server_thread) { \
  551. m_r ret; \
  552. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, &ret); \
  553. SYNC_DEBUG \
  554. return ret; \
  555. } else { \
  556. return server_name->m_type(p1, p2, p3, p4, p5, p6); \
  557. } \
  558. }
  559. #define FUNC6RC(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6) \
  560. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
  561. if (Thread::get_caller_id() != server_thread) { \
  562. m_r ret; \
  563. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, &ret); \
  564. SYNC_DEBUG \
  565. return ret; \
  566. } else { \
  567. return server_name->m_type(p1, p2, p3, p4, p5, p6); \
  568. } \
  569. }
  570. #define FUNC6S(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6) \
  571. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
  572. if (Thread::get_caller_id() != server_thread) { \
  573. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6); \
  574. SYNC_DEBUG \
  575. } else { \
  576. server_name->m_type(p1, p2, p3, p4, p5, p6); \
  577. } \
  578. }
  579. #define FUNC6SC(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6) \
  580. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
  581. if (Thread::get_caller_id() != server_thread) { \
  582. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6); \
  583. SYNC_DEBUG \
  584. } else { \
  585. server_name->m_type(p1, p2, p3, p4, p5, p6); \
  586. } \
  587. }
  588. #define FUNC6(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6) \
  589. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
  590. if (Thread::get_caller_id() != server_thread) { \
  591. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6); \
  592. } else { \
  593. server_name->m_type(p1, p2, p3, p4, p5, p6); \
  594. } \
  595. }
  596. #define FUNC6C(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6) \
  597. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
  598. if (Thread::get_caller_id() != server_thread) { \
  599. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6); \
  600. } else { \
  601. server_name->m_type(p1, p2, p3, p4, p5, p6); \
  602. } \
  603. }
  604. #define FUNC7R(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7) \
  605. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) { \
  606. if (Thread::get_caller_id() != server_thread) { \
  607. m_r ret; \
  608. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, &ret); \
  609. SYNC_DEBUG \
  610. return ret; \
  611. } else { \
  612. return server_name->m_type(p1, p2, p3, p4, p5, p6, p7); \
  613. } \
  614. }
  615. #define FUNC7RC(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7) \
  616. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) const { \
  617. if (Thread::get_caller_id() != server_thread) { \
  618. m_r ret; \
  619. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, &ret); \
  620. SYNC_DEBUG \
  621. return ret; \
  622. } else { \
  623. return server_name->m_type(p1, p2, p3, p4, p5, p6, p7); \
  624. } \
  625. }
  626. #define FUNC7S(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7) \
  627. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) { \
  628. if (Thread::get_caller_id() != server_thread) { \
  629. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7); \
  630. SYNC_DEBUG \
  631. } else { \
  632. server_name->m_type(p1, p2, p3, p4, p5, p6, p7); \
  633. } \
  634. }
  635. #define FUNC7SC(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7) \
  636. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) const { \
  637. if (Thread::get_caller_id() != server_thread) { \
  638. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7); \
  639. SYNC_DEBUG \
  640. } else { \
  641. server_name->m_type(p1, p2, p3, p4, p5, p6, p7); \
  642. } \
  643. }
  644. #define FUNC7(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7) \
  645. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) { \
  646. if (Thread::get_caller_id() != server_thread) { \
  647. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7); \
  648. } else { \
  649. server_name->m_type(p1, p2, p3, p4, p5, p6, p7); \
  650. } \
  651. }
  652. #define FUNC7C(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7) \
  653. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) const { \
  654. if (Thread::get_caller_id() != server_thread) { \
  655. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7); \
  656. } else { \
  657. server_name->m_type(p1, p2, p3, p4, p5, p6, p7); \
  658. } \
  659. }
  660. #define FUNC8R(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8) \
  661. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7, m_arg8 p8) { \
  662. if (Thread::get_caller_id() != server_thread) { \
  663. m_r ret; \
  664. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8, &ret); \
  665. SYNC_DEBUG \
  666. return ret; \
  667. } else { \
  668. return server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8); \
  669. } \
  670. }
  671. #define FUNC8RC(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8) \
  672. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7, m_arg8 p8) const { \
  673. if (Thread::get_caller_id() != server_thread) { \
  674. m_r ret; \
  675. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8, &ret); \
  676. SYNC_DEBUG \
  677. return ret; \
  678. } else { \
  679. return server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8); \
  680. } \
  681. }
  682. #define FUNC8S(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8) \
  683. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7, m_arg8 p8) { \
  684. if (Thread::get_caller_id() != server_thread) { \
  685. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8); \
  686. SYNC_DEBUG \
  687. } else { \
  688. server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8); \
  689. } \
  690. }
  691. #define FUNC8SC(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8) \
  692. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7, m_arg8 p8) const { \
  693. if (Thread::get_caller_id() != server_thread) { \
  694. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8); \
  695. SYNC_DEBUG \
  696. } else { \
  697. server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8); \
  698. } \
  699. }
  700. #define FUNC8(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8) \
  701. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7, m_arg8 p8) { \
  702. if (Thread::get_caller_id() != server_thread) { \
  703. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8); \
  704. } else { \
  705. server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8); \
  706. } \
  707. }
  708. #define FUNC8C(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8) \
  709. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7, m_arg8 p8) const { \
  710. if (Thread::get_caller_id() != server_thread) { \
  711. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8); \
  712. } else { \
  713. server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8); \
  714. } \
  715. }
  716. #define FUNC9(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8, m_arg9) \
  717. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7, m_arg8 p8, m_arg9 p9) { \
  718. if (Thread::get_caller_id() != server_thread) { \
  719. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8, p9); \
  720. } else { \
  721. server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8, p9); \
  722. } \
  723. }
  724. #define FUNC10(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8, m_arg9, m_arg10) \
  725. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7, m_arg8 p8, m_arg9 p9, m_arg10 p10) { \
  726. if (Thread::get_caller_id() != server_thread) { \
  727. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \
  728. } else { \
  729. server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \
  730. } \
  731. }
  732. #define FUNC11(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8, m_arg9, m_arg10, m_arg11) \
  733. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7, m_arg8 p8, m_arg9 p9, m_arg10 p10, m_arg11 p11) { \
  734. if (Thread::get_caller_id() != server_thread) { \
  735. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \
  736. } else { \
  737. server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \
  738. } \
  739. }
  740. #define FUNC12(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8, m_arg9, m_arg10, m_arg11, m_arg12) \
  741. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7, m_arg8 p8, m_arg9 p9, m_arg10 p10, m_arg11 p11, m_arg12 p12) { \
  742. if (Thread::get_caller_id() != server_thread) { \
  743. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \
  744. } else { \
  745. server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \
  746. } \
  747. }