synchronization

How to synchronize multiple video streams in ActionScript?

怎甘沉沦 提交于 2019-12-06 06:35:19
问题 I'm trying to play multiple video streams simultaneously. However, I cannot synchronize these videos to play at the same rate. ---- details -------- I have three 45-second videos in FLV format and I use flash.net.NetStream to play these videos. I call netstream.play() of these netstream at the same time (by using a for-loop). However, these videos are out-of-sync even all videos files are on my local machine. For example, when the wall clock is at 10th second, the first video is at 7th second

How to synchronize threads in python?

孤街醉人 提交于 2019-12-06 06:21:34
I have two threads in python (2.7). I start them at the beginning of my program. While they execute, my program reaches the end and exits, killing both of my threads before waiting for resolution. I'm trying to figure out how to wait for both threads to finish before exiting. def connect_cam(ip, execute_lock): try: conn = TelnetConnection.TelnetClient(ip) execute_lock.acquire() ExecuteUpdate(conn, ip) execute_lock.release() except ValueError: pass execute_lock = thread.allocate_lock() thread.start_new_thread(connect_cam, ( headset_ip, execute_lock ) ) thread.start_new_thread(connect_cam, (

What will it take for Transactional Memory to be viable?

六月ゝ 毕业季﹏ 提交于 2019-12-06 05:22:51
问题 I've been doing some work on transactional memory and its viability for systems programming (databases, operating systems, servers, etc.). My own experience employing transactions, together with having seen how few communities use transactions in real code, has raised a question: What would convince you, a developer writing production code, to employ transactional memory in your work? Would it be general adoption? High speed? Improved reliability? By how much? For those that haven't seen them

Get a number of resources asynchronously and “asynchronously” save them to a database. Which good pattern to use? (AFNetworking, Core Data)

无人久伴 提交于 2019-12-06 05:19:22
I need to populate my map with annotations. Each annotation has corresponding Place resource that is being fetched from remote server. Each Place has associated Category - it is fetched from the server too as a separate resource. Let's assume that to populate a given region I need to fetch 100 places, each belonging to the one of 20 categories (actually there are much more of them). I use AFNetworking to fetch the both of resources. I try to cache both places and categories for offline use, so before the annotations are displayed on map, I write fetched resources to the Core Data tables. Each

Memory visibility in C++ concurrency (no data race)

我只是一个虾纸丫 提交于 2019-12-06 05:05:18
It is a follow up question of Shared_ptr and Memory Visibility in c++ and Create object in thread A, use in thread B. Mutex required? . This question is more about memory visibility rather than data race. In Java, I have: ExecutorService executor = Executors.newSingleThreadExecutor(); Integer i = new Integer(5); // no write to i afterwards executor.submit(() -> { System.out.println(i); }); I don't think this is thread-safe. Because there is no need to put value 5 in the main memory, it could stay in the main thread's CPU cache. Since there is no memory barrier, the executor thread is not

InitializeCriticalSectionAndSpinCount optimal SpinCount (user mode)

蓝咒 提交于 2019-12-06 04:35:52
I don't quite understand the documentation for InitializeCriticalSectionAndSpinCount: http://msdn.microsoft.com/en-us/library/windows/desktop/ms683476(v=vs.85).aspx It says "You can improve performance significantly by choosing a small spin count ..." However, since waiting on a spinner is faster than waiting for an object, doesn't it make sense to have the SpinCount as high as possible? What am I missing? Thanks. (I am using it inside a C DLL used by a multi-threaded application) Here is the code for the critical section, called constantly by a large number of threads: int g_slots[256] = {0};

Two threads using a same variable

给你一囗甜甜゛ 提交于 2019-12-06 04:22:51
I have two threads: 'main' and 'worker', and one global variable bool isQuitRequested that will be used by the main thread to inform worker , when it's time to quit its while loop (something like this: while(isQuitRequested == false) { ... do some stuff ... } ) Now, I'm a bit concerned... Do I need to use some kind of mutex protection for isQuitRequested , considering that only one thread ( main ) performs isQuitRequested = true operation, and the other ( worker ) just performs checking and nothing else? I have read What could happen if two threads access the same bool variable at the same

Multiple threads waiting on one event?

老子叫甜甜 提交于 2019-12-06 04:19:47
问题 What (I think) I want is the equivelant of an AutoResetEvent that multiple threads can wait on, all to be resumed when it's set. I know this can be achieved by having one AutoResetEvent per thread and setting each of them - but is there an easier way? A way that doesn't depend on arrays of eventhandles? Effectively what (I think) I'd like is to be able to do this: private volatile string state; private MultiEventHandle stateChanged = new MultiEventHandle(); public void WaitForBlob() { while

iOS: Synchronizing frames from camera and motion data

 ̄綄美尐妖づ 提交于 2019-12-06 04:10:32
问题 I'm trying to capture frames from camera and associated motion data. For synchronization I'm using timestamps. Video and motion is written to a file and then processed. In that process I can calculate motion-frames offset for every video. Turns out motion data and video data for same timestamp is offset from each other by different time from 0.2 sec up to 0.3 sec. This offset is constant for one video but varies from video to video. If it was same offset every time I would be able to subtract

When should each thread synchronization objects be used?

邮差的信 提交于 2019-12-06 04:02:28
Under what circumstances should each of the following synchronization objects be used? ReaderWriter lock Semaphore Mutex Since wait() will return once for each time post() is called, semaphores are a basic producer-consumer model - the simplest form of inter-thread message except maybe signals. They are used so one thread can tell another thread that something has happened that it's interested in (and how many times), and for managing access to resources which can have at most a fixed finite number of users. They offer ordering guarantees needed for multi-threaded code. Mutexes do what they