mirror of
https://gitee.com/an-tao/drogon.git
synced 2024-12-02 03:38:03 +08:00
Update trantor
This commit is contained in:
parent
f1f41201b9
commit
4897c29a67
@ -65,10 +65,6 @@ endif()
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -std=${CMAKE_CXX_STD_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -std=${CMAKE_CXX_STD_FLAGS}")
|
||||
|
||||
MESSAGE(STATUS ${CMAKE_CXX_FLAGS})
|
||||
|
||||
|
||||
|
||||
add_subdirectory(trantor)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/trantor ${PROJECT_SOURCE_DIR}/lib/inc)
|
||||
|
||||
|
@ -65,7 +65,7 @@ public:
|
||||
{
|
||||
bucketCount_=limit/interval+1;
|
||||
event_bucket_queue_.resize(bucketCount_);
|
||||
_loop->runEvery(interval, [=](){
|
||||
_timerId=_loop->runEvery(interval, [=](){
|
||||
CallbackBucket tmp;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(bucketMutex_);
|
||||
@ -76,6 +76,9 @@ public:
|
||||
}
|
||||
});
|
||||
};
|
||||
~CacheMap(){
|
||||
_loop->invalidateTimer(_timerId);
|
||||
}
|
||||
typedef struct MapValue
|
||||
{
|
||||
size_t timeout=0;
|
||||
@ -147,7 +150,8 @@ public:
|
||||
_map.erase(key);
|
||||
|
||||
}
|
||||
protected:
|
||||
|
||||
private:
|
||||
std::unordered_map< T1,MapValue > _map;
|
||||
CallbackBucketQueue event_bucket_queue_;
|
||||
|
||||
@ -156,6 +160,7 @@ protected:
|
||||
int bucketCount_;
|
||||
int timeInterval_;
|
||||
int _limit;
|
||||
trantor::TimerId _timerId;
|
||||
trantor::EventLoop* _loop;
|
||||
|
||||
void eraseAfter(int delay,const T1& key)
|
||||
|
@ -67,10 +67,14 @@ SharedLibManager::SharedLibManager(trantor::EventLoop *loop,const std::vector<st
|
||||
_loop(loop),
|
||||
_libPaths(libPaths)
|
||||
{
|
||||
_loop->runEvery(5.0,[=](){
|
||||
_timeId=_loop->runEvery(5.0,[=](){
|
||||
managerLibs();
|
||||
});
|
||||
}
|
||||
SharedLibManager::~SharedLibManager()
|
||||
{
|
||||
_loop->invalidateTimer(_timeId);
|
||||
}
|
||||
void SharedLibManager::managerLibs()
|
||||
{
|
||||
for(auto libPath:_libPaths)
|
||||
|
@ -22,7 +22,7 @@ namespace drogon{
|
||||
{
|
||||
public:
|
||||
SharedLibManager(trantor::EventLoop *loop,const std::vector<std::string> & libPaths);
|
||||
~SharedLibManager(){}
|
||||
~SharedLibManager();
|
||||
private:
|
||||
void managerLibs();
|
||||
trantor::EventLoop *_loop;
|
||||
@ -33,5 +33,6 @@ namespace drogon{
|
||||
};
|
||||
std::unordered_map<std::string,DLStat> _dlMap;
|
||||
void* loadLibs(const std::string &sourceFile,void *oldHld);
|
||||
trantor::TimerId _timeId;
|
||||
};
|
||||
}
|
2
trantor
2
trantor
@ -1 +1 @@
|
||||
Subproject commit cfcce97585a1eae16f0ae0d7e30f322bbf5d1fdd
|
||||
Subproject commit 29a0bf275c33e76fa8830166fceb9d045b65466b
|
Loading…
Reference in New Issue
Block a user