Function getCurrentThreadIndex


#include <lib/inc/drogon/HttpAppFramework.h>

virtual size_t getCurrentThreadIndex() const =0


Get the Current Thread Index whose range is [0, the total number of IO threads].

size_t If the current thread is the main EventLoop thread (in which the app().run() is called), the number of the IO threads is returned. If the current thread is a network IO thread, the index of it in the range [0, the number of IO threads) is returned. otherwise the maximum value of type size_t is returned.
Basically this method is used for storing thread-related various in an array and users can use indexes returned by this method to access them. This is much faster than using a map. If the array is properly initialized at the beginning, users can access it without locks.


Line 1161 in lib/inc/drogon/HttpAppFramework.h.

Add Discussion as Guest

Log in