Questions tagged [boost-thread]

Boost.Thread enables the use of multiple threads of execution with shared data in portable C++ code.

Boost.Thread enables the use of multiple threads of execution with shared data in portable C++ code. It provides classes and functions for managing the threads themselves, along with others for synchronizing data between the threads or providing separate copies of data specific to individual threads.

The Boost.Thread library was originally written and designed by William E. Kempf. For Boost 1.35+, Anthony Williams performed a major rewrite designed to closely follow the proposals presented to the C++ Standards Committee, in particular N2497, N2320, N2184, N2139, and N2094.

As of Boost version 1.50.0 Boost.Thread provides an almost complete implementation of the C++ 2011 Threads library, plus extensions such as shared locks and thread interruption.

885 questions
5
votes
3 answers

boost::thread within a class

I'm trying to have a class that when created, starts a background thread, similar to that below: class Test { boost::thread thread_; void Process() { ... } public: Test() { thread_ = boost::thread(Process); } } I…
Matthew Finlay
  • 3,354
  • 2
  • 27
  • 32
5
votes
1 answer

Is using shared_ptr and weak_ptr to manage lifetime of std::function safe?

I've created a wrapper around boost::asio::io_service to handle asynchronous tasks on the GUI thread of an OpenGL application. Tasks might be created from other threads so boost::asio seems ideal for this purpose and means I don't need to write my…
RandomEtc
  • 1,976
  • 1
  • 18
  • 17
5
votes
1 answer

boost mutex throwing (odd?) exception

I am using a blocking queue example I got from this website, thinking it was pretty nice. This blocking queue is using boost::mutex. It is sometime throwing an exception : terminate called after throwing an instance of…
TheSquad
  • 7,385
  • 8
  • 40
  • 79
5
votes
2 answers

CPU Affinity in Boost::Thread API

Is it possible to set CPU affinity in boost threads ((i.e. setting each thread to run on a different CPU)? Is there any tutorial/documentation you can suggest on this? Googling does not return much info except the following thread where the…
F. Aydemir
  • 2,665
  • 5
  • 40
  • 60
5
votes
4 answers

boost thread destroys polymorphism

duplicate of: "pure virtual method called" when implementing a boost::thread wrapper interface I am trying to create a more object oriented version of the threads using boost threads. So I created a Thread class: class Thread { public: Thread()…
user365268
5
votes
4 answers

C++, Linux: error: conversion from ‘boost::unique_future’ to non-scalar type ‘boost::shared_future’ requested. how to get around it?

I try to work with boost thread futures. So as shown here we can get shared future from packaged task. So I try such function on linux: template void pool_item( boost::shared_ptr< boost::packaged_task > pt) { …
Rella
  • 65,003
  • 109
  • 363
  • 636
5
votes
2 answers

std::map of boost::mutex with strange behaviour

I have this code: //// // Default Namespaces /// using namespace std; typedef map t_map_shared_mutex; int main(int argc, char** argv) { t_map_shared_mutex list_lock; boost::shared_mutex global_lock; …
ElementalStorm
  • 809
  • 12
  • 31
5
votes
4 answers

boost::thread data structure sizes on the ridiculous side?

Compiler: clang++ x86-64 on linux. It has been a while since I have written any intricate low level system code, and I ussualy program against the system primitives (windows and pthreads/posix). So, the in#s and out's have slipped from my memory. I…
5
votes
2 answers

boost condition variable issue

The following minimal code sample of a larger program sends commands from client threads to an asio io_service object. The io_service object (in the Ios class) is being run with one thread. When the command is sent the client thread waits until it…
Liam
  • 100
  • 2
  • 6
5
votes
3 answers

boost::thread program crashes on throwing std::exception

I am puzzled as to why this program crashes. This is the entire program #include #include #include #include #include void func( const std::string& filename ) { …
user754425
  • 437
  • 1
  • 4
  • 10
5
votes
1 answer

Stopping threaded server loop using Boost::Asio

I am developing a tiny server loop for a bigger software but it doesn't work as I want it to do. When the user types in ".quit" I want the software to stop this threaded server loop: try { while (true) { acceptor.accept(socket); const…
Paul
  • 1,295
  • 2
  • 11
  • 26
5
votes
1 answer

PortAudio real-time audio processing for continuous input stream

I am using PortAudio to implement a real-time audio processing. My primary task is to acquire data from mic continuously and provide 100 samples for processing (each FRAME = 100 samples at a time) to some other processing thread. Here is my…
Ashish K
  • 905
  • 10
  • 27
5
votes
3 answers

boost::threads execution ordering

i have a problem with the order of execution of the threads created consecutively. here is the code. #include #include #include using namespace std; boost::mutex mutexA; boost::mutex mutexB; boost::mutex…
ali_bahoo
  • 4,732
  • 6
  • 41
  • 63
5
votes
1 answer

mciSendString doesn't pause sound played from a thread

Recently I already asked for a solution similar to this questions: Is there a way to pause/stop a mp3 file playing with mcisendstring with the "wait" option? I want to implement a function in my audio player which allows people to have sound playing…
Sossenbinder
  • 4,852
  • 5
  • 35
  • 78
5
votes
5 answers

Parallel version of loop not faster than serial version

I'm writing a program in C++ to perform a simulation of particular system. For each timestep, the biggest part of the execution is taking up by a single loop. Fortunately this is embarassingly parallel, so I decided to use Boost Threads to…