<commit_before>// Copyright (C) 2015 SRG Technology, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#ifndef ANYRPC_SERVER_H_
#define ANYRPC_SERVER_H_

#if defined(ANYRPC_THREADING)
# if defined(__MINGW32__)
// These constants are not defined for mingw but are needed in the following libraries
#  ifndef EOWNERDEAD
#   define EOWNERDEAD       133    /* File too big */
#  endif
#  ifndef EPROTO
#   define EPROTO    134    /* Protocol error */
#  endif

#  include "internal/mingw.thread.h"
#  include <mutex>
#  include "internal/mingw.mutex.h"
#  include "internal/mingw.condition_variable.h"
# else
#  include <thread>
#  include <condition_variable>
#  include <mutex>
# endif //defined(__MINGW32__)
#endif //defined(ANYRPC_THREADING)

namespace anyrpc
{

//! Server for an RPC protocol
/*!
 *  The server can operate in four way.
 *  First, as part of the main thread by calling Work.
 *  Second, as an independent thread by calling StartThread.
 *  Third, as an independent thread with individual connection threads.
 *  Fourth, as an independent thread with multiple worker threads for execution.
 *
 *  The server's MethodManager must be populated with the available methods.
 *
 *  The BindAndListen call to set the port should be performed before
 *  calling the Work or StartThread functions.
 *
 *  There is a limit to the number of simultaneous connections.
 *  New connections will attempt to close an old connection with the assumption
 *  that the client will retry a failed attempt. This prevents stale
 *  connections from consuming resources. Set forcedDisconnectAllowed_ to false
 *  to disable this feature.
 */
class ANYRPC_API Server
{
public:
    Server();
    virtual ~Server() { Shutdown(); }

    //! Set the maximum number of simultaneous connections that the server can have
    void SetMaxConnections(unsigned maxConnections) { maxConnections_ = maxConnections; }
    //! Enable or Disable the closing of old connections on connection of new clients
    void SetForcedDisconnectAllowed(bool forcedDisconnectAllowed) { forcedDisconnectAllowed_ = forcedDisconnectAllowed; }<commit_msg>Add check IsForcedDisconnectAllowed<commit_after>// Copyright (C) 2015 SRG Technology, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#ifndef ANYRPC_SERVER_H_
#define ANYRPC_SERVER_H_

#if defined(ANYRPC_THREADING)
# if defined(__MINGW32__)
// These constants are not defined for mingw but are needed in the following libraries
#  ifndef EOWNERDEAD
#   define EOWNERDEAD       133    /* File too big */
#  endif
#  ifndef EPROTO
#   define EPROTO    134    /* Protocol error */
#  endif

#  include "internal/mingw.thread.h"
#  include <mutex>
#  include "internal/mingw.mutex.h"
#  include "internal/mingw.condition_variable.h"
# else
#  include <thread>
#  include <condition_variable>
#  include <mutex>
# endif //defined(__MINGW32__)
#endif //defined(ANYRPC_THREADING)

namespace anyrpc
{

//! Server for an RPC protocol
/*!
 *  The server can operate in four way.
 *  First, as part of the main thread by calling Work.
 *  Second, as an independent thread by calling StartThread.
 *  Third, as an independent thread with individual connection threads.
 *  Fourth, as an independent thread with multiple worker threads for execution.
 *
 *  The server's MethodManager must be populated with the available methods.
 *
 *  The BindAndListen call to set the port should be performed before
 *  calling the Work or StartThread functions.
 *
 *  There is a limit to the number of simultaneous connections.
 *  New connections will attempt to close an old connection with the assumption
 *  that the client will retry a failed attempt. This prevents stale
 *  connections from consuming resources. Set forcedDisconnectAllowed_ to false
 *  to disable this feature.
 */
class ANYRPC_API Server
{
public:
    Server();
    virtual ~Server() { Shutdown(); }

    //! Set the maximum number of simultaneous connections that the server can have
    void SetMaxConnections(unsigned maxConnections) { maxConnections_ = maxConnections; }
    //! Enable or Disable the closing of old connections on connection of new clients
    void SetForcedDisconnectAllowed(bool forcedDisconnectAllowed) { forcedDisconnectAllowed_ = forcedDisconnectAllowed; }
    //! Check if inactive clients will be disconnected to free slots for new ones
    bool IsForcedDisconnectAllowed() const { return forcedDisconnectAllowed_; }
{'fraction_non_alphanumeric': 0.06732550957381099, 'fraction_numerical': 0.004323656578134651, 'mean_word_length': 3.982307692307692, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1271492', 'n_tokens_mistral': 1709, 'n_tokens_neox': 1641, 'n_words': 808}