Commit Graph

21 Commits

Author SHA1 Message Date
Falk Seidel
d647eaabc0 Welcome to 2018
The same procedure as last year, Miss Sophie?
The same procedure as every year, James.

[skip ci]
2018-01-19 19:38:58 +00:00
Phansa
3189ce7f8a Welcome to 2017
Welcome to 2017

temp

temp2
2017-03-12 20:34:26 -04:00
Alexey Sokolov
8eeeaf71a0 Add framework for translating ZNC to different languages 2016-01-31 20:09:19 +00:00
Falk Seidel
8f73840e74 Welcome to 2016
🎆  Happy 2016 🎆
2016-01-01 20:11:21 +01:00
Alexey Sokolov
d185d6f22d clang-format: switch tabs to spaces
I like tabs, but I have to admit that spaces make source code more
consistent, because every editor/viewer tends to render tabs differently :(
2015-12-07 00:53:30 +00:00
Alexey Sokolov
33b0627d75 Add clang-format configuration.
For now, it uses tabs like before, to make the diff easier to read/check.
One of following commits will switch it to spaces.
2015-12-07 00:53:01 +00:00
Alexey Sokolov
9c48119897 Use C++11 threads instead of custom pthread wrappers.
Signal handling of CThread was handled in previous commit.
2015-12-06 00:11:15 +00:00
J-P Nurmi
e93c37fc6b Cleanup extra semi-colons 2015-08-07 22:00:08 +02:00
J-P Nurmi
6a6bb648d1 Use member initialization lists [-Weffc++] (#270) 2015-02-28 21:59:01 +01:00
J-P Nurmi
70c0ffb10b Use nullptr (#816)
Changes applied by 'clang-modernize -use-nullptr [...]'
2015-02-25 09:20:20 +01:00
Uli Schlachter
fd34f84bfd ~CThreadPool(): Handle spurious wakeups
From pthread_cond_wait()'s man page:

  When using condition variables there is always a boolean predicate involving
  shared variables associated with each condition wait that is true if the
  thread should proceed. Spurious wakeups from the pthread_cond_wait() or
  pthread_cond_timedwait() functions may occur. Since the return from
  pthread_cond_wait() or pthread_cond_timedwait() does not imply anything about
  the value of this predicate, the predicate should be re-evaluated upon such
  return.

Fix ~CThreadPool() to account for this possibility.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2015-02-19 08:38:28 +01:00
OGAWA Hirofumi
b8dcb5f706 Don't polling to wait the exit of threads in CThreadPool destructor
All values are protected by m_mutex. So we don't need the polling to
wait m_num_threads==0 with wakeups, instead simply use CConditionVariable.
2015-01-25 21:55:42 +09:00
Falk Seidel
2e29d49a53 Welcome to 2015 2014-12-31 11:28:38 +01:00
Uli Schlachter
e0e86e8b02 CThreadPool::cancelJobs(): Add a comment explaining the logic a bit
Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-08-11 09:09:38 +02:00
Uli Schlachter
74fdd97a52 CJob: Even cancel finished jobs
When a job was cancelled after its runThread() method finished, but before the
main thread noticed this and reacted, we would just run runMain() before and
pretend the job finished normally.

However, with CModuleJob this means that runMain() might get called for a module
which is currently being destructed. This has bad effects with virtual functions
and thus causes problems. It's better to just really cancel the job instead.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-08-11 09:09:38 +02:00
Uli Schlachter
0fddbba230 CThreadPool: Fix a race when starting threads
There was a race where threads were themselves responsible for increasing the
counter for the number of running threads. This left an open window where the
thread was already started, but our counter was not yet increased. The effect of
this race would be that we start more threads than we should.

Fix this by increasing the counter before actually starting new worker threads.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-08-06 15:20:12 +02:00
Uli Schlachter
1d67e87d90 CThreadPool: Add cancellation support
This adds CThreadPool::cancelJob() and cancelJobs() which can cancel a set of
jobs synchronously. These functions only return when the job was successfully
cancelled.

It tries to cancel the jobs as quickly as possible, skipping any callbacks on
CJob that were not yet called. A job that is already running can use
CJob::wasCancelled() to check if it should quit.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2014-08-06 15:15:57 +02:00
Falk Seidel
f19b4caa43 Welcome to 2014 - year 10 with ZNC 2013-12-31 10:10:55 +01:00
Alexey Sokolov
b2dcad5fd4 Change ZNC license to Apache 2.0
The following people agreed with the change, in alphabetical order:
(people who approved in several ways are listed only once)
By email:
- Adam (from Anope)
- Austin Morton
- Brian Campbell
- Christian Walde
- Daniel Holbert
- Daniel Wallace
- Falk Seidel
- Heiko Hund
- Ingmar Runge
- Jim Hull
- Kyle Fuller
- Lee Aylward
- Martin Martimeo
- Matt Harper
- Michael J Edgar
- Michael Ziegler
- Nick Bebout
- Paul Driver
- Perry Nguyen
- Philippe (cycomate)
- Reuben Morais
- Roland Hieber
- Sebastian Ramacher
- Stefan Rado
- Stéphan Kochen
- Thomas Ward
- Toon Schoenmakers
- Veit Wahlich
- Wulf C. Krueger

By IRC:
- CNU
- Jonas Gorski
- Joshua M. Clulow
- Prozac/SHiZNO
- SilverLeo
- Uli Schlachter

At https://github.com/znc/znc/issues/311 :
- Alexey Sokolov
- Elizabeth Myers
- flakes
- Jens-Andre Koch
- Jyzee
- KindOne/ineedalifetoday
- Lee Williams
- Mantas Mikulėnas
- md-5
- Reed Loden

At the last few pull requests' comments:
- Allan Odgaard
- Jacob Baines
- Lluís Batlle i Rossell
- ravomavain
- protomouse

The following commits' authors didn't respond:
Trivial changes:
- f70f1086fd
- 4ca8b50e45

The changes which are not presented in master anymore:
- 5512ed2ea0
- 960a4498f7
- 0f739de2c0
- 7f53cc810b

Fix #311
Fix #218
2013-06-14 00:43:34 +04:00
Uli Schlachter
53c579b296 CJob: Add a way to do stuff on the main thread
This just moves the pipe from the socket code to the thread pool. However, now
all CJobs can use this and there is a single place for them to get deleted.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-03-15 11:58:27 +01:00
Uli Schlachter
75f2e3fa41 Add a generic threads abstraction
This should make it easier to work with threads. It provides classes for mutexes
and condition variables. Additionally, there is a special CMutexGuard that
automatically unlocks the mutex on destruction and a CThreadPool class.

This thread pool is used to replace the thread pool in the sockets code.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2013-03-15 11:58:22 +01:00