summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@lshift.net>2009-09-02 11:09:29 +0100
committerMatthew Sackman <matthew@lshift.net>2009-09-02 11:09:29 +0100
commit88a24812eefde667fa1b16aa963b8706810fd6cc (patch)
treede93729b1926802db3bae7032277fbb526506c00
parent5f06c3f77569736c3dcb426b1d2a6be9ef9cf685 (diff)
downloadrabbitmq-server-git-88a24812eefde667fa1b16aa963b8706810fd6cc.tar.gz
made type signatures almost as useful as comments
-rw-r--r--include/rabbit.hrl3
-rw-r--r--src/rabbit_file_handle_cache.erl14
-rw-r--r--src/rabbit_msg_file.erl13
3 files changed, 19 insertions, 11 deletions
diff --git a/include/rabbit.hrl b/include/rabbit.hrl
index a2eae8f8f9..25a3673263 100644
--- a/include/rabbit.hrl
+++ b/include/rabbit.hrl
@@ -84,6 +84,9 @@
-type(info_key() :: atom()).
-type(info() :: {info_key(), any()}).
-type(regexp() :: binary()).
+-type(file_path() :: any()).
+-type(io_device() :: any()).
+-type(file_open_mode() :: any()).
%% this is really an abstract type, but dialyzer does not support them
-type(guid() :: any()).
diff --git a/src/rabbit_file_handle_cache.erl b/src/rabbit_file_handle_cache.erl
index 7cc2ed90da..85a5d6e942 100644
--- a/src/rabbit_file_handle_cache.erl
+++ b/src/rabbit_file_handle_cache.erl
@@ -33,6 +33,10 @@
-export([init/2, close_all/1, close_file/2, with_file_handle_at/4]).
+%%----------------------------------------------------------------------------
+
+-include("rabbit.hrl").
+
-record(hcstate,
{ limit, %% how many file handles can we open?
handles, %% dict of the files to their handles, age and offset
@@ -47,14 +51,14 @@
-type(hcstate() :: #hcstate { limit :: non_neg_integer(),
handles :: dict(),
ages :: gb_tree(),
- mode :: [any()]
+ mode :: [file_open_mode()]
}).
--spec(init/2 :: (non_neg_integer(), [any()]) -> hcstate()).
+-spec(init/2 :: (non_neg_integer(), [file_open_mode()]) -> hcstate()).
-spec(close_all/1 :: (hcstate()) -> hcstate()).
--spec(close_file/2 :: (any(), hcstate()) -> hcstate()).
--spec(with_file_handle_at/4 :: (any(), non_neg_integer(),
- fun ((any()) -> {non_neg_integer(), A}),
+-spec(close_file/2 :: (file_path(), hcstate()) -> hcstate()).
+-spec(with_file_handle_at/4 :: (file_path(), non_neg_integer(),
+ fun ((io_device()) -> {non_neg_integer(), A}),
hcstate()) ->
{A, hcstate()}).
-endif.
diff --git a/src/rabbit_msg_file.erl b/src/rabbit_msg_file.erl
index 6124b989c6..0b3b5af856 100644
--- a/src/rabbit_msg_file.erl
+++ b/src/rabbit_msg_file.erl
@@ -48,13 +48,14 @@
-ifdef(use_specs).
--spec(append/4 :: (any(), msg_id(), binary(), boolean()) ->
- ({'ok', non_neg_integer()} | any())).
--spec(read/2 :: (any(), non_neg_integer()) ->
+-spec(append/4 :: (io_device(), msg_id(), binary(), boolean()) ->
+ ({'ok', non_neg_integer()} | {'error', any()})).
+-spec(read/2 :: (io_device(), non_neg_integer()) ->
({'ok', {msg_id(), binary(), boolean(), non_neg_integer()}} |
- any())).
--spec(scan/1 :: (any()) -> {'ok', [{msg_id(), boolean(), non_neg_integer(),
- non_neg_integer()}]}).
+ {'error', any()})).
+-spec(scan/1 :: (io_device()) ->
+ {'ok', [{msg_id(), boolean(), non_neg_integer(),
+ non_neg_integer()}]}).
-endif.