Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Fine.

Hiroki KUMAZAKI kumagi

:octocat:
Fine.
View GitHub Profile
@kumagi
kumagi / threadpool.hpp
Created Jan 30, 2010
thread pool with lockfree queue
View threadpool.hpp
#ifndef THREAD_POOL
#define THREAD_POOL
#include <pthread.h>
#include <stdlib.h> // malloc
#include <unistd.h> // sleep,usleep
#include "queue.hpp"
#include <assert.h>
#include <sys/resource.h> // rlimit
namespace{
@kumagi
kumagi / lockfree_stack.cpp
Created Feb 5, 2010
lock-free stack like STL
View lockfree_stack.cpp
template<typename obj>
class lf_stack{
private:
class node{
public:
obj data;
node* next;
node(const obj& d):data(d),next(NULL){ }
};
volatile node *head;
View deviding_tag.cpp
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <unistd.h>
#include <time.h>
class deviding_tag {
private:
@kumagi
kumagi / lockfree::queue.hpp
Created Apr 22, 2010
lockfree queue without hazard pointer
View lockfree::queue.hpp
#ifndef LOCKFREE_QUEUE
#define LOCKFREE_QUEUE
#include "atomics.h"
#include <unistd.h> // usleep
#include <stdlib.h> // rand
namespace lockfree{
template<typename T>
@kumagi
kumagi / atomics.h
Created Apr 22, 2010
atomic operation wrapper for i386 and x86_64
View atomics.h
#ifndef ATOMICS
#define ATOMICS
#if __x86_64__ || _WIN64
#define _64BIT
#define _ptr long long
#else
#define _32BIT
#define _ptr int
View kvs_client_sample.py
#!/usr/bin/python
import msgpack
import socket,struct,sys,time
SET=0
GET=1
DELETE=2
FOUND=3
DONE=4
NONE=5
@kumagi
kumagi / msgpack_client.cpp
Created Apr 24, 2010
msgpack KVSclient sample
View msgpack_client.cpp
#include <stdint.h>
#include <msgpack.hpp>
#include <mp/wavy.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
@kumagi
kumagi / msgpack_server.cpp
Created Apr 24, 2010
msgpack KVSserver sample
View msgpack_server.cpp
#include <stdint.h>
#include <stdlib.h>
#include <msgpack.hpp>
#include <mp/wavy.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
@kumagi
kumagi / tcp_wrapper.cpp
Created May 28, 2010
tcp socket wrapper for kumagi
View tcp_wrapper.cpp
static int OK = 1;
int create_tcpsocket(void){
int fd = socket(AF_INET,SOCK_STREAM, 0);
if(fd < 0){
perror("scocket");
}
return fd;
}
View tokyo cabinet hashmap in C++
#ifndef TCPP_HPP_
#define TCPP_HPP_
#include <tcutil.h>
#include <tchdb.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>