Actions

Boostcon 2011

From Just in Time

This page will contain my notes taken during Boostcon 2011

Library in a Week

Review tools

  • Code Collaborator
  • Crucible (Crubicle?)

Notes of my 'homework' assignment are here

Sort

Radix sort, does not use comparison. Faster if compare takes a relatively long time (e.g. string). Has three functions (integer_sort, float_sort, string_sort) and three overloads for each.

boost.algorithm

Intended to be a collection of algorithms, so that review of new algorithms can be much lighter.

Boost.Asio

Chris Kohlhoff

fundamental concepts that went into the library. Use them in your programs.

One key criterium: should not be a framework, but a toolkit. This gives you more freedom.

io_service
"your channel into the operationg system"

Challenges of asynchronous programming:

  • Object lifetimes
  • Thinking asynchronously
  • Threads
  • ?

Object lifetimes

handlers and buffers are taken by value, a copy is made. Buffers are shallow.

Arguments taken by non-const reference: caller needs to guarantee lifetime. this-pointer should outlive operation. Newby problem: providing a buffer that goes out of scope (local variable for instance).

Use shared_ptr and shared_from_this to automatically manage object lifetime.

Thinking Asynchronously

Wrong:

if (socket.connected())
{   
    socket.write();
}

Threading

  • First: single threaded
  • Use other thread to handle long running task. Uset post to give the result back to the main thread. Take care to tell the service that there is still work pending while the background thread is working. use 'asio::ioservice::work.
  • multiple io_services. Tip: If you want to make handlers wait for some event triggered by another async op, use a timer that will never expire.
  • one io_service, multiple threads. Use strands.

"Difficulty with reactor pattern is that it is hard to create [higher order abstractions] based on it"

Manage Complexity

Approaches

  • Pass the buck
    • create composed operations
  • the buck stops here

"Pass the buck" refers to passing the responsibility for the lifetime of objects to the caller in a similar way that the asio-function do this.

Phoenix V3

Hartmuth Kaiser

proto

Function calls can be either done through <terminal>() or just writing a function that uses make_expr to return a proto expression(-tree). The latter has much better performance (as learned from spirit).

Creating derivative of an analytical function.

Transactional Language Constructs for C++

Transactional Memory. Bridge Boost and C++ TM Spec.

  • tutorial
  • solicit feedback

Transactions can be composed.

"relaxed transactions" like a global lock, but actually obtaining a lock could be deferred to when the irreversible action is performed?

"discussion ensues"

Spirit.Qi

In case of compiler error: search for '***' in the output. go to the associated header file and there will probably be a useful comment there that explains what the problem is.

'%=' is not needed if the RHS does not contain semantic actions.

Gotcha: phoenix comma operator needs #iclude of 'sequence.hpp' to work, otherwise you get the regular comma, which silently fails.

Haskell and C++ Template Metaprogramming

Introduction to haskell

"a-> b" is a type and it means "function that takes an argument of type a and returns a value of type b" fact :: (Num t) => t-> t "if t is of Num type then fact is of type t -> t"

Operator overloading is possible, but, for instance the * operator can only be performed on types that are of 'class' Num

Continuation
instead of returning a value, receive an extra (function-) argument that represents the rest (continuation) of the calculation.

Haskell Monads

"Proto is like a state monad"

Threads and Shared Variables in C++0x

Synchronization primitives normally include some memory fence.

DRF = Data Race Free SC = Sequentially Consistent

Skoot network library

  • Insulate application from asynchronous design and coding details.
  • App provides all threading, no threads in Skoot

Extending boost.asio

Three objects:

  • io object
  • io service
  • io service object

The first and last are related (e.g. serial_port and serial_port_service). io service is the one and only io_service type of asio.

The deadline timer service actually uses a platform specific service.

basic_io_object has two members: the (specific) service (by ref) and the (specific) implementation (by value). The implementation member is given to the service when calls are forwarded to the service.

Many services use the same underlying platform specific service object. An example of a service that does not do this is the resolver_service. This service uses its own thread and io_service to resolve names in the background.

Don't use win_iocp_io_server directly, use b::a::windows:overlapped_ptr.

Object relational mapping with ODB and Boost

  • Since 4.5.0, GCC allows compiler plugins

http://codesynthesis.com/products/odb

Why C++0X is the most awesomest language...

Hooks in ASIO (boost 1.47.0) to show which handler registers other handlers and which handlers are being called. coroutines are in an ASIO example at this moment.

Boost.Generic

Boost.Process