server_wrap_mt_common.h 63 KB

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