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
4
votes
1 answer

Boost 1.48.0 upgrade_to_unique_lock on Linux: Has something changed since 1.47 or I do something wrong?

I have a small cpp source and h source files with some class. It uses shared mutexes and shared locks. It compiles on windows with no errors with boost 1.48.0. It also compiled on linux (with boost 1.47 before). But now having code like this: …
myWallJSON
  • 9,110
  • 22
  • 78
  • 149
4
votes
2 answers

Use boost::mutex with MFC threads (AfxBeginThread)?

Can you use the boost::mutex libraries to protect a critical section of code when you are not using boost::thread but instead using the MFC threading capability via AfxBeginThread? If so, are there any problems with doing this?
User
  • 62,498
  • 72
  • 186
  • 247
4
votes
4 answers

boost::scoped_lock not working with local static variable?

I made the following sample program to play with boost threading: #pragma once #include "boost\thread\mutex.hpp" #include class ThreadWorker { public: ThreadWorker() {} virtual ~ThreadWorker() {} static void FirstCount(int…
User
  • 62,498
  • 72
  • 186
  • 247
4
votes
4 answers

Boost::thread how to get a pointer to the thread where my function is called?

With boost::thread how do I get a pointer to the boost::thread which is currently executing my function, from within that function? The following does not compile for me: boost::thread *currentThread = boost::this_thread;
Rella
  • 65,003
  • 109
  • 363
  • 636
4
votes
1 answer

Incorrect use of boost::asio and boost::thread

I am using boost::asio and boost::thread to realize a message service which accepts messages, send them asynchronously if there is no message being processed or queues the message if there are messages being processed. The message rate is to my mind…
Konrad Reiche
  • 27,743
  • 15
  • 106
  • 143
4
votes
3 answers

How do I reverse set_value() and 'deactivate' a promise?

I have a total n00b question here on synchronization. I have a 'writer' thread which assigns a different value 'p' to a promise at each iteration. I need 'reader' threads which wait for shared_futures of this value and then process them, and my…
MMagique
  • 41
  • 3
4
votes
1 answer

asio use_future instead of yield[ec]

i want to make container of futures ,each future is void result of a task so that i could use wait_for_any on the container ,each task is coroutine which i currently implement using yield_context,and inside this coroutine there initiating function…
ahmed allam
  • 377
  • 2
  • 15
4
votes
2 answers

Condition variables

I noticed that when I'm performing a wait operation on a condition variable, it immediately returns. The consequence is that, when executing the following dummy code, 100% of one CPU is being used in the loop : int main(void)…
4
votes
0 answers

Linker cannot find boost::thread references

Background: I'm porting an huge project to a new toolchain (from gcc 4.7.0 to gcc 8.2.0 and from boost 1.55 to boost 1.68). The whole SDK is generated by Yocto. There are several libraries and applications, all built with cmake. The problem: All the…
gabbla
  • 269
  • 4
  • 11
4
votes
3 answers

Using boost::thread with CMake in MS Visual Studio 2017 results in two compiler errors

I want to use boost::thread in my project and I use CMake as a build tool. However, even a very simple setup results in two compiler errors: main.cpp #include int main() { boost::thread t; return…
WolfgangP
  • 3,195
  • 27
  • 37
4
votes
1 answer

Problem accessing camera when using Boost thread on OSX

I'm trying to use OpenCV to open a camera. This works fine when I open the camera in the main thread, but when I try to open the camera while in a Boost thread, it fails. I haven't been able to google why this happens. I assume it's somehow related…
okintheory
  • 195
  • 1
  • 6
4
votes
1 answer

assignment operator for classes having a non copyable boost::mutex

I am reading here this old Boost Thread FAQ where there is a guideline to implement copy-construction and assignment operator for classes having a boost::mutexnon-copyable object as member. I am fine with the copy constructor but I have some doubt…
Abruzzo Forte e Gentile
  • 14,423
  • 28
  • 99
  • 173
4
votes
2 answers

How to add boost thread library to an iPhone project?

I am trying to port an existing project to iPhone which needs Boost.Thread library, the project compiles without error but there are link errors: "boost::thread::start_thread()", referenced from: boost::thread::thread<(anonymous…
ohho
  • 50,879
  • 75
  • 256
  • 383
4
votes
1 answer

Boost Thread Access Violation in Boost Log on shutdown

I have an application that uses boost logging. During shutdown, it gets an access violation on a null pointer access. When I step through the code to the point of failure, it appears that the boost::log dll is being de-allocated and then…
JeffV
  • 52,985
  • 32
  • 103
  • 124
4
votes
2 answers

Inner class and initialisation

I have a class defined like this: This is not all complete and probably won't compile. class Server { public: Server(); ~Server(); class Worker { public: Worker(Server& server) : _server(server) { } ~Worker() { } void Run()…
hookenz
  • 36,432
  • 45
  • 177
  • 286