• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

I_ProtectedQueue.h

Go to the documentation of this file.
00001 /** @file
00002 
00003   A brief file description
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 /****************************************************************************
00025 
00026   Protected Queue, a FIFO queue with the following functionality:
00027   (1). Multiple threads could be simultaneously trying to enqueue
00028        and dequeue. Hence the queue needs to be protected with mutex.
00029   (2). In case the queue is empty, dequeue() sleeps for a specified
00030        amount of time, or until a new element is inserted, whichever
00031        is earlier
00032 
00033 
00034  ****************************************************************************/
00035 #ifndef _I_ProtectedQueue_h_
00036 #define _I_ProtectedQueue_h_
00037 
00038 #include "libts.h"
00039 #include "I_Event.h"
00040 struct ProtectedQueue
00041 {
00042   void enqueue(Event * e,bool fast_signal=false);
00043   void signal();
00044   int try_signal();             // Use non blocking lock and if acquired, signal
00045   void enqueue_local(Event * e);        // Safe when called from the same thread
00046   void remove(Event * e);
00047   Event *dequeue_local();
00048   void dequeue_timed(ink_hrtime cur_time, ink_hrtime timeout, bool sleep);
00049 
00050   InkAtomicList al;
00051   ink_mutex lock;
00052   ink_cond might_have_data;
00053   Que(Event, link) localQueue;
00054 
00055   ProtectedQueue();
00056 };
00057 
00058 void flush_signals(EThread * t);
00059 
00060 #endif

Generated by  doxygen 1.7.1