Skip to content
Snippets Groups Projects
  • Andy Green's avatar
    d3a55055
    multithreaded service · d3a55055
    Andy Green authored
    
    This adds support for multithreaded service to lws without adding any
    threading or locking code in the library.
    
    At context creation time you can request split the service part of the
    context into n service domains, which are load-balanced so that the most
    idle one gets the next listen socket accept.
    
    There's a single listen socket on one port still.
    
    User code may then spawn n threads doing n service loops / poll()s
    simultaneously.  Locking is only required (I think) in the existing
    FD lock callbacks already handled by the pthreads server example,
    and that locking takes place in user code.  So the library remains
    completely agnostic about the threading / locking scheme.
    
    And by default, it's completely compatible with one service thread
    so no changes are required by people uninterested in multithreaded
    service.
    
    However for people interested in extremely lightweight mass http[s]/
    ws[s] service with minimum provisioning, the library can now do
    everything out of the box.
    
    To test it, just try
    
    $ libwebsockets-test-server-pthreads -j 8
    
    where -j controls the number of service threads
    
    Signed-off-by: default avatarAndy Green <andy.green@linaro.org>
    d3a55055
    History
    multithreaded service
    Andy Green authored
    
    This adds support for multithreaded service to lws without adding any
    threading or locking code in the library.
    
    At context creation time you can request split the service part of the
    context into n service domains, which are load-balanced so that the most
    idle one gets the next listen socket accept.
    
    There's a single listen socket on one port still.
    
    User code may then spawn n threads doing n service loops / poll()s
    simultaneously.  Locking is only required (I think) in the existing
    FD lock callbacks already handled by the pthreads server example,
    and that locking takes place in user code.  So the library remains
    completely agnostic about the threading / locking scheme.
    
    And by default, it's completely compatible with one service thread
    so no changes are required by people uninterested in multithreaded
    service.
    
    However for people interested in extremely lightweight mass http[s]/
    ws[s] service with minimum provisioning, the library can now do
    everything out of the box.
    
    To test it, just try
    
    $ libwebsockets-test-server-pthreads -j 8
    
    where -j controls the number of service threads
    
    Signed-off-by: default avatarAndy Green <andy.green@linaro.org>