summaryrefslogtreecommitdiffstats
path: root/core/JMXThreadedEntity.h
blob: 2404dac664b392fa58c4232827a71ea1d76170eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//
// JMXThreadedEntity.h
// JMX
//
// Created by xant on 9/7/10.
// Copyright 2010 Dyne.org. All rights reserved.
//
//
//  This file is part of JMX
//
//  JMX is free software: you can redistribute it and/or modify
//  it under the terms of the GNU Lesser General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  Foobar 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 JMX.  If not, see <http://www.gnu.org/licenses/>.
//
/*!
 @header JMXThreadedEntity.h
 @abstract Base (abstract) class representing a threaded entity in the JMX world
 @discussion Threaded entities are those which require an active runloop to let them produce
             a signal at a given frequency. Not all entities need to be threaded, consider
             subclassing JMXEntity instead of this class if you don't really need an active thread
             to drive production of output signals
 @related JMXPin.h
 */
#import "JMXEntity.h"
#import "JMXRunLoop.h"

/*!
 * @class JMXThreadedEntity
 * @abstract Base class for threaded entitites
 * @discussion conforms to protocols: JMXRunLoop
 *
 *
 * This class exposes the follwing input pins:
 * 
 * * active kJMXBooleanPin
 * 
 * * frequency kJMXNumberPin MinValue:1.0 MaxValue:120.0
 *             The frequency at which signals must be delivered (AKA: how many times the tick: message is sent to the instance) 
 * 
 *
 * This class exposes the follwing output pins:
 *
 * * frequency kJMXNumberPin
 *             The effective frequency at which the entity is running (could be slowed down by a too heavy tick implementation)
 * 
 */
@interface JMXThreadedEntity : JMXEntity < JMXRunLoop > {
@protected
    uint64_t previousTimeStamp;
    NSNumber *frequency;
    BOOL quit;
@private
    NSThread *worker;
    NSTimer  *timer;
    JMXOutputPin   *frequencyPin;
    int64_t stamps[kJMXFpsMaxStamps + 1]; // XXX - 25 should be a constant
    int stampCount;
}

/*!
 @property frequency
 @abstract get/set the frequency at which output signals are delivered
 @discussion the frequency affects also how intensively is the runloop 
 */
@property (retain) NSNumber *frequency;

// entities should implement this message to trigger 
// delivering of signals to all their custom output pins

@end