1d4afb5ceSopenharmony_ci# lws minimal ws server (threads) + SMP 2d4afb5ceSopenharmony_ci 3d4afb5ceSopenharmony_ciThis demonstrates both independent threads creating content as in the 4d4afb5ceSopenharmony_ci-threads example, multiple service threads as in the http-server-smp 5d4afb5ceSopenharmony_ciexample (but with ws), and using the foreign libuv loop. 6d4afb5ceSopenharmony_ci 7d4afb5ceSopenharmony_ci## build 8d4afb5ceSopenharmony_ci 9d4afb5ceSopenharmony_ciYou must first build libwebsockets itself with cmake `-DLWS_MAX_SMP=8` 10d4afb5ceSopenharmony_cior some other number greater than one, as well as `-DLWS_WITH_LIBUV=1` 11d4afb5ceSopenharmony_ci 12d4afb5ceSopenharmony_ci``` 13d4afb5ceSopenharmony_ci $ cmake . && make 14d4afb5ceSopenharmony_ci``` 15d4afb5ceSopenharmony_ci 16d4afb5ceSopenharmony_ciPthreads is required on your system. 17d4afb5ceSopenharmony_ci 18d4afb5ceSopenharmony_ci## usage 19d4afb5ceSopenharmony_ci 20d4afb5ceSopenharmony_ci``` 21d4afb5ceSopenharmony_ci $ ./lws-minimal-ws-server-threads-smp 22d4afb5ceSopenharmony_ci[2019/01/28 06:59:17:4217] USER: LWS minimal ws server + threads + smp | visit http://localhost:7681 23d4afb5ceSopenharmony_ci[2019/01/28 06:59:17:4219] NOTICE: Service threads: 2 24d4afb5ceSopenharmony_ci[2019/01/28 06:59:17:4220] NOTICE: LWS_CALLBACK_EVENT_WAIT_CANCELLED in svc tid 0x7fec48af8700 25d4afb5ceSopenharmony_ci[2019/01/28 06:59:17:4220] NOTICE: LWS_CALLBACK_EVENT_WAIT_CANCELLED in svc tid 0x7fec48af8700 26d4afb5ceSopenharmony_ci... 27d4afb5ceSopenharmony_ci``` 28d4afb5ceSopenharmony_ci 29d4afb5ceSopenharmony_ciVisit http://localhost:7681 on multiple browser windows. You may need to open 30d4afb5ceSopenharmony_ci4 before the second service thread is used (check "svc tid" in the browser output). 31d4afb5ceSopenharmony_ci 32d4afb5ceSopenharmony_ciTwo lws service threads are started. 33d4afb5ceSopenharmony_ci 34d4afb5ceSopenharmony_ciTwo separate asynchronous threads generate strings and add them to a ringbuffer, 35d4afb5ceSopenharmony_cisignalling all lws service threads to send new entries to all the browser windows. 36d4afb5ceSopenharmony_ci 37d4afb5ceSopenharmony_ciThis demonstrates how to safely manage asynchronously generated content 38d4afb5ceSopenharmony_ciand hook it up to the lws service threads. 39d4afb5ceSopenharmony_ci 40