Logtalk 2.30.7 files.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1973 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
pmoura
2007-11-06 01:50:09 +00:00
parent 6c3aee8c63
commit 42aabce1bb
320 changed files with 2252 additions and 1289 deletions

View File

@@ -1,6 +1,6 @@
================================================================
Logtalk - Open source object-oriented logic programming language
Release 2.30.2
Release 2.30.7
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
================================================================

View File

@@ -1,6 +1,6 @@
================================================================
Logtalk - Open source object-oriented logic programming language
Release 2.30.2
Release 2.30.7
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
================================================================
@@ -14,25 +14,55 @@ Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
% start the producer and the consumer, each one running in its own thread:
| ?- threaded_ignore(producer::run(10)), threaded_ignore(consumer::run(10)).
| ?- threaded_ignore(producer(2)::run(25)), threaded_ignore(consumer(5)::run(25)).
producer wrote item 0
consumer read item 0
producer wrote item 1
consumer read item 1
producer wrote item 2
consumer read item 2
producer wrote item 3
consumer read item 3
producer wrote item 4
consumer read item 4
producer wrote item 5
consumer read item 5
producer wrote item 6
consumer read item 6
producer wrote item 7
consumer read item 7
producer wrote item 8
consumer read item 8
producer wrote item 9
consumer read item 9
produced item 0 (1/7 items in the buffer)
consumed item 0 (0/7 items in the buffer)
produced item 1 (1/7 items in the buffer)
produced item 2 (2/7 items in the buffer)
produced item 3 (3/7 items in the buffer)
produced item 4 (4/7 items in the buffer)
consumed item 1 (3/7 items in the buffer)
produced item 5 (4/7 items in the buffer)
produced item 6 (5/7 items in the buffer)
produced item 7 (6/7 items in the buffer)
consumed item 2 (5/7 items in the buffer)
produced item 8 (6/7 items in the buffer)
consumed item 3 (5/7 items in the buffer)
produced item 9 (6/7 items in the buffer)
consumed item 4 (5/7 items in the buffer)
produced item 10 (6/7 items in the buffer)
consumed item 5 (5/7 items in the buffer)
produced item 11 (6/7 items in the buffer)
produced item 12 (7/7 items in the buffer)
consumed item 6 (6/7 items in the buffer)
produced item 13 (7/7 items in the buffer)
consumed item 7 (6/7 items in the buffer)
produced item 14 (7/7 items in the buffer)
consumed item 8 (6/7 items in the buffer)
produced item 15 (7/7 items in the buffer)
consumed item 9 (6/7 items in the buffer)
produced item 16 (7/7 items in the buffer)
consumed item 10 (6/7 items in the buffer)
produced item 17 (7/7 items in the buffer)
consumed item 11 (6/7 items in the buffer)
produced item 18 (7/7 items in the buffer)
consumed item 12 (6/7 items in the buffer)
produced item 19 (7/7 items in the buffer)
consumed item 13 (6/7 items in the buffer)
produced item 20 (7/7 items in the buffer)
consumed item 14 (6/7 items in the buffer)
produced item 21 (7/7 items in the buffer)
consumed item 15 (6/7 items in the buffer)
produced item 22 (7/7 items in the buffer)
consumed item 16 (6/7 items in the buffer)
produced item 23 (7/7 items in the buffer)
consumed item 17 (6/7 items in the buffer)
produced item 24 (7/7 items in the buffer)
consumed item 18 (6/7 items in the buffer)
consumed item 19 (5/7 items in the buffer)
consumed item 20 (4/7 items in the buffer)
consumed item 21 (3/7 items in the buffer)
consumed item 22 (2/7 items in the buffer)
consumed item 23 (1/7 items in the buffer)
consumed item 24 (0/7 items in the buffer)

View File

@@ -2,21 +2,19 @@
:- object(buffer(_MaxCapacity)).
:- info([
version is 2.0,
version is 2.1,
author is 'Paulo Moura',
date is 2007/6/20,
date is 2007/9/16,
comment is 'Producer-consumer problem with a bounded buffer.']).
:- threaded.
:- public(put/1).
:- dynamic(put/1).
:- mode(put(?integer), one).
:- info(put/1, [
comment is 'Put an item in the buffer.']).
:- public(get/1).
:- dynamic(get/1).
:- mode(get(?integer), one).
:- info(get/1, [
comment is 'Get an item from the buffer.']).
@@ -29,6 +27,26 @@
size_(0).
:- synchronized([put_item/1, get_item/1]).
put_item(Item) :-
parameter(1, MaxCapacity),
assertz(item_(Item)),
retract(size_(N)),
N2 is N + 1,
assertz(size_(N2)),
write(' produced item '), write(Item),
write(' ('), write(N2), write('/'), write(MaxCapacity), write(' items in the buffer'), write(')'), nl.
get_item(Item) :-
parameter(1, MaxCapacity),
retract(item_(Item)),
retract(size_(N)),
N2 is N - 1,
assertz(size_(N2)),
write(' consumed item '), write(Item),
write(' ('), write(N2), write('/'), write(MaxCapacity), write(' items in the buffer'), write(')'), nl.
put(Item) :-
parameter(1, MaxCapacity),
size_(N),
@@ -55,24 +73,6 @@
)
).
:- synchronized([put_item/1, get_item/1]).
put_item(Item) :-
assertz(item_(Item)),
retract(size_(N)),
N2 is N + 1,
assertz(size_(N2)),
sender(Sender),
writeq(Sender), write(' stored item '), write(Item), nl.
get_item(Item) :-
retract(item_(Item)),
retract(size_(N)),
N2 is N - 1,
assertz(size_(N2)),
sender(Sender),
writeq(Sender), write(' consumed item '), write(Item), nl.
:- end_object.

View File

@@ -1,4 +1,4 @@
:- initialization((
logtalk_load(library(random_loader), [reload(skip)]),
logtalk_load(library(random_loader), [reload(skip)]), % allow for static binding
logtalk_load(buffer))).