Quantcast
Channel: User yohjp - Stack Overflow
Browsing latest articles
Browse All 38 View Live

Comment by yohjp on How to parallel variadic function with TBB parallel_for?

When range has 4 elements and TBB splits it two subranges, you want to parallel invoke func(t1,t2,(t3+0),(t3+1)) and func(t1,t2,(t3+2),(t3+3)) ?

View Article



Comment by yohjp on How to parallel variadic function with TBB parallel_for?

gcc 4.8.2 does and 4.8.3 will be. LiveDemo

View Article

Comment by yohjp on How can I get revoked flag for current task in Celery...

so, what should I do revoke that task?

View Article

Comment by yohjp on Is the meaning of "lock-free" even defined by the C++...

Please refer C++14 (also C++11) 17.3.2[defns.block] define block and 17.3.3[defns.blocked] define blocked thread. 17.3.3 says "a thread that is waiting for some condition (other than the availability...

View Article

Comment by yohjp on Copy/move semantics documentation of &T/&mut T types itself

Thanks for your comment. Why they behave is understandable, and I'm looking for some documented resources.

View Article


Comment by yohjp on ffmpeg: Is there a way to decode a video frame, given the...

MPEG-4 video decoding performs IDCT(Inverse discrete cosine transform) process. ISO MPEG-4 Standard define IDCT with floating point number, so each Decoder implementation may output slightly different...

View Article

Comment by yohjp on Why is std::shared_ptr::unique() deprecated?

@user3514538 Your interpretation about C++ atomics is wrong, read LWG2776.

View Article

Comment by yohjp on What about atomic_flag.wait/notify_one in gcc and clang?

P0995R1 proposal was integrated into P1135R6, and here is libstdc++ / libcxx status page.

View Article


Comment by yohjp on Why does C++20 std::condition_variable not support...

Do you intend to write that lock.lock() -> cv.notify_all() -> lock.unlock() ordering in stop_callback lambda? Anyway std::condition_variable accepts only std::unique_lock<std::mutex> as...

View Article


Comment by yohjp on Why must a std::ranges::filter_view object be non-const...

FYI: P0789R3 1.3.1 "The filter adaptor is not const-iterable" explains the design decision of filter_view.

View Article

Comment by yohjp on Ffmpeg Video frame rate issues

You can count actual video frames with ffmpeg -i <input.avi> -f null /dev/null. The AVI media container does NOT support H.264 video stream (and/or modern video codecs), it has no frame...

View Article

Comment by yohjp on pthread_barrier_t on Android NDK

Android NDK added pthread_barrier_t since API level 24. See github.com/android/ndk/issues/336.

View Article

Comment by yohjp on Restriction of explicit object parameter in lambda with...

I mean that "implementation issues" is for C++ compiler.

View Article


Answer by yohjp for c++ openmp for loop max reduction value during interim of...

Is it the max only for a particular thread or is it the max of all threads?It's a "per thread" private value within OpenMP parallel region.The following code snippet might implement what you want to...

View Article

Answer by yohjp for OpenMP : Creating threads, parallelism, barrier in loop

In your code, loop iterator i is shared unintentionally;#pragma omp parallelshall be#pragma omp parallel private(i)Live demo: http://melpon.org/wandbox/permlink/nE74kARjqoBjVWbr

View Article


Answer by yohjp for Unable to calculate Percentage in thread to update status.

You should lock mutex for reading a global variable(prec).while(1){ int curr_prec; pthread_mutex_lock(&my_lock); curr_prec = prec; pthread_mutex_unlock(&my_lock); printf("\r%d %.2f percent...

View Article

Answer by yohjp for What exactly does the final keyword guarantee regarding...

"JSR 133 (Java Memory Model) FAQ, Jeremy Manson and Brian Goetz, February 2004" describes how does final field work.How can final fields appear to change their values?How do final fields work under the...

View Article


Answer by yohjp for OpenMP reduction with template type

It's unspecified (for OpenMP 3.0 or later) or undefined (for OpenMP 2.5)reduction is one of data-sharing attribute clauses, and OpenMP Application Program Interface Version 2.5 says:2.8.3 Data-Sharing...

View Article

Answer by yohjp for CountDownLatch.await/countDown vs Thread.join/interrupt...

+1 for CountDownLatch.It's simple and light-weighted than Thread.

View Article

Answer by yohjp for Implementing pthreads in .h and .cpp

The error message says that AppendData_Linux is member function of XMLParse class, and that can't convert to pointer to normal (non-member) function required by pthread_create.Here is solution:class X...

View Article

Answer by yohjp for How can memory_order_relaxed work for incrementing atomic...

Boost.Atomic library that emulates std::atomic provides similar reference counting example and explanation, and it may help your understanding.Increasing the reference counter can always be done with...

View Article


Answer by yohjp for Will two atomic writes to different locations in...

Is the weird outcomer1==1, r2==0 and r3==0, r4==2 possible in this case under the C++11 memory model?Yes. C++ memory model allows such weird outcome.What if I were to replace all...

View Article


Answer by yohjp for how to write an atomic account transfer function

Your code is logically broken. Regardless of the from_account's balance, to_account will win account unconditionally! (and I wanna be to_account owner :)In this case, you must acquire both locks of two...

View Article

Answer by yohjp for how to handle cached data structures with multi-threading...

You can use "Double-Checked-Locking(DCL) pattern" with OpenMP atomic operation, OpenMP v3.1 or later required (read/write option of omp atomic pragma).class A {public: A() : initialized(false) {} int...

View Article

Answer by yohjp for Setting all TLS (thread local storage) variables to a...

Here is a light weighted implementation of "Plan A" with C++11 Standard atomic variable and thread_local-specifier. (If your compiler doesn't support them, please replace to vendor specific...

View Article


non-member function begin()/cbegin() and its constexpr-ness

C++11 introduced std::begin() non-member function without constexpr-specifier, and then C++14 updates to constexpr-std::begin() for array type(T (&)[N]) and appends constexpr-std::cbegin() for...

View Article

What does 'transmitted' mean in printf function return?

I'm confused the interpretation of printf's return value and buffered stream in Standard C Library. In C99:TC3 Standard, 7.19.6.3/p3 defines that printf function returns non-negative "number of...

View Article

Answer by yohjp for Reduction(op:var) has the same effect as shared(var)

shared clause would be sufficient for such operation.Nope.When you remove reduction(+:result), program cause data race on result variable and the result is unstable.This means you may get wrong result,...

View Article

Task progress is not updated latest status on Celery+RabbitMQ

I implemented progress feedback of long task with custom states on Celery + RabbitMQ result backend.But the caller can't retrive the latest progess status as I expected. In following code,...

View Article



Answer by yohjp for Consume queue from other thread

TypeError caused from for element in q: not q.empty(). Because Queue class doesn't provide __iter__() nor __getitem__() methods for for-statement.You should use get() method to retrieve the element.

View Article

Answer by yohjp for VS 11 with std::future - Is this a bug?

Try below adhoc workaround. (I tried at Visual Studio 11 Beta)std::future<int> f = std::async(std::launch::any, foo, 5, 7);As C++11 standards function std::async() has two overloads, but MSVC/CRT...

View Article

Answer by yohjp for Copy/move semantics documentation of &T/&mut T types itself

Rust's std::marker::Copy trait reference says (thanks to @Chris Emerson):When can my type not be Copy? Some types can't be copied safely. For example, copying &mut T would create an aliased mutable...

View Article

How can I get revoked flag for current task in Celery worker?

I want to implement task cancellation with cleanup process on Celery + RabbitMQ broker.How can I get "REVOKED" status of current task in Celery worker?# tasks.py -- celery workerfrom celery import...

View Article


why `S x({})` invoke default constructor in GCC 7/C++1z mode only?

In the following snippet, GCC 7 with C++1z mode invokes the default constructor, but GCC/C++14 and Clang/C++14,C++1z invoke the initializer-list constructor.Is this behavior affected by any C++1z...

View Article

GCC 5.1 warns cancel construct within `parallel for` construct

When I use cancel directive (since OpenMP 4.0) to break parallel loop within parallel for construct, GCC 5.1 warns "'#pragma omp cancel for' inside 'nowait' for construct" for the following...

View Article

Answer by yohjp for Implementing example from coroutines TS 2017

Can this be improved, in a reasonably economical way, to tend to the dangling thread?You can use "thread pool" implementation, instead of on-demand detached thread.Here is toy...

View Article


Answer by yohjp for Create a generator in C++ using coroutines

promise_type::get_return_object() shall return user-defined coroutine result type resumable_thing, instead of promise_type& itself.struct resumable_thing{ struct promise_type { resumable_thing...

View Article


Why does C++20 std::condition_variable not support std::stop_token?

In C++20 Standard library std::condition_variable_any::wait() family support std::stop_token for generalized thread cancellation, but std::condition_variable does not.P0660R10 Stop Token and Joining...

View Article
Browsing latest articles
Browse All 38 View Live




Latest Images