mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
New Resource::Manager for controlling access to server resources
This commit is contained in:
105
src/ripple/resource/impl/Manager.cpp
Normal file
105
src/ripple/resource/impl/Manager.cpp
Normal file
@@ -0,0 +1,105 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
namespace ripple {
|
||||
namespace Resource {
|
||||
|
||||
class ManagerImp
|
||||
: public Manager
|
||||
, public Thread
|
||||
{
|
||||
public:
|
||||
Journal m_journal;
|
||||
LogicType <SimpleMonotonicClock> m_logic;
|
||||
|
||||
ManagerImp (Journal journal)
|
||||
: Thread ("Resource::Manager")
|
||||
,
|
||||
m_journal (journal)
|
||||
, m_logic (journal)
|
||||
{
|
||||
startThread ();
|
||||
}
|
||||
|
||||
~ManagerImp ()
|
||||
{
|
||||
stopThread ();
|
||||
}
|
||||
|
||||
Consumer newInboundEndpoint (IPEndpoint const& address)
|
||||
{
|
||||
return m_logic.newInboundEndpoint (address);
|
||||
}
|
||||
|
||||
Consumer newOutboundEndpoint (IPEndpoint const& address)
|
||||
{
|
||||
return m_logic.newOutboundEndpoint (address);
|
||||
}
|
||||
|
||||
Consumer newAdminEndpoint (std::string const& name)
|
||||
{
|
||||
return m_logic.newAdminEndpoint (name);
|
||||
}
|
||||
|
||||
Gossip exportConsumers ()
|
||||
{
|
||||
return m_logic.exportConsumers();
|
||||
}
|
||||
|
||||
void importConsumers (std::string const& origin, Gossip const& gossip)
|
||||
{
|
||||
m_logic.importConsumers (origin, gossip);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
void onWrite (PropertyStream::Map& map)
|
||||
{
|
||||
m_logic.onWrite (map);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
void run ()
|
||||
{
|
||||
do
|
||||
{
|
||||
m_logic.periodicActivity();
|
||||
wait (1000);
|
||||
}
|
||||
while (! threadShouldExit ());
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
Manager::Manager ()
|
||||
: PropertyStream::Source ("resource")
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
Manager* Manager::New (Journal journal)
|
||||
{
|
||||
return new ManagerImp (journal);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user