iothread.c File Reference

Implementation for a thread used for blocking I/O operations. More...

#include <SDL.h>
#include <SDL_thread.h>
#include <assert.h>
#include "iothread.h"
#include "random.h"

Include dependency graph for iothread.c:

Go to the source code of this file.

Data Structures

struct  Operation_t
 Stores information on a queued operation. More...

Defines

#define FLAG_CANCEL   1
 Bit flag used with opFlags to indicate that the current operation should return early.
#define FLAG_TERM   2
 Bit flag used with opFlags to indicate that the I/O thread should terminate.

Functions

Bool CancelOperations ()
 Attempts to cancel all operations currently queued on the I/O thread.
static int ioThread (void *ignore)
 The thread body that waits for queued I/O requests and runs them.
Bool IsCancelationRequested ()
 Tells if a request has been made to cancel the current operation on the I/O thread through a call to CancelOperations().
int QueueOperation (ioOperation op, void *data)
 Adds an operation to the queue of pending blocking operations.
void StartIOThread ()
 Starts the I/O thread.
void StopIOThread ()
 Terminates the I/O thread.

Variables

static SDL_cond * notify
 Used to notify the I/O thread that there is work to do.
static int opFlags = 0
 The flags used to indicate when:
  • the running operation should return early
  • the I/O thread should terminate.

static struct Operation_t queue [4]
 The operation queue.
static int queueLen = 0
 The number of operations in the queue.
static SDL_mutex * queueMutex = NULL
 The semaphore used to control access to the operation queue.
static int queueNext = 0
 The index of the next operation in the queue.
static SDL_Thread * thread = NULL
 A reference to information about the running I/O thread.


Detailed Description

Implementation for a thread used for blocking I/O operations.

Author:
Jeff Jackowski (jeffj@ro.com)
Copyright (C) 2007 Jeff Jackowski

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Or visit their website at: http://www.gnu.org/

Definition in file iothread.c.


Generated on Mon May 28 04:41:39 2007 for Retro Tank Super Attack by  doxygen 1.5.2