Skip to content

Instantly share code, notes, and snippets.

View xylcbd's full-sized avatar
🎯
Focusing

xylcbd xylcbd

🎯
Focusing
View GitHub Profile
1,SIMD指令优化的是计算,对于内存复制之类的问题,限制在内存,使用SIMD指令优化很少;
2,SIMD指令也需要耗费时间,不要把若干移位和一两次乘法变成SIMD乘法,性能急剧下降;
@xylcbd
xylcbd / scope_exit_lambda.cpp
Last active November 27, 2015 12:23
scope exit lambda
namespace cxxdetail
{
template <typename FuncType>
class InnerScopeExit
{
public:
InnerScopeExit(const FuncType _func) :func(_func){}
~InnerScopeExit(){ if (!dismissed){ func(); } }
private:
FuncType func;
@xylcbd
xylcbd / timeout_handler.cpp
Created August 31, 2015 01:51
c++11 timeout handler
template<typename CALLBACKTYPE,typename... ARGS>
class TimeoutHandler
{
public:
TimeoutHandler(const int _timeout/*ms*/,CALLBACKTYPE _callback, ARGS... _args)
{
std::thread([](TimeoutHandler* this_object,int _timeout, CALLBACKTYPE _callback, ARGS... _args)
{
std::this_thread::sleep_for(std::chrono::milliseconds(_timeout));
if (!this_object->exit_flag)
#pragma once
#include <functional>
class CScopedRelease
{
public:
explicit CScopedRelease(std::function<void ()> pfnRelease)
: m_pfnRelease(pfnRelease)
{
@xylcbd
xylcbd / KMP
Last active August 29, 2015 14:00
#include <iostream>
#include <cstring>
#include <cassert>
#include <memory>
#include <ctime>
using namespace std;
bool g_bUseNormal = false;
int* next_array = nullptr;