Skip to content

Instantly share code, notes, and snippets.

:octocat:
Focusing

kgbook kgbook

Block or report user

Report or block kgbook

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View parseIP.cpp
#include <string>
#include <sstream>
#include <iostream>
int getIP(std::string ip_str) {
if (ip_str.empty()) {
return 0;
}
std::stringstream ss(ip_str);
@kgbook
kgbook / interrupt_sleep.cpp
Last active Apr 19, 2019
#thread_sleep #interrupt_sleep
View interrupt_sleep.cpp
//
// Created by kang on 2019-04-19.
//
#include <chrono>
#include <iostream>
#include "interrupt_sleep.h"
using namespace std::chrono;
@kgbook
kgbook / boost_thread_interruption.cpp
Created Nov 30, 2018
[boost thread interruption example] boost thread interruption example #boost::thread::interrupt
View boost_thread_interruption.cpp
#include <iostream>
#include <boost/thread.hpp>
using std::cout;
using std::endl;
void sayHello() {
int32_t cnt = 0;
while (!boost::this_thread::interruption_requested()) {
@kgbook
kgbook / inheritance_example.cpp
Last active Nov 28, 2018
[inheritance example]inheritance #inheritance #C++
View inheritance_example.cpp
#include <iostream>
//using namespace std::cout;
class Subject
{
public:
Subject() {
std::cout <<__func__ <<"@LINE#" <<__LINE__ <<std::endl;
}
@kgbook
kgbook / boost_variant_example.cpp
Last active Nov 15, 2018
[boost variant example]boost::variant example #boost #variant
View boost_variant_example.cpp
#include <boost/variant.hpp>
#include <string>
#include <iostream>
using data_t = boost::variant<
bool,
int8_t,
uint8_t,
int16_t,
uint16_t,
@kgbook
kgbook / boost_thread_interrupt.cpp
Last active Nov 12, 2018
[boost thread interrupt]example of boost::thread interruption #interrupt #multithreading #boost
View boost_thread_interrupt.cpp
#include <iostream>
#include <boost/chrono/chrono.hpp>
#include <boost/thread/thread.hpp>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
static pid_t child_pid = 0;
void child_process_thread_func() {
@kgbook
kgbook / SharedSemaphore.h
Last active Nov 12, 2018
[interprocess semaphore example]interprocess semaphore example #interprocess #semaphore
View SharedSemaphore.h
#ifndef SHARED_SEMAPHORE_H
#define SHARED_SEMAPHORE_H
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cerrno>
#include <sys/types.h>
#include <semaphore.h>
#include <fcntl.h>
@kgbook
kgbook / atexit_example.cpp
Last active Nov 12, 2018
[atexit example]register a function to be called at normal process termination #atexit #interprocess
View atexit_example.cpp
#include <iostream>
#include <cstdlib>
#include <unistd.h>
#include <cstring>
#include <cerrno>
#include <sys/types.h>
#include <sys/wait.h>
void parent_process_callback() {
std::cout <<__func__ <<", pid: " <<getpid() <<std::endl;
You can’t perform that action at this time.