Skip to content

MulleFoundation/MulleThread

Repository files navigation

MulleThread

🍝 MulleThread sleeps until nudged

A MulleInvocationQueue is fed with NSInvocations, which it then executes in serial in a separate thread.

Release Version Release Notes
Mulle kybernetiK tag Build Status RELEASENOTES

MulleThread

The MulleThread is the combination of a NSConditionLock and NSThread. The thread idles waiting for work. If there is something to do, you -nudge the thread and it runs it's "target" / "selector". Then the thread returns to idle, waiting for the next -nudge.

MulleThread also manages a NSAutoreleasePool for your code.

Create a thread and start it:

thread = [MulleThread mulleThreadWithTarget:foo
                                   selector:@selector( runServer:)
                                     object:nil];
[thread start];

The initial -start will not call "target" / "selector" yet. The thread waits for a -nudge. You can -preempt the thread at any time. For a more graceful shutdown use -cancelWhenIdle. The thread code can -cancel itself at any time. Use of +exit to finish a "MulleThread" is bad style.

[thread nudge];
[thread preempt];
[thread cancelWhenIdle];

To wait for a thread to complete use -mulleJoin. But you need to -preempt or -cancelWhenIdle before.

Requirements

Requirement Release Version Description
MulleFoundationBase Mulle kybernetiK tag Build Status 🧱 MulleFoundationBase amalgamates Foundations projects
mulle-objc-list Mulle kybernetiK tag Build Status πŸ“’ Lists mulle-objc runtime information contained in executables.

You are here

Overview

Add

Use mulle-sde to add MulleThread to your project:

mulle-sde add github:MulleFoundation/MulleThread

Install

Install with mulle-sde

Use mulle-sde to build and install MulleThread and all dependencies:

mulle-sde install --prefix /usr/local \
   https://github.com/MulleFoundation/MulleThread/archive/latest.tar.gz

Manual Installation

Install the requirements:

Requirements Description
MulleFoundationBase 🧱 MulleFoundationBase amalgamates Foundations projects
mulle-objc-list πŸ“’ Lists mulle-objc runtime information contained in executables.

Download the latest tar or zip archive and unpack it.

Install MulleThread into /usr/local with cmake:

cmake -B build \
      -DCMAKE_INSTALL_PREFIX=/usr/local \
      -DCMAKE_PREFIX_PATH=/usr/local \
      -DCMAKE_BUILD_TYPE=Release &&
cmake --build build --config Release &&
cmake --install build --config Release

Author

Nat! for Mulle kybernetiK