Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / native_client_sdk / src / examples / demo / nacl_io_demo / queue.h
blobe0ef83736264c767e49162a882becd184364454e
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. */
5 #ifndef QUEUE_H_
6 #define QUEUE_H_
8 #include "ppapi/c/pp_var.h"
10 /* This file implements a single-producer/single-consumer queue, using a mutex
11 * and a condition variable.
13 * There are techniques to implement a queue like this without using memory
14 * barriers or locks on x86, but ARM's memory system is different from x86, so
15 * we cannot make the same assumptions about visibility order of writes. Using a
16 * mutex is slower, but also simpler.
18 * We make the assumption that messages are only enqueued on the main thread
19 * and consumed on the worker thread. Because we don't want to block the main
20 * thread, EnqueueMessage will return zero if the message could not be enqueued.
22 * DequeueMessage will block until a message is available using a condition
23 * variable. Again, this may not be as fast as spin-waiting, but will consume
24 * much less CPU (and battery), which is important to consider for ChromeOS
25 * devices. */
27 void InitializeMessageQueue();
28 int EnqueueMessage(struct PP_Var message);
29 struct PP_Var DequeueMessage();
31 #endif /* QUEUE_H_ */