-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allocate memory on update for some acl structs.
- Loading branch information
Timur Aitov
committed
Mar 6, 2024
1 parent
64a660b
commit 4f08a4c
Showing
27 changed files
with
1,058 additions
and
413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
#include <vector> | ||
|
||
#include "stream.h" | ||
|
||
namespace common::memory_manager | ||
{ | ||
|
||
inline uint64_t convert_string_to_bytes(std::string string) | ||
{ | ||
static std::map<char, uint64_t> multipliers = | ||
{{'k', 1024ull}, | ||
{'K', 1024ull}, | ||
{'m', 1024ull * 1024ull}, | ||
{'M', 1024ull * 1024ull}, | ||
{'g', 1024ull * 1024ull * 1024ull}, | ||
{'G', 1024ull * 1024ull * 1024ull}}; | ||
|
||
if (string.empty()) | ||
{ | ||
return 0; | ||
} | ||
|
||
uint64_t multiplier = 1; | ||
|
||
auto iter = multipliers.find(string.back()); | ||
if (iter != multipliers.end()) | ||
{ | ||
multiplier = iter->second; | ||
string.pop_back(); | ||
} | ||
|
||
return std::stoll(string) * multiplier; | ||
} | ||
|
||
class memory_group | ||
{ | ||
public: | ||
void pop(common::stream_in_t& stream) | ||
{ | ||
stream.pop(name); | ||
stream.pop(limit); | ||
stream.pop(memory_groups); | ||
} | ||
|
||
void push(common::stream_out_t& stream) const | ||
{ | ||
stream.push(name); | ||
stream.push(limit); | ||
stream.push(memory_groups); | ||
} | ||
|
||
public: | ||
std::string name; | ||
uint64_t limit; | ||
std::vector<std::shared_ptr<memory_group>> memory_groups; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include "memory_manager.h" | ||
|
||
using namespace controlplane::memory_manager; | ||
|
||
void memory_manager::reload(const base_t& base_prev, | ||
const base_t& base_next, | ||
common::idp::updateGlobalBase::request& globalbase) | ||
{ | ||
(void)base_prev; | ||
(void)globalbase; | ||
dataplane.memory_manager_update(base_next.root_memory_group); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include "base.h" | ||
#include "module.h" | ||
#include "type.h" | ||
|
||
#include "common/idataplane.h" | ||
|
||
namespace controlplane::memory_manager | ||
{ | ||
|
||
class memory_manager : public module_t | ||
{ | ||
public: | ||
void reload(const controlplane::base_t& base_prev, const controlplane::base_t& base_next, common::idp::updateGlobalBase::request& globalbase) override; | ||
|
||
protected: | ||
interface::dataPlane dataplane; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.