-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from toppers/mmap
fix #14
- Loading branch information
Showing
10 changed files
with
92 additions
and
32 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
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,10 @@ | ||
#ifndef _HAKO_SHARED_MEMORY_FACTORY_HPP_ | ||
#define _HAKO_SHARED_MEMORY_FACTORY_HPP_ | ||
|
||
#include "hako_shared_memory.hpp" | ||
|
||
namespace hako::utils { | ||
std::shared_ptr<hako::utils::HakoSharedMemory> hako_shared_memory_create(const std::string& type); | ||
} | ||
|
||
#endif /* _HAKO_SHARED_MEMORY_FACTORY_HPP_ */ |
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,31 @@ | ||
#ifndef _HAKO_SHARED_MEMORY_SHM_HPP_ | ||
#define _HAKO_SHARED_MEMORY_SHM_HPP_ | ||
|
||
#include "types/hako_types.hpp" | ||
#include "utils/hako_share/hako_shared_memory.hpp" | ||
#include <map> | ||
|
||
namespace hako::utils { | ||
|
||
class HakoSharedMemoryShm : public HakoSharedMemory { | ||
public: | ||
HakoSharedMemoryShm() {} | ||
virtual ~HakoSharedMemoryShm() {} | ||
|
||
virtual int32_t create_memory(int32_t key, int32_t size) override; | ||
virtual void* load_memory(int32_t key, int32_t size) override; | ||
|
||
virtual void* lock_memory(int32_t key) override; | ||
virtual void unlock_memory(int32_t key) override; | ||
virtual void destroy_memory(int32_t key) override; | ||
|
||
virtual int32_t get_semid(int32_t key) override; | ||
|
||
private: | ||
void* load_memory_shmid(int32_t key, int32_t shmid); | ||
std::map<int32_t, SharedMemoryInfoType> shared_memory_map_; | ||
}; | ||
} | ||
|
||
|
||
#endif /* _HAKO_SHARED_MEMORY_SHM_HPP_ */ |
13 changes: 13 additions & 0 deletions
13
src/hako/utils/hako_share/impl/hako_shared_memory_factory.cpp
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,13 @@ | ||
#include "utils/hako_share/hako_shared_memory_factory.hpp" | ||
#include "utils/hako_share/hako_shared_memory_shm.hpp" | ||
|
||
std::shared_ptr<hako::utils::HakoSharedMemory> hako::utils::hako_shared_memory_create(const std::string& type) | ||
{ | ||
if (type == "shm") { | ||
return std::make_shared<hako::utils::HakoSharedMemoryShm>(); | ||
} | ||
else | ||
{ | ||
return nullptr; | ||
} | ||
} |
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