server_wrap_mt_common.h 64 KB

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