This file contains hidden or 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
#include <stdio.h> | |
#include <sys/mman.h> | |
#include <string.h> | |
#include <stdint.h> | |
double mul(double x, double y) { | |
return x * y; | |
} | |
const int page_size = 1024 * 4; | |
char buf[page_size] __attribute__((aligned(page_size))) // (1) |
This file contains hidden or 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
SUBDIRS := subdir0 subdir1 | |
TARGET := $(addprefix test_,$(SUBDIRS)) | |
.PHONY: test | |
.PHONY: $(TARGET) | |
test: | |
$(MAKE) -k $(TARGET) | |
$(TARGET): | |
$(MAKE) -C $(subst test_,,$@) test |
This file contains hidden or 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
.PHONY: test | |
test: | |
$(MAKE) -C subdir0 test | |
$(MAKE) -C subdir1 test |
This file contains hidden or 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
.PHONY: test | |
test: | |
for d in $(SUBDIRS); do \ | |
$(MAKE) -C $$d test; \ | |
done |
This file contains hidden or 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
#include <string> | |
#include <iostream> | |
#include <thread> | |
#include <chrono> | |
#include <mutex> | |
class Helper | |
{ | |
public: | |
void handle(std::string filepath, |
This file contains hidden or 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
#include <mutex> | |
std::mutex mutex; | |
int main() | |
{ | |
while (!mutex.try_lock()) { | |
// ロックを取得できなかった際の処理(イベントループを回すなど) | |
} | |
// ロックが必要な処理. |
This file contains hidden or 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
#include <regex> | |
#include <vector> | |
#include <algorithm> | |
#include <iostream> | |
int main() | |
{ | |
std::string str("ABC,DEF,GHI,JKL"); | |
std::regex pattern(","); | |
std::sregex_token_iterator begin(str.begin(), str.end(), pattern, -1); |
This file contains hidden or 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
#include <regex> | |
#include <algorithm> | |
#include <iostream> | |
int main() | |
{ | |
std::string str("version 1.20.300.400"); | |
std::regex pattern("([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)"); | |
{ | |
std::sregex_token_iterator begin(str.begin(), str.end(), pattern, {1,3}); |
This file contains hidden or 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
#include <chrono> | |
#include <iostream> | |
int main() | |
{ | |
ThreadPool tp(5, 1000); | |
for (int n = 0; n < 1000; n++) { | |
auto workA = [ ] { std::cout << "WorkA" << std::endl; }; | |
auto workB = [=] { std::cout << "WorkB n=" << n << std::endl; }; |
This file contains hidden or 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
#include <deque> | |
#include <vector> | |
#include <functional> | |
#include <thread> | |
#include <mutex> | |
#include <condition_variable> | |
#include <cassert> | |
template <typename T> class Queue | |
{ |
NewerOlder