Commit graph

31 commits

Author SHA1 Message Date
Sergey Bugaev
d51173e4c4 LibThread: Add API to join a thread 2020-11-24 21:36:28 +01:00
Itamar
8af67210cf HackStudio: Detach from debugged process before terminating
Fixes #3308
2020-09-26 17:18:21 +02:00
Ben Wiederhake
08f9bc26a6 Meta+LibHTTP through LibWeb: Make clang-format-10 clean 2020-09-25 21:18:17 +02:00
Brian Gianforcaro
0ca00639a9 LibThread: Uninitialized member variable in Thread, found by Coverity 2020-08-17 09:17:57 +02:00
Muhammad Zahalqa
33cb41edcb LibThread: Lockable - add forwarding constructor 2020-08-14 18:15:10 +02:00
Ben Wiederhake
bee08a4b9f Kernel: More PID/TID typing 2020-08-10 11:51:45 +02:00
Muhammad Zahalqa
91d259ef1c
LibThread: Remove redundant --m_level in Lock::unlock() (#3040) 2020-08-07 17:24:49 +02:00
Muhammad Zahalqa
5fe6c13e5b
LibThread: Remove redundant r/w of atomic variable in Lock::lock() (#3013)
m_holder.compare_exchange_strong(expected, desired, ...)
will either successfully update the value to desired if == expected
or put the current value in expected otherwise.
2020-08-06 17:50:25 +02:00
Muhammad Zahalqa
f2d3cc7325 LibPThread: Make pthread_exit a noreturn function
LibPThread: mark pthread_exit a noreturn function using compiler attributes
LibThread: remove a call to pthread_exit from Thread::start lambda expression
as it make the return of teh lambda unreachable.
2020-07-21 01:10:41 +02:00
Sergey Bugaev
450a2a0f9c Build: Switch to CMake :^)
Closes https://github.com/SerenityOS/serenity/issues/2080
2020-05-14 20:15:18 +02:00
Andreas Kling
888e35f0fe AK: Add ALWAYS_INLINE, NEVER_INLINE and FLATTEN macros
It's tedious to write (and look at) [[gnu::always_inline]] etc. :^)
2020-04-30 11:43:25 +02:00
Andreas Kling
94647fa4ab LibThread: Simplify the userspace Lock to remove CAS on unlock()
Instead of using a separate synchronization variable, just use the lock
holder TID for synchronization. This way, we only need to CAS when
first acquiring a lock.
2020-04-13 12:33:42 +02:00
Sergey Bugaev
cbf2881bf7 LibThread: Fix destroying background actions
In the old model, before bc319d9e88, the parent
(the background thread) would delete us when it exits (i.e. never), so we had to
keep track of our own refcount in order to destroy ourselves when we're done.

With bc319d9e88, the parent keeps additional
reference to us, so:
* There should be no need to explicitly ref() ourselves
* The unref() would not get rid of the last reference to us anymore

The latter is why all the BackgroundAction's were getting leaked. Fix this by
simply unparenting ourselves from the background thread when we're done.
2020-02-25 10:17:31 +01:00
Andreas Kling
90c4e6b000 LibThread: Post the completion callbacks to the *current* event loop
FilePicker was not showing thumbnails correctly because once each
thumbnail rendering BackgroundAction completed, it posted a deferred
invocation event to the *main* event loop.

Since FilePicker runs in a nested event loop, those completion
callbacks never ran until it was too late and the FilePicker was gone.
2020-02-24 21:18:35 +01:00
Andreas Kling
8f7333f080 LibCore: Add a forward declaration header
This patch adds <LibCore/Forward.h> and uses it in various places to
shrink the header dependency graph.
2020-02-14 23:31:18 +01:00
Andreas Kling
d17e23bd27 LibCore: Remove leading C from filenames 2020-02-06 15:04:03 +01:00
joshua stein
482611766a LibThread: Store thread id as pthread_t, use pthread_self()
Serenity calls pthread_self() for gettid() anyway but this makes it
portable.
2020-02-05 18:39:45 +01:00
Andreas Kling
2d39da5405 LibCore: Put all classes in the Core namespace and remove the leading C
I've been wanting to do this for a long time. It's time we start being
consistent about how this stuff works.

The new convention is:

- "LibFoo" is a userspace library that provides the "Foo" namespace.

That's it :^) This was pretty tedious to convert and I didn't even
start on LibGUI yet. But it's coming up next.
2020-02-02 15:15:30 +01:00
Sergey Bugaev
c0b32f7b76 Meta: Claim copyright for files created by me
This changes copyright holder to myself for the source code files that I've
created or have (almost) completely rewritten. Not included are the files
that were significantly changed by others even though it was me who originally
created them (think HtmlView), or the many other files I've contributed code to.
2020-01-24 15:15:16 +01:00
Andreas Kling
3de5439579 AK: Let's call decrementing reference counts "unref" instead of "deref"
It always bothered me that we're using the overloaded "dereference"
term for this. Let's call it "unreference" instead. :^)
2020-01-23 15:14:21 +01:00
Andreas Kling
94ca55cefd Meta: Add license header to source files
As suggested by Joshua, this commit adds the 2-clause BSD license as a
comment block to the top of every source file.

For the first pass, I've just added myself for simplicity. I encourage
everyone to add themselves as copyright holders of any file they've
added or modified in some significant way. If I've added myself in
error somewhere, feel free to replace it with the appropriate copyright
holder instead.

Going forward, all new source files should include a license header.
2020-01-18 09:45:54 +01:00
Andreas Kling
eede6cfd06 LibPthread: Fix incompatible pthread_setname_np(), pthread_getname_np()
Other implementations of pthread_setname_np() do not take the name
length as an argument.

For pthread_getname_np(), other implementations take the buffer size
as a size_t.

This patch brings us in line with other implementations.
2020-01-11 12:54:30 +01:00
joshua stein
ac25438d54 Build: clean up build system, use one shared Makefile
Allow everything to be built from the top level directory with just
'make', cleaned with 'make clean', and installed with 'make
install'.  Also support these in any particular subdirectory.

Specifying 'make VERBOSE=1' will print each ld/g++/etc. command as
it runs.

Kernel and early host tools (IPCCompiler, etc.) are built as
object.host.o so that they don't conflict with other things built
with the cross-compiler.
2019-12-20 20:20:54 +01:00
Andrew Kaster
0b38a553b1 LibThread: Allow setting thread name in constructor
Thread now has an optional thread_name parameter to the consturctor
that will call pthread_setname_np if given.
2019-12-08 14:09:29 +01:00
Andreas Kling
69ca9cfd78 LibPthread: Start working on a POSIX threading library
This patch adds pthread_create() and pthread_exit(), which currently
simply wrap our existing create_thread() and exit_thread() syscalls.

LibThread is also ported to using LibPthread.
2019-11-13 21:49:24 +01:00
George Pickering
704f48d7f3 POSIX compliance: (most) shell scripts converted to generic shell
Ports/.port_include.sh, Toolchain/BuildIt.sh, Toolchain/UseIt.sh
have been left largely untouched due to use of Bash-exclusive
functions and variables such as $BASH_SOURCE, pushd and popd.
2019-11-03 09:26:22 +01:00
Tom
b0773a8ea6 AK: Add Atomic.h
Use gcc built-in atomics
2019-10-12 19:30:59 +02:00
Andreas Kling
bc319d9e88 LibCore: Make CObject reference-counted
Okay, I've spent a whole day on this now, and it finally kinda works!
With this patch, CObject and all of its derived classes are reference
counted instead of tree-owned.

The previous, Qt-like model was nice and familiar, but ultimately also
outdated and difficult to reason about.

CObject-derived types should now be stored in RefPtr/NonnullRefPtr and
each class can be constructed using the forwarding construct() helper:

    auto widget = GWidget::construct(parent_widget);

Note that construct() simply forwards all arguments to an existing
constructor. It is inserted into each class by the C_OBJECT macro,
see CObject.h to understand how that works.

CObject::delete_later() disappears in this patch, as there is no longer
a single logical owner of a CObject.
2019-09-22 00:25:25 +02:00
Andreas Kling
c686264703 LibThread: Add missing install.sh script
This unbreaks the SDL port build.
2019-09-01 16:59:12 +02:00
Sergey Bugaev
3439a479af LibThread: Move CLock to LibThread::Lock
And adapt all the code that uses it.
2019-08-26 11:31:14 +02:00
Sergey Bugaev
e1a6f8a27d LibThread: Introduce a new threading library
This library is meant to provide C++-style wrappers over lower
level APIs such as syscalls and pthread_* functions, as well as
utilities for easily running pieces of logic on different
threads.
2019-08-26 11:31:14 +02:00