blob: e23c13883e5392574f5daabfbcb6a3692a092627 [file] [log] [blame]
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <list>
#include "base/basictypes.h"
#include "mojo/public/system/core.h"
#include "mojo/public/system/system_export.h"
namespace mojo {
namespace system {
class Waiter;
// |WaiterList| tracks all the |Waiter|s that are waiting on a given
// handle/|Dispatcher|. There should be a |WaiterList| for each handle that can
// be waited on (in any way). In the simple case, the |WaiterList| is owned by
// the |Dispatcher|, whereas in more complex cases it is owned by the secondary
// object (see simple_dispatcher.* and the explanatory comment in
// This class is thread-unsafe (all concurrent access must be protected by some
// lock).
class MOJO_SYSTEM_EXPORT WaiterList {
void AwakeWaitersForStateChange(MojoWaitFlags satisfied_flags,
MojoWaitFlags satisfiable_flags);
void CancelAllWaiters();
void AddWaiter(Waiter* waiter, MojoWaitFlags flags, MojoResult wake_result);
void RemoveWaiter(Waiter* waiter);
struct WaiterInfo {
WaiterInfo(Waiter* waiter, MojoWaitFlags flags, MojoResult wake_result)
: waiter(waiter), flags(flags), wake_result(wake_result) {}
Waiter* waiter;
MojoWaitFlags flags;
MojoResult wake_result;
typedef std::list<WaiterInfo> WaiterInfoList;
WaiterInfoList waiters_;
} // namespace system
} // namespace mojo