server_wrap_mt_common.h 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823
  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-2020 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2020 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. server_name->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. List<RID> m_type##_id_pool; \
  194. int m_type##allocn(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
  195. for (int i = 0; i < pool_max_size; i++) { \
  196. m_type##_id_pool.push_back(server_name->m_type##_create(p1, p2, p3, p4, p5)); \
  197. } \
  198. return 0; \
  199. } \
  200. void m_type##_free_cached_ids() { \
  201. while (m_type##_id_pool.size()) { \
  202. free(m_type##_id_pool.front()->get()); \
  203. m_type##_id_pool.pop_front(); \
  204. } \
  205. } \
  206. virtual RID m_type##_create(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
  207. if (Thread::get_caller_id() != server_thread) { \
  208. RID rid; \
  209. alloc_mutex->lock(); \
  210. if (m_type##_id_pool.size() == 0) { \
  211. int ret; \
  212. command_queue.push_and_ret(this, &ServerNameWrapMT::m_type##allocn, p1, p2, p3, p4, p5, &ret); \
  213. SYNC_DEBUG \
  214. } \
  215. rid = m_type##_id_pool.front()->get(); \
  216. m_type##_id_pool.pop_front(); \
  217. alloc_mutex->unlock(); \
  218. return rid; \
  219. } else { \
  220. return server_name->m_type##_create(p1, p2, p3, p4, p5); \
  221. } \
  222. }
  223. #define FUNC0RC(m_r, m_type) \
  224. virtual m_r m_type() const { \
  225. if (Thread::get_caller_id() != server_thread) { \
  226. m_r ret; \
  227. command_queue.push_and_ret(server_name, &ServerName::m_type, &ret); \
  228. SYNC_DEBUG \
  229. return ret; \
  230. } else { \
  231. return server_name->m_type(); \
  232. } \
  233. }
  234. #define FUNC0(m_type) \
  235. virtual void m_type() { \
  236. if (Thread::get_caller_id() != server_thread) { \
  237. command_queue.push(server_name, &ServerName::m_type); \
  238. } else { \
  239. server_name->m_type(); \
  240. } \
  241. }
  242. #define FUNC0C(m_type) \
  243. virtual void m_type() const { \
  244. if (Thread::get_caller_id() != server_thread) { \
  245. command_queue.push(server_name, &ServerName::m_type); \
  246. } else { \
  247. server_name->m_type(); \
  248. } \
  249. }
  250. #define FUNC0S(m_type) \
  251. virtual void m_type() { \
  252. if (Thread::get_caller_id() != server_thread) { \
  253. command_queue.push_and_sync(server_name, &ServerName::m_type); \
  254. SYNC_DEBUG \
  255. } else { \
  256. server_name->m_type(); \
  257. } \
  258. }
  259. #define FUNC0SC(m_type) \
  260. virtual void m_type() const { \
  261. if (Thread::get_caller_id() != server_thread) { \
  262. command_queue.push_and_sync(server_name, &ServerName::m_type); \
  263. SYNC_DEBUG \
  264. } else { \
  265. server_name->m_type(); \
  266. } \
  267. }
  268. ///////////////////////////////////////////////
  269. #define FUNC1R(m_r, m_type, m_arg1) \
  270. virtual m_r m_type(m_arg1 p1) { \
  271. if (Thread::get_caller_id() != server_thread) { \
  272. m_r ret; \
  273. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, &ret); \
  274. SYNC_DEBUG \
  275. return ret; \
  276. } else { \
  277. return server_name->m_type(p1); \
  278. } \
  279. }
  280. #define FUNC1RC(m_r, m_type, m_arg1) \
  281. virtual m_r m_type(m_arg1 p1) const { \
  282. if (Thread::get_caller_id() != server_thread) { \
  283. m_r ret; \
  284. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, &ret); \
  285. SYNC_DEBUG \
  286. return ret; \
  287. } else { \
  288. return server_name->m_type(p1); \
  289. } \
  290. }
  291. #define FUNC1S(m_type, m_arg1) \
  292. virtual void m_type(m_arg1 p1) { \
  293. if (Thread::get_caller_id() != server_thread) { \
  294. command_queue.push_and_sync(server_name, &ServerName::m_type, p1); \
  295. SYNC_DEBUG \
  296. } else { \
  297. server_name->m_type(p1); \
  298. } \
  299. }
  300. #define FUNC1SC(m_type, m_arg1) \
  301. virtual void m_type(m_arg1 p1) const { \
  302. if (Thread::get_caller_id() != server_thread) { \
  303. command_queue.push_and_sync(server_name, &ServerName::m_type, p1); \
  304. SYNC_DEBUG \
  305. } else { \
  306. server_name->m_type(p1); \
  307. } \
  308. }
  309. #define FUNC1(m_type, m_arg1) \
  310. virtual void m_type(m_arg1 p1) { \
  311. if (Thread::get_caller_id() != server_thread) { \
  312. command_queue.push(server_name, &ServerName::m_type, p1); \
  313. } else { \
  314. server_name->m_type(p1); \
  315. } \
  316. }
  317. #define FUNC1C(m_type, m_arg1) \
  318. virtual void m_type(m_arg1 p1) const { \
  319. if (Thread::get_caller_id() != server_thread) { \
  320. command_queue.push(server_name, &ServerName::m_type, p1); \
  321. } else { \
  322. server_name->m_type(p1); \
  323. } \
  324. }
  325. #define FUNC2R(m_r, m_type, m_arg1, m_arg2) \
  326. virtual m_r m_type(m_arg1 p1, m_arg2 p2) { \
  327. if (Thread::get_caller_id() != server_thread) { \
  328. m_r ret; \
  329. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, &ret); \
  330. SYNC_DEBUG \
  331. return ret; \
  332. } else { \
  333. return server_name->m_type(p1, p2); \
  334. } \
  335. }
  336. #define FUNC2RC(m_r, m_type, m_arg1, m_arg2) \
  337. virtual m_r m_type(m_arg1 p1, m_arg2 p2) const { \
  338. if (Thread::get_caller_id() != server_thread) { \
  339. m_r ret; \
  340. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, &ret); \
  341. SYNC_DEBUG \
  342. return ret; \
  343. } else { \
  344. return server_name->m_type(p1, p2); \
  345. } \
  346. }
  347. #define FUNC2S(m_type, m_arg1, m_arg2) \
  348. virtual void m_type(m_arg1 p1, m_arg2 p2) { \
  349. if (Thread::get_caller_id() != server_thread) { \
  350. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2); \
  351. SYNC_DEBUG \
  352. } else { \
  353. server_name->m_type(p1, p2); \
  354. } \
  355. }
  356. #define FUNC2SC(m_type, m_arg1, m_arg2) \
  357. virtual void m_type(m_arg1 p1, m_arg2 p2) const { \
  358. if (Thread::get_caller_id() != server_thread) { \
  359. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2); \
  360. SYNC_DEBUG \
  361. } else { \
  362. server_name->m_type(p1, p2); \
  363. } \
  364. }
  365. #define FUNC2(m_type, m_arg1, m_arg2) \
  366. virtual void m_type(m_arg1 p1, m_arg2 p2) { \
  367. if (Thread::get_caller_id() != server_thread) { \
  368. command_queue.push(server_name, &ServerName::m_type, p1, p2); \
  369. } else { \
  370. server_name->m_type(p1, p2); \
  371. } \
  372. }
  373. #define FUNC2C(m_type, m_arg1, m_arg2) \
  374. virtual void m_type(m_arg1 p1, m_arg2 p2) const { \
  375. if (Thread::get_caller_id() != server_thread) { \
  376. command_queue.push(server_name, &ServerName::m_type, p1, p2); \
  377. } else { \
  378. server_name->m_type(p1, p2); \
  379. } \
  380. }
  381. #define FUNC3R(m_r, m_type, m_arg1, m_arg2, m_arg3) \
  382. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
  383. if (Thread::get_caller_id() != server_thread) { \
  384. m_r ret; \
  385. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, &ret); \
  386. SYNC_DEBUG \
  387. return ret; \
  388. } else { \
  389. return server_name->m_type(p1, p2, p3); \
  390. } \
  391. }
  392. #define FUNC3RC(m_r, m_type, m_arg1, m_arg2, m_arg3) \
  393. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
  394. if (Thread::get_caller_id() != server_thread) { \
  395. m_r ret; \
  396. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, &ret); \
  397. SYNC_DEBUG \
  398. return ret; \
  399. } else { \
  400. return server_name->m_type(p1, p2, p3); \
  401. } \
  402. }
  403. #define FUNC3S(m_type, m_arg1, m_arg2, m_arg3) \
  404. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
  405. if (Thread::get_caller_id() != server_thread) { \
  406. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3); \
  407. SYNC_DEBUG \
  408. } else { \
  409. server_name->m_type(p1, p2, p3); \
  410. } \
  411. }
  412. #define FUNC3SC(m_type, m_arg1, m_arg2, m_arg3) \
  413. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
  414. if (Thread::get_caller_id() != server_thread) { \
  415. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3); \
  416. SYNC_DEBUG \
  417. } else { \
  418. server_name->m_type(p1, p2, p3); \
  419. } \
  420. }
  421. #define FUNC3(m_type, m_arg1, m_arg2, m_arg3) \
  422. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
  423. if (Thread::get_caller_id() != server_thread) { \
  424. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3); \
  425. } else { \
  426. server_name->m_type(p1, p2, p3); \
  427. } \
  428. }
  429. #define FUNC3C(m_type, m_arg1, m_arg2, m_arg3) \
  430. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
  431. if (Thread::get_caller_id() != server_thread) { \
  432. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3); \
  433. } else { \
  434. server_name->m_type(p1, p2, p3); \
  435. } \
  436. }
  437. #define FUNC4R(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4) \
  438. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
  439. if (Thread::get_caller_id() != server_thread) { \
  440. m_r ret; \
  441. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, &ret); \
  442. SYNC_DEBUG \
  443. return ret; \
  444. } else { \
  445. return server_name->m_type(p1, p2, p3, p4); \
  446. } \
  447. }
  448. #define FUNC4RC(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4) \
  449. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
  450. if (Thread::get_caller_id() != server_thread) { \
  451. m_r ret; \
  452. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, &ret); \
  453. SYNC_DEBUG \
  454. return ret; \
  455. } else { \
  456. return server_name->m_type(p1, p2, p3, p4); \
  457. } \
  458. }
  459. #define FUNC4S(m_type, m_arg1, m_arg2, m_arg3, m_arg4) \
  460. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
  461. if (Thread::get_caller_id() != server_thread) { \
  462. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4); \
  463. SYNC_DEBUG \
  464. } else { \
  465. server_name->m_type(p1, p2, p3, p4); \
  466. } \
  467. }
  468. #define FUNC4SC(m_type, m_arg1, m_arg2, m_arg3, m_arg4) \
  469. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
  470. if (Thread::get_caller_id() != server_thread) { \
  471. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4); \
  472. SYNC_DEBUG \
  473. } else { \
  474. server_name->m_type(p1, p2, p3, p4); \
  475. } \
  476. }
  477. #define FUNC4(m_type, m_arg1, m_arg2, m_arg3, m_arg4) \
  478. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
  479. if (Thread::get_caller_id() != server_thread) { \
  480. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4); \
  481. } else { \
  482. server_name->m_type(p1, p2, p3, p4); \
  483. } \
  484. }
  485. #define FUNC4C(m_type, m_arg1, m_arg2, m_arg3, m_arg4) \
  486. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
  487. if (Thread::get_caller_id() != server_thread) { \
  488. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4); \
  489. } else { \
  490. server_name->m_type(p1, p2, p3, p4); \
  491. } \
  492. }
  493. #define FUNC5R(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5) \
  494. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
  495. if (Thread::get_caller_id() != server_thread) { \
  496. m_r ret; \
  497. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, &ret); \
  498. SYNC_DEBUG \
  499. return ret; \
  500. } else { \
  501. return server_name->m_type(p1, p2, p3, p4, p5); \
  502. } \
  503. }
  504. #define FUNC5RC(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5) \
  505. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
  506. if (Thread::get_caller_id() != server_thread) { \
  507. m_r ret; \
  508. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, &ret); \
  509. SYNC_DEBUG \
  510. return ret; \
  511. } else { \
  512. return server_name->m_type(p1, p2, p3, p4, p5); \
  513. } \
  514. }
  515. #define FUNC5S(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5) \
  516. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
  517. if (Thread::get_caller_id() != server_thread) { \
  518. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5); \
  519. SYNC_DEBUG \
  520. } else { \
  521. server_name->m_type(p1, p2, p3, p4, p5); \
  522. } \
  523. }
  524. #define FUNC5SC(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5) \
  525. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
  526. if (Thread::get_caller_id() != server_thread) { \
  527. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5); \
  528. SYNC_DEBUG \
  529. } else { \
  530. server_name->m_type(p1, p2, p3, p4, p5); \
  531. } \
  532. }
  533. #define FUNC5(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5) \
  534. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
  535. if (Thread::get_caller_id() != server_thread) { \
  536. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5); \
  537. } else { \
  538. server_name->m_type(p1, p2, p3, p4, p5); \
  539. } \
  540. }
  541. #define FUNC5C(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5) \
  542. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
  543. if (Thread::get_caller_id() != server_thread) { \
  544. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5); \
  545. } else { \
  546. server_name->m_type(p1, p2, p3, p4, p5); \
  547. } \
  548. }
  549. #define FUNC6R(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6) \
  550. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
  551. if (Thread::get_caller_id() != server_thread) { \
  552. m_r ret; \
  553. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, &ret); \
  554. SYNC_DEBUG \
  555. return ret; \
  556. } else { \
  557. return server_name->m_type(p1, p2, p3, p4, p5, p6); \
  558. } \
  559. }
  560. #define FUNC6RC(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6) \
  561. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
  562. if (Thread::get_caller_id() != server_thread) { \
  563. m_r ret; \
  564. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, &ret); \
  565. SYNC_DEBUG \
  566. return ret; \
  567. } else { \
  568. return server_name->m_type(p1, p2, p3, p4, p5, p6); \
  569. } \
  570. }
  571. #define FUNC6S(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6) \
  572. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
  573. if (Thread::get_caller_id() != server_thread) { \
  574. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6); \
  575. SYNC_DEBUG \
  576. } else { \
  577. server_name->m_type(p1, p2, p3, p4, p5, p6); \
  578. } \
  579. }
  580. #define FUNC6SC(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6) \
  581. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
  582. if (Thread::get_caller_id() != server_thread) { \
  583. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6); \
  584. SYNC_DEBUG \
  585. } else { \
  586. server_name->m_type(p1, p2, p3, p4, p5, p6); \
  587. } \
  588. }
  589. #define FUNC6(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6) \
  590. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
  591. if (Thread::get_caller_id() != server_thread) { \
  592. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6); \
  593. } else { \
  594. server_name->m_type(p1, p2, p3, p4, p5, p6); \
  595. } \
  596. }
  597. #define FUNC6C(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6) \
  598. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
  599. if (Thread::get_caller_id() != server_thread) { \
  600. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6); \
  601. } else { \
  602. server_name->m_type(p1, p2, p3, p4, p5, p6); \
  603. } \
  604. }
  605. #define FUNC7R(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7) \
  606. 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) { \
  607. if (Thread::get_caller_id() != server_thread) { \
  608. m_r ret; \
  609. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, &ret); \
  610. SYNC_DEBUG \
  611. return ret; \
  612. } else { \
  613. return server_name->m_type(p1, p2, p3, p4, p5, p6, p7); \
  614. } \
  615. }
  616. #define FUNC7RC(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7) \
  617. 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 { \
  618. if (Thread::get_caller_id() != server_thread) { \
  619. m_r ret; \
  620. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, &ret); \
  621. SYNC_DEBUG \
  622. return ret; \
  623. } else { \
  624. return server_name->m_type(p1, p2, p3, p4, p5, p6, p7); \
  625. } \
  626. }
  627. #define FUNC7S(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7) \
  628. 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) { \
  629. if (Thread::get_caller_id() != server_thread) { \
  630. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7); \
  631. SYNC_DEBUG \
  632. } else { \
  633. server_name->m_type(p1, p2, p3, p4, p5, p6, p7); \
  634. } \
  635. }
  636. #define FUNC7SC(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7) \
  637. 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 { \
  638. if (Thread::get_caller_id() != server_thread) { \
  639. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7); \
  640. SYNC_DEBUG \
  641. } else { \
  642. server_name->m_type(p1, p2, p3, p4, p5, p6, p7); \
  643. } \
  644. }
  645. #define FUNC7(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7) \
  646. 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) { \
  647. if (Thread::get_caller_id() != server_thread) { \
  648. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7); \
  649. } else { \
  650. server_name->m_type(p1, p2, p3, p4, p5, p6, p7); \
  651. } \
  652. }
  653. #define FUNC7C(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7) \
  654. 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 { \
  655. if (Thread::get_caller_id() != server_thread) { \
  656. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7); \
  657. } else { \
  658. server_name->m_type(p1, p2, p3, p4, p5, p6, p7); \
  659. } \
  660. }
  661. #define FUNC8R(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8) \
  662. 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) { \
  663. if (Thread::get_caller_id() != server_thread) { \
  664. m_r ret; \
  665. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8, &ret); \
  666. SYNC_DEBUG \
  667. return ret; \
  668. } else { \
  669. return server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8); \
  670. } \
  671. }
  672. #define FUNC8RC(m_r, m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8) \
  673. 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 { \
  674. if (Thread::get_caller_id() != server_thread) { \
  675. m_r ret; \
  676. command_queue.push_and_ret(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8, &ret); \
  677. SYNC_DEBUG \
  678. return ret; \
  679. } else { \
  680. return server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8); \
  681. } \
  682. }
  683. #define FUNC8S(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8) \
  684. 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) { \
  685. if (Thread::get_caller_id() != server_thread) { \
  686. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8); \
  687. SYNC_DEBUG \
  688. } else { \
  689. server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8); \
  690. } \
  691. }
  692. #define FUNC8SC(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8) \
  693. 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 { \
  694. if (Thread::get_caller_id() != server_thread) { \
  695. command_queue.push_and_sync(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8); \
  696. SYNC_DEBUG \
  697. } else { \
  698. server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8); \
  699. } \
  700. }
  701. #define FUNC8(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8) \
  702. 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) { \
  703. if (Thread::get_caller_id() != server_thread) { \
  704. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8); \
  705. } else { \
  706. server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8); \
  707. } \
  708. }
  709. #define FUNC8C(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8) \
  710. 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 { \
  711. if (Thread::get_caller_id() != server_thread) { \
  712. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8); \
  713. } else { \
  714. server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8); \
  715. } \
  716. }
  717. #define FUNC9(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8, m_arg9) \
  718. 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) { \
  719. if (Thread::get_caller_id() != server_thread) { \
  720. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8, p9); \
  721. } else { \
  722. server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8, p9); \
  723. } \
  724. }
  725. #define FUNC10(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8, m_arg9, m_arg10) \
  726. 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) { \
  727. if (Thread::get_caller_id() != server_thread) { \
  728. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \
  729. } else { \
  730. server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \
  731. } \
  732. }
  733. #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) \
  734. 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) { \
  735. if (Thread::get_caller_id() != server_thread) { \
  736. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \
  737. } else { \
  738. server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \
  739. } \
  740. }
  741. #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) \
  742. 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) { \
  743. if (Thread::get_caller_id() != server_thread) { \
  744. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \
  745. } else { \
  746. server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \
  747. } \
  748. }
  749. #define FUNC13(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, m_arg13) \
  750. 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, m_arg13 p13) { \
  751. if (Thread::get_caller_id() != server_thread) { \
  752. command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \
  753. } else { \
  754. server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \
  755. } \
  756. }