doer 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/doer.rb +61 -0
- metadata +44 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d2bfc4d0bbf3418d5c01f9c4775c7f269277b9cdbd70ac84fc74e4cb61ed54b4
|
|
4
|
+
data.tar.gz: 58201652d667a93cb5a69754e02b4aa328c4eb19f33a09c576927da730f9f2c9
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: de32a413cc72a366f27369aa2cdfe36b3ffc46e8615b17c60cf7cdcc6f6402d9b3b8392af2ff2f65b66f401ab198cce3e65516fc2d34479ccd6b71a54e823aff
|
|
7
|
+
data.tar.gz: c7da2239f3672b60a74d01e3a546e3c24f67c934c88399957e2a72b395e2e5ca10697cde68830e190b931d2907adea00ce07f7216ecfb011628344c566746d78
|
data/lib/doer.rb
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Copyright 2025 Ahmet Cetinkaya
|
|
2
|
+
|
|
3
|
+
# This file is part of Doer.
|
|
4
|
+
|
|
5
|
+
# Doer is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
|
|
10
|
+
# Doer is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with Doer. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
module Doer
|
|
19
|
+
class Doer
|
|
20
|
+
def initialize(period, dt)
|
|
21
|
+
@period = period
|
|
22
|
+
@dt = dt
|
|
23
|
+
@lam = lambda{nil}
|
|
24
|
+
@mut = Mutex.new
|
|
25
|
+
@in_call = false
|
|
26
|
+
dloop
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def dloop
|
|
30
|
+
Thread.new do
|
|
31
|
+
last = Time.new
|
|
32
|
+
loop do
|
|
33
|
+
sleep(@dt)
|
|
34
|
+
now = Time.new
|
|
35
|
+
if now - last > @period
|
|
36
|
+
last = now
|
|
37
|
+
@mut.synchronize do
|
|
38
|
+
unless @in_call
|
|
39
|
+
Thread.new do
|
|
40
|
+
@in_call = true
|
|
41
|
+
old_lam = @lam
|
|
42
|
+
@lam.call
|
|
43
|
+
@in_call = false
|
|
44
|
+
if @lam == old_lam
|
|
45
|
+
@lam = lambda{nil}
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def task(&lam)
|
|
56
|
+
@mut.synchronize do
|
|
57
|
+
@lam = lam
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: doer
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: '0.1'
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Ahmet Cetinkaya
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: doer provides a ruby class Doer that completes tasks that you want to
|
|
13
|
+
schedule and possibly update even while an existing task is being executed. It is
|
|
14
|
+
useful for handling tasks in gui applications with user input.
|
|
15
|
+
email:
|
|
16
|
+
- cetinkayaahmet@yahoo.com
|
|
17
|
+
executables: []
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files: []
|
|
20
|
+
files:
|
|
21
|
+
- lib/doer.rb
|
|
22
|
+
homepage: https://github.org/cetinkaya/doer
|
|
23
|
+
licenses:
|
|
24
|
+
- GPL-3.0
|
|
25
|
+
metadata: {}
|
|
26
|
+
rdoc_options: []
|
|
27
|
+
require_paths:
|
|
28
|
+
- lib
|
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
requirements: []
|
|
40
|
+
rubygems_version: 3.6.7
|
|
41
|
+
specification_version: 4
|
|
42
|
+
summary: doer is a ruby class that completes tasks that you want to schedule and possibly
|
|
43
|
+
update even while an existing task is being executed.
|
|
44
|
+
test_files: []
|