Skip to content

Instantly share code, notes, and snippets.

<html>
<head>
<title>Try chunked stream</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
</head>
<body>
<div id="progress_container" style="width: 123px; height: 20px; background-color: white; border: solid black 1px">
<div id="progress_bar" style="width: 0px; height: 18px; background-color: white; border: solid blue 1px; background-color: blue">
</div>
<br style="clear:both"/>
get_cmake_property(var_names VARIABLES)
foreach (var ${var_names})
message(STATUS "${var}=${${var}}")
endforeach()
typedef struct Foo Foo;
Foo *bar; // this is ok
void bartest()
{
bar->a = 2; // this is NOT ok, struct Foo is not defined
}
// Note, no typedef here, just defining struct Foo
@doug65536
doug65536 / gist:6115840
Last active December 20, 2015 10:31
Producer consumer queue
template<typename T>
class ProducerConsumer
{
thread_mutex queue_lock;
thread_condition_variable queue_not_empty;
thread_condition_variable queue_not_full;
typedef std::deque<T> Queue;
Queue queue;
@doug65536
doug65536 / gist:6119730
Last active December 20, 2015 10:59
cmake producer consumer test
cmake_minimum_required(VERSION 2.8)
project(producerconsumer)
set(SRC
main.cpp
util_pcqueue.h
)
if(CMAKE_COMPILER_IS_GNUCXX )
@doug65536
doug65536 / gist:6119771
Created July 31, 2013 06:24
producer consumer link errors
Linking CXX executable test_pc_std
/usr/bin/cmake -E cmake_link_script CMakeFiles/test_pc_std.dir/link.txt --verbose=1
/usr/bin/c++ -std=c++11 -pthread CMakeFiles/test_pc_std.dir/main.cpp.o CMakeFiles/test_pc_std.dir/dummy.cpp.o -o test_pc_std -rdynamic
CMakeFiles/test_pc_std.dir/main.cpp.o: In function `main':
main.cpp:(.text+0xe7): undefined reference to `boost::thread::join()'
main.cpp:(.text+0xf6): undefined reference to `boost::thread::join()'
main.cpp:(.text+0x10a): undefined reference to `boost::thread::~thread()'
main.cpp:(.text+0x119): undefined reference to `boost::thread::~thread()'
main.cpp:(.text+0x157): undefined reference to `boost::thread::~thread()'
main.cpp:(.text+0x16b): undefined reference to `boost::thread::~thread()'
@doug65536
doug65536 / gist:6119783
Created July 31, 2013 06:26
producer consumer configure output
doug@doug-MS-7666 ~/code/producerconsumer/build $ cmake ../producerconsumer
-- Boost version: 1.49.0
-- Found the following Boost libraries:
-- thread
-- boost defines:
-- boost include dirs: /usr/include
-- boost library dirs: /usr/lib
-- boost libraries: /usr/lib/libboost_thread-mt.so;pthread
-- Configuring done
-- Generating done
#ifdef WITH_BOOST
#include <boost/thread.hpp>
#include <boost/bind.hpp>
typedef boost::thread thread;
typedef boost::mutex thread_mutex;
typedef boost::mutex::scoped_lock thread_scoped_lock;
typedef boost::condition_variable thread_condition_variable;
#define function_bind boost::bind
#define sleep_ms(ms) boost::this_thread::sleep_for(boost::chrono::milliseconds(ms))
#ifdef WITH_BOOST
#include <boost/thread.hpp>
#include <boost/bind.hpp>
typedef boost::thread thread;
typedef boost::mutex thread_mutex;
typedef boost::mutex::scoped_lock thread_scoped_lock;
typedef boost::condition_variable thread_condition_variable;
#define function_bind boost::bind
#define sleep_ms(ms) boost::this_thread::sleep_for(boost::chrono::milliseconds(ms))
#elif __cplusplus >= 201103L
#include <iostream>
#include "util_pcqueue.h"
#ifdef WITH_BOOST
#include <boost/atomic.hpp>
#define Atomic boost
#elif __cplusplus >= 201103L
#include <atomic>
#define Atomic std