Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding non-blocking (on destruction) service executors/future_then_as…
…ync_executor.cpp - implement run_as_os_thread in terms of non-blocking io_pool executor
- Loading branch information
Showing
6 changed files
with
188 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
tests/regressions/threads/run_as_os_thread_lockup_2991.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) 2017 Maciej Brodowicz | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#include <hpx/hpx_init.hpp> | ||
#include <hpx/hpx.hpp> | ||
#include <hpx/runtime/threads/run_as_os_thread.hpp> | ||
|
||
#include <iostream> | ||
#include <mutex> | ||
#include <thread> | ||
|
||
std::mutex mtx; | ||
|
||
void locker() | ||
{ | ||
std::cout << std::this_thread::get_id() << ": about to lock mutex\n"; | ||
std::lock_guard<std::mutex> lock(mtx); | ||
std::cout << std::this_thread::get_id() << ": mutex locked\n"; | ||
} | ||
|
||
int hpx_main() | ||
{ | ||
{ | ||
std::cout << std::this_thread::get_id() << ": about to lock mutex\n"; | ||
std::lock_guard<std::mutex> lock(mtx); | ||
std::cout << std::this_thread::get_id() << ": mutex locked\n"; | ||
|
||
std::cout << std::this_thread::get_id() << ": about to run on io thread\n"; | ||
hpx::threads::run_as_os_thread(locker); | ||
//sleep(2); | ||
} | ||
std::cout << std::this_thread::get_id() << ": exiting\n"; | ||
|
||
return hpx::finalize(); | ||
} | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
return hpx::init(argc, argv); | ||
} | ||
|