Skip to content

Instantly share code, notes, and snippets.

@yohhoy
yohhoy / gist:1827903
Created February 14, 2012 16:25
Tiny Parallel Library
/**
* Tiny Parallel Library
*
* The library implements following parallel algorithms that its
* interface are compatible with Intel TBB and Microsoft PPL.
* - parallel_for_each(first,last,func)
* - parallel_for(first,last,func)
* - parallel_invoke(f1,f2,...) (up to 4 args)
*/
#ifndef TINYPL_HPP
@yohhoy
yohhoy / binsem.cpp
Last active February 23, 2024 12:48
binary semaphore for C++11
#include <mutex>
#include <condition_variable>
// binary semaphore
class binsem {
public:
explicit binsem(int init_count = count_max)
: count_(init_count) {}
// P-operation / acquire
@yohhoy
yohhoy / threads.h
Last active December 6, 2023 00:35
C11 <threads.h> emulation library
/*
* C11 <threads.h> emulation library
*
* (C) Copyright yohhoy 2012.
* Distributed under the Boost Software License, Version 1.0.
* (See copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef EMULATED_THREADS_H_INCLUDED_
#define EMULATED_THREADS_H_INCLUDED_
@yohhoy
yohhoy / mock_tbb.h
Created April 2, 2012 05:09
Mockup implementation of TBB
/*
* Mockup implementation of Threading Building Blocks(TBB) library
*
* (C) Copyright yohhoy 2012.
* Distributed under the Boost Software License, Version 1.0.
* (See copy at http://www.boost.org/LICENSE_1_0.txt)
*
* Support:
* - Range concept (except `blocked_range3d')
* - Parallel algorithms (except `pipeline'/`parallel_pipeline')
@yohhoy
yohhoy / libfiber.hpp
Created April 6, 2012 08:13
fiber library(prototype)
/*
* libfiber.hpp
*
* (C) Copyright yohhoy 2012.
* Distributed under the Boost Software License, Version 1.0.
* (See copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef LIBFIBER_HPP_INCLUDED_
#define LIBFIBER_HPP_INCLUDED_
@yohhoy
yohhoy / example.cpp
Created April 9, 2012 08:07
example for "libfiber.hpp"
/*
* example for "libfiber.hpp" - 2生産者-3消費者デモ
*/
#include <iostream>
#include <vector>
#include <boost/circular_buffer.hpp>
#include "libfiber.hpp"
// 上限付きFIFOキュー
@yohhoy
yohhoy / deferthread.cpp
Created April 19, 2012 14:08
deferred thread start
#include <iostream>
#define PROCESS (std::cout<<"do"<<std::endl)
//#define PROCESS (throw 42)
//--------------------------------
#ifdef TEST1
#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
class X {
@yohhoy
yohhoy / once_function.cpp
Created April 27, 2012 08:12
once function(+binder)
#include <tuple>
#include <memory>
#include <functional> // bad_function_call
#include <utility>
#include <type_traits>
namespace detail {
// index_tuple<size_t...>, make_indices<E,S>
@yohhoy
yohhoy / oledd.c
Created July 5, 2012 12:17
OLE Drag & Drop sample code
/*
* OLE Drag and Drop module
*
* Copyright(c) 2001 yoh(yohhoy)
*/
#define STRICT
#define NONAMELESSUNION
#define COBJMACROS
#include <windows.h>
#include "oledd.h"
@yohhoy
yohhoy / tricky.bas
Created July 5, 2012 15:13
VisualBasic 6.0
Attribute VB_Name = "mdlMain"
Option Explicit
'
' tricky.bas
'
' Copyright(c) 2001 yoh(yohhoy)
'
' Win32API
Private Type WNDCLASS